Search in sources :

Example 6 with ProjectModel

use of org.talend.sdk.component.starter.server.model.ProjectModel in project component-runtime by Talend.

the class ProjectResourceTest method emptyGradleProject.

@Test
void emptyGradleProject(final WebTarget target) throws IOException {
    final ProjectModel projectModel = new ProjectModel();
    projectModel.setBuildType("Gradle");
    final Map<String, String> files = createZip(projectModel, target);
    assertEquals(Stream.of("application/gradle/", "application/", "application/gradle/wrapper/gradle-wrapper.jar", "application/gradlew.bat", "application/gradlew", "application/gradle/wrapper/gradle-wrapper.properties", "application/gradle/wrapper/", "application/README.adoc", "application/build.gradle").collect(toSet()), files.keySet());
}
Also used : Resources.resourceFileToString(org.talend.sdk.component.starter.server.service.Resources.resourceFileToString) ProjectModel(org.talend.sdk.component.starter.server.model.ProjectModel) Test(org.junit.jupiter.api.Test)

Example 7 with ProjectModel

use of org.talend.sdk.component.starter.server.model.ProjectModel in project component-runtime by Talend.

the class ProjectResourceTest method testingProject.

@Test
void testingProject(final WebTarget target) throws IOException {
    final ProjectModel projectModel = new ProjectModel();
    projectModel.setFacets(singletonList("Talend Component Kit Testing"));
    // todo: add source/proc
    final Map<String, String> files = createZip(projectModel, target);
    assertEquals(Stream.of("application/", "application/src/test/resources/", "application/src/", "application/mvnw.cmd", "application/mvnw", "application/.mvn/", "application/.mvn/wrapper/maven-wrapper.properties", "application/.mvn/wrapper/", "application/.mvn/wrapper/maven-wrapper.jar", "application/src/test/", "application/src/test/resources/log4j2.xml", "application/pom.xml", "application/README.adoc").collect(toSet()), files.keySet());
    Stream.of("component-api", "<source>1.8</source>", "<trimStackTrace>false</trimStackTrace>").forEach(token -> assertTrue(files.get("application/pom.xml").contains(token), token));
    assertEquals("= A Talend generated Component Starter Project\n" + "\n" + "== Test\n" + "\n" + "=== Talend Component Kit Testing\n" + "\n" + "Talend Component Kit Testing skeleton generator. For each component selected it generates an associated test suffixed with `Test`.\n" + "\n" + "\n", files.get("application/README.adoc"));
}
Also used : Resources.resourceFileToString(org.talend.sdk.component.starter.server.service.Resources.resourceFileToString) ProjectModel(org.talend.sdk.component.starter.server.model.ProjectModel) Test(org.junit.jupiter.api.Test)

Example 8 with ProjectModel

use of org.talend.sdk.component.starter.server.model.ProjectModel in project component-runtime by Talend.

the class ProjectResourceTest method travisFacet.

@Test
void travisFacet(final WebTarget target) throws IOException {
    final ProjectModel projectModel = new ProjectModel();
    projectModel.setFacets(singletonList("Travis CI"));
    final Map<String, String> files = createZip(projectModel, target);
    assertTrue(files.get("application/README.adoc").contains("=== Travis CI\n"));
    assertTrue(files.get("application/.travis.yml").contains("language: java"));
}
Also used : Resources.resourceFileToString(org.talend.sdk.component.starter.server.service.Resources.resourceFileToString) ProjectModel(org.talend.sdk.component.starter.server.model.ProjectModel) Test(org.junit.jupiter.api.Test)

Example 9 with ProjectModel

use of org.talend.sdk.component.starter.server.model.ProjectModel in project component-runtime by Talend.

the class ProjectResourceTest method emptyMavenProject.

@Test
void emptyMavenProject(final WebTarget target) throws IOException {
    final ProjectModel projectModel = new ProjectModel();
    final Map<String, String> files = createZip(projectModel, target);
    assertEquals(Stream.of("application/.mvn/wrapper/", "application/mvnw.cmd", "application/", "application/mvnw", "application/.mvn/", "application/.mvn/wrapper/maven-wrapper.jar", "application/.mvn/wrapper/maven-wrapper.properties", "application/pom.xml", "application/README.adoc").collect(toSet()), files.keySet());
    Stream.of("component-api", "<source>1.8</source>", "<trimStackTrace>false</trimStackTrace>").forEach(token -> assertTrue(files.get("application/pom.xml").contains(token), token));
    assertEquals("= A Talend generated Component Starter Project\n", files.get("application/README.adoc"));
    assertEquals(resourceFileToString("generated/ProjectResourceTest/emptyProject/pom.xml").replace("@runtime.version@", Versions.KIT).replace("@api.version@", Versions.API_KIT), files.get("application/pom.xml"));
}
Also used : Resources.resourceFileToString(org.talend.sdk.component.starter.server.service.Resources.resourceFileToString) ProjectModel(org.talend.sdk.component.starter.server.model.ProjectModel) Test(org.junit.jupiter.api.Test)

Example 10 with ProjectModel

use of org.talend.sdk.component.starter.server.model.ProjectModel in project component-runtime by Talend.

the class ProjectResourceTest method wadlFacetGradle.

@Test
void wadlFacetGradle(final WebTarget target) throws IOException {
    final ProjectModel projectModel = new ProjectModel();
    projectModel.setBuildType("Gradle");
    projectModel.setPackageBase("com.foo");
    projectModel.setFacets(singletonList("WADL Client Generation"));
    final Map<String, String> files = createZip(projectModel, target);
    assertWadl(files);
    Stream.of("apply plugin: 'nebula.provided-base'\n" + "apply plugin: 'org.talend.sdk.component'\n" + "apply plugin: 'java'\n" + "\n" + "tasks.withType(JavaCompile) {\n" + "    sourceCompatibility = 1.8\n" + "    targetCompatibility = 1.8\n" + "    options.compilerArgs << '-parameters'\n" + "    options.fork = true\n" + "}\n" + "\n" + "import org.apache.cxf.tools.common.ToolContext\n" + "import org.apache.cxf.tools.wadlto.WADLToJava\n" + "\n" + "buildscript {\n" + "  repositories {\n" + "    mavenLocal()\n" + "    mavenCentral()\n" + "    maven {\n" + "      url \"https://plugins.gradle.org/m2/\"\n" + "    }\n" + "  }\n" + "  dependencies {\n" + "    classpath \"com.netflix.nebula:gradle-extra-configurations-plugin:3.0.3\"\n" + "    classpath \"org.talend.sdk.component:gradle-talend-component:" + Versions.KIT + "\"\n" + "    classpath \"org.apache.cxf:cxf-tools-wadlto-jaxrs:3.2.4\"\n" + "  }\n" + "}\n" + "\n" + "repositories {\n" + "  mavenLocal()\n" + "  mavenCentral()\n" + "}\n" + "\n" + "group = 'com.component'\n" + "description = 'An application generated by the Talend Component Kit Starter'\n" + "\n" + "jar {\n" + "  baseName = 'application'\n" + "  version = '0.0.1-SNAPSHOT'\n" + "}\n" + "\n" + "test {\n" + "  testLogging.showStandardStreams = true\n" + "}\n" + "def wadlGeneratedFolder = \"$buildDir/generated-sources/cxf\"\n" + "task generateWadlClient {\n" + "  def wadl = \"$projectDir/src/main/resources/wadl/client.xml\"\n" + "\n" + "  inputs.file(wadl)\n" + "  outputs.dir(wadlGeneratedFolder)\n" + "\n" + "  doLast {\n" + "    new File(wadlGeneratedFolder).mkdirs()\n" + "\n" + "    new WADLToJava([\n" + "      \"-d\", wadlGeneratedFolder,\n" + "      \"-p\", \"com.application.client.wadl\",\n" + "      wadl\n" + "    ] as String[]).run(new ToolContext())\n" + "  }\n" + "}\n" + "\n" + "sourceSets {\n" + "  main {\n" + "    java {\n" + "      project.tasks.compileJava.dependsOn project.tasks.generateWadlClient\n" + "      srcDir wadlGeneratedFolder\n" + "    }\n" + "  }\n" + "}\n" + "\n" + "repositories {\n" + "  mavenCentral()\n" + "}\n" + "\n" + "dependencies {\n" + "  provided group: 'org.talend.sdk.component', name: 'component-api', version: '" + Versions.API_KIT + "'\n" + "  compile group: 'org.apache.cxf', name: 'cxf-rt-rs-client', version: '3.2.4'\n" + "}").forEach(string -> assertTrue(files.get("application/build.gradle").contains(string), string));
}
Also used : Resources.resourceFileToString(org.talend.sdk.component.starter.server.service.Resources.resourceFileToString) ProjectModel(org.talend.sdk.component.starter.server.model.ProjectModel) Test(org.junit.jupiter.api.Test)

Aggregations

ProjectModel (org.talend.sdk.component.starter.server.model.ProjectModel)12 Test (org.junit.jupiter.api.Test)10 Resources.resourceFileToString (org.talend.sdk.component.starter.server.service.Resources.resourceFileToString)10 InputStream (java.io.InputStream)2 ZipInputStream (java.util.zip.ZipInputStream)2 BufferedInputStream (java.io.BufferedInputStream)1 BufferedReader (java.io.BufferedReader)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 File (java.io.File)1 FileWriter (java.io.FileWriter)1 IOException (java.io.IOException)1 InputStreamReader (java.io.InputStreamReader)1 Writer (java.io.Writer)1 Annotation (java.lang.annotation.Annotation)1 StandardCharsets (java.nio.charset.StandardCharsets)1 Files (java.nio.file.Files)1 StandardCopyOption (java.nio.file.StandardCopyOption)1 StandardOpenOption (java.nio.file.StandardOpenOption)1 ArrayList (java.util.ArrayList)1