@Test public void testGenerateProject() throws Exception { TestResourceManager resourceManager = new TestResourceManager(); Integration integration = resourceManager.newIntegration( new Step.Builder() .stepKind(StepKind.endpoint) .connection(new Connection.Builder() .id("timer-connection") .connector(TestConstants.TIMER_CONNECTOR) .build()) .putConfiguredProperty("period", "5000") .action(TestConstants.PERIODIC_TIMER_ACTION) .build(), new Step.Builder() .stepKind(StepKind.mapper) .putConfiguredProperty("atlasmapping", "{}") .build(), new Step.Builder() .stepKind(StepKind.ruleFilter) .putConfiguredProperty("predicate", "AND") .putConfiguredProperty("rules", "[{ \"path\": \"in.header.counter\", \"op\": \">\", \"value\": \"10\" }]") .build(), new Step.Builder() .stepKind(StepKind.extension) .extension(new Extension.Builder() .id("my-extension-1") .extensionId("my-extension-1") .addDependency(Dependency.maven("org.slf4j:slf4j-api:1.7.11")) .addDependency(Dependency.maven("org.slf4j:slf4j-simple:1.7.11")) .addDependency(Dependency.maven("org.apache.camel:camel-spring-boot-starter:2.10.0")) .build()) .putConfiguredProperty("key-1", "val-1") .putConfiguredProperty("key-2", "val-2") .action(new StepAction.Builder() .id("my-extension-1-action-1") .addTag("expose") .descriptor(new StepDescriptor.Builder() .kind(StepAction.Kind.ENDPOINT) .entrypoint("direct:extension") .build() ).build()) .build(), new Step.Builder() .stepKind(StepKind.extension) .extension(new Extension.Builder() .id("my-extension-2") .extensionId("my-extension-2") .build()) .putConfiguredProperty("key-1", "val-1") .putConfiguredProperty("key-2", "val-2") .action(new StepAction.Builder() .id("my-extension-1-action-1") .addTag("expose") .descriptor(new StepDescriptor.Builder() .kind(StepAction.Kind.BEAN) .entrypoint("com.example.MyExtension::action") .build() ).build()) .build(), new Step.Builder() .stepKind(StepKind.extension) .extension(new Extension.Builder() .id("my-extension-3") .extensionId("my-extension-3") .build()) .putConfiguredProperty("key-1", "val-1") .putConfiguredProperty("key-2", "val-2") .action(new StepAction.Builder() .id("my-extension-2-action-1") .descriptor(new StepDescriptor.Builder() .kind(StepAction.Kind.STEP) .entrypoint("com.example.MyStep") .build() ).build()) .build(), new Step.Builder() .stepKind(StepKind.endpoint) .connection(new Connection.Builder() .id("http-connection") .connector(TestConstants.HTTP_CONNECTOR) .build()) .putConfiguredProperty("httpUri", "http: .putConfiguredProperty("username", "admin") .putConfiguredProperty("password", "admin") .putConfiguredProperty("token", "mytoken") .action(TestConstants.HTTP_GET_ACTION) .build() ); ProjectGeneratorConfiguration configuration = new ProjectGeneratorConfiguration(); configuration.getTemplates().setOverridePath(this.basePath); configuration.getTemplates().getAdditionalResources().addAll(this.additionalResources); configuration.setSecretMaskingEnabled(true); Path runtimeDir = generate(integration, configuration, resourceManager); assertFileContents(configuration, runtimeDir.resolve("pom.xml"), "pom.xml"); assertFileContentsJson(configuration, runtimeDir.resolve("src/main/resources/syndesis/integration/integration.json"), "integration.json"); assertFileContents(configuration, runtimeDir.resolve("src/main/resources/application.properties"), "application.properties"); assertFileContents(configuration, runtimeDir.resolve("src/main/resources/loader.properties"), "loader.properties"); assertFileContents(configuration, runtimeDir.resolve(".s2i/bin/assemble"), "assemble"); assertFileContents(configuration, runtimeDir.resolve("prometheus-config.yml"), "prometheus-config.yml"); assertThat(runtimeDir.resolve("extensions/my-extension-1.jar")).exists(); assertThat(runtimeDir.resolve("extensions/my-extension-2.jar")).exists(); assertThat(runtimeDir.resolve("extensions/my-extension-3.jar")).exists(); assertThat(runtimeDir.resolve("src/main/resources/mapping-flow-0-step-1.json")).exists(); try (Stream<Path> stream = Files.walk(testFolder.getRoot().toPath().resolve("integration-project")) ) { stream.sorted(Comparator.reverseOrder()) .map(Path::toFile) .forEach(File::delete); } configuration.setActivityTracing(true); runtimeDir = generate(integration, configuration, resourceManager); assertFileContents(configuration, runtimeDir.resolve("src/main/resources/application.properties"), "application-tracing.properties"); assertThat(errors).isEmpty(); }
@Override @SuppressWarnings("resource") public InputStream generate(final Integration integrationDefinition, IntegrationErrorHandler errorHandler) throws IOException { final Integration integration = resourceManager.sanitize(integrationDefinition); final PipedInputStream is = new PipedInputStream(); final ExecutorService executor = Executors.newSingleThreadExecutor(); final PipedOutputStream os = new PipedOutputStream(is); executor.execute(generateAddProjectTarEntries(integration, os, errorHandler)); return is; }
ProjectGenerator implements IntegrationProjectGenerator { @Override @SuppressWarnings("resource") public InputStream generate(final Integration integrationDefinition, IntegrationErrorHandler errorHandler) throws IOException { final Integration integration = resourceManager.sanitize(integrationDefinition); final PipedInputStream is = new PipedInputStream(); final ExecutorService executor = Executors.newSingleThreadExecutor(); final PipedOutputStream os = new PipedOutputStream(is); executor.execute(generateAddProjectTarEntries(integration, os, errorHandler)); return is; } }
ProjectGenerator implements IntegrationProjectGenerator { @Override @SuppressWarnings("resource") public InputStream generate(final Integration integrationDefinition, IntegrationErrorHandler errorHandler) throws IOException { final Integration integration = resourceManager.sanitize(integrationDefinition); final PipedInputStream is = new PipedInputStream(); final ExecutorService executor = Executors.newSingleThreadExecutor(); final PipedOutputStream os = new PipedOutputStream(is); executor.execute(generateAddProjectTarEntries(integration, os, errorHandler)); return is; } ProjectGenerator(ProjectGeneratorConfiguration configuration, IntegrationResourceManager resourceManager, MavenProperties mavenProperties); }
ProjectGenerator implements IntegrationProjectGenerator { @Override @SuppressWarnings("resource") public InputStream generate(final Integration integrationDefinition, IntegrationErrorHandler errorHandler) throws IOException { final Integration integration = resourceManager.sanitize(integrationDefinition); final PipedInputStream is = new PipedInputStream(); final ExecutorService executor = Executors.newSingleThreadExecutor(); final PipedOutputStream os = new PipedOutputStream(is); executor.execute(generateAddProjectTarEntries(integration, os, errorHandler)); return is; } ProjectGenerator(ProjectGeneratorConfiguration configuration, IntegrationResourceManager resourceManager, MavenProperties mavenProperties); @Override @SuppressWarnings("resource") InputStream generate(final Integration integrationDefinition, IntegrationErrorHandler errorHandler); @Override Properties generateApplicationProperties(final Integration integrationDefinition); @Override byte[] generatePom(final Integration integration); }
ProjectGenerator implements IntegrationProjectGenerator { @Override @SuppressWarnings("resource") public InputStream generate(final Integration integrationDefinition, IntegrationErrorHandler errorHandler) throws IOException { final Integration integration = resourceManager.sanitize(integrationDefinition); final PipedInputStream is = new PipedInputStream(); final ExecutorService executor = Executors.newSingleThreadExecutor(); final PipedOutputStream os = new PipedOutputStream(is); executor.execute(generateAddProjectTarEntries(integration, os, errorHandler)); return is; } ProjectGenerator(ProjectGeneratorConfiguration configuration, IntegrationResourceManager resourceManager, MavenProperties mavenProperties); @Override @SuppressWarnings("resource") InputStream generate(final Integration integrationDefinition, IntegrationErrorHandler errorHandler); @Override Properties generateApplicationProperties(final Integration integrationDefinition); @Override byte[] generatePom(final Integration integration);  }