@Test public void testGenerateApplicationWithOpenApiV2RestDSL() throws Exception { TestResourceManager resourceManager = new TestResourceManager(); URL location = ProjectGeneratorTest.class.getResource("/petstore-v2.json"); byte[] content = Files.readAllBytes(Paths.get(location.toURI())); resourceManager.put("petstore", new OpenApi.Builder().document(content).id("petstore").build()); Step s1 = new Step.Builder() .stepKind(StepKind.endpoint) .action(new ConnectorAction.Builder() .id(KeyGenerator.createKey()) .descriptor(new ConnectorDescriptor.Builder() .connectorId("new") .componentScheme("direct") .putConfiguredProperty("name", "start") .build()) .build()) .connection(new Connection.Builder() .connector( new Connector.Builder() .id("api-provider") .addDependency(new Dependency.Builder() .type(Dependency.Type.MAVEN) .id("io.syndesis.connector:connector-api-provider:1.x.x") .build()) .build()) .build()) .build(); Step s2 = new Step.Builder() .stepKind(StepKind.endpoint) .action(new ConnectorAction.Builder() .id(KeyGenerator.createKey()) .descriptor(new ConnectorDescriptor.Builder() .connectorId("new") .componentScheme("log") .putConfiguredProperty("loggerName", "end") .build()) .build()) .build(); Integration integration = new Integration.Builder() .id("test-integration") .name("Test Integration") .description("This is a test integration!") .addResource(new ResourceIdentifier.Builder() .kind(Kind.OpenApi) .id("petstore") .build()) .addFlow(new Flow.Builder() .steps(Arrays.asList(s1, s2)) .build()) .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); assertThat(runtimeDir.resolve("src/main/java/io/syndesis/example/Application.java")).exists(); assertThat(runtimeDir.resolve("src/main/java/io/syndesis/example/RestRoute.java")).exists(); assertThat(runtimeDir.resolve("src/main/java/io/syndesis/example/RestRouteConfiguration.java")).exists(); assertFileContents(configuration, runtimeDir.resolve("src/main/java/io/syndesis/example/RestRoute.java"), "RestRoute.java"); assertFileContents(configuration, runtimeDir.resolve("src/main/java/io/syndesis/example/RestRouteConfiguration.java"), "RestRouteConfiguration.java"); 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);  }