Package at.bestsolution.efxclipse.tooling.pde.e4.project.template

Source Code of at.bestsolution.efxclipse.tooling.pde.e4.project.template.SampleTestCaseGenerator

package at.bestsolution.efxclipse.tooling.pde.e4.project.template;

import at.bestsolution.efxclipse.tooling.rrobot.model.task.CompilationUnit;
import at.bestsolution.efxclipse.tooling.rrobot.model.task.File;
import at.bestsolution.efxclipse.tooling.rrobot.model.task.Generator;
import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.util.Map;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.xtend2.lib.StringConcatenation;

@SuppressWarnings("all")
public class SampleTestCaseGenerator implements Generator<File> {
  public InputStream generate(final File file, final Map<String,Object> data) {
    EObject _eContainer = file.eContainer();
    final CompilationUnit cp = ((CompilationUnit) _eContainer);
    String _packagename = cp.getPackagename();
    CharSequence _generate = this.generate(_packagename);
    String _string = _generate.toString();
    byte[] _bytes = _string.getBytes();
    ByteArrayInputStream _byteArrayInputStream = new ByteArrayInputStream(_bytes);
    return _byteArrayInputStream;
  }
 
  public CharSequence generate(final String packageName) {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("package ");
    _builder.append(packageName, "");
    _builder.append(";");
    _builder.newLineIfNotEmpty();
    _builder.newLine();
    _builder.append("import junit.framework.Assert;");
    _builder.newLine();
    _builder.newLine();
    _builder.append("import org.jemmy.fx.SceneDock;");
    _builder.newLine();
    _builder.append("import org.junit.BeforeClass;");
    _builder.newLine();
    _builder.append("import org.junit.Test;");
    _builder.newLine();
    _builder.newLine();
    _builder.append("public class SampleTestCase {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("protected static SceneDock scene;");
    _builder.newLine();
    _builder.append("\t");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("@BeforeClass");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("public static void startApp() throws InterruptedException {");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("try {");
    _builder.newLine();
    _builder.append("\t\t\t");
    _builder.append("scene = new SceneDock();");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("} catch(Throwable t ) {");
    _builder.newLine();
    _builder.append("\t\t\t");
    _builder.append("t.printStackTrace();");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("\t");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("@Test");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("public void sampleTestMethod() {");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("Assert.fail(\"Not implemented\");");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    return _builder;
  }
}
TOP

Related Classes of at.bestsolution.efxclipse.tooling.pde.e4.project.template.SampleTestCaseGenerator

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.