### Question:
ProjectGenerator implements IntegrationProjectGenerator { @Override public Properties generateApplicationProperties(final Integration integrationDefinition) { final Integration integration = resourceManager.sanitize(integrationDefinition); final Properties properties = new Properties(); properties.putAll(integration.getConfiguredProperties()); addPropertiesFrom(properties, integration, resourceManager); return properties; } 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);  }### Answer:
@Test public void testGenerateApplicationProperties() throws IOException { final ConnectorAction newAction = new ConnectorAction.Builder() .id(KeyGenerator.createKey()) .descriptor(new ConnectorDescriptor.Builder() .connectorId("new") .componentScheme("http4") .build()) .build(); final Connector newConnector = new Connector.Builder() .id("new") .addAction(newAction) .putProperty("username", new ConfigurationProperty.Builder() .componentProperty(false) .secret(true) .build()) .putProperty("password", new ConfigurationProperty.Builder() .componentProperty(false) .secret(true) .build()) .putProperty("token", new ConfigurationProperty.Builder() .componentProperty(true) .secret(true) .build()) .build(); Step s1 = new Step.Builder() .stepKind(StepKind.endpoint) .connection(new Connection.Builder() .id(KeyGenerator.createKey()) .connector(newConnector) .build()) .putConfiguredProperty("username", "my-username-2") .putConfiguredProperty("password", "my-password-2") .putConfiguredProperty("token", "my-token-2") .action(newAction) .build(); TestResourceManager resourceManager = new TestResourceManager(); ProjectGeneratorConfiguration configuration = new ProjectGeneratorConfiguration(); ProjectGenerator generator = new ProjectGenerator(configuration, resourceManager, TestConstants.MAVEN_PROPERTIES); Integration integration = new Integration.Builder() .createFrom(resourceManager.newIntegration(s1)) .putConfiguredProperty("integration", "property") .build(); Properties properties = generator.generateApplicationProperties(integration); assertThat(properties).containsOnly( entry("integration", "property"), entry("flow-0.http4-0.token", "my-token-2"), entry("flow-0.http4-0.username", "my-username-2"), entry("flow-0.http4-0.password", "my-password-2") ); }
@Test public void testGenerateApplicationPropertiesOldStyle() throws IOException { final ConnectorAction oldAction = new ConnectorAction.Builder() .id(KeyGenerator.createKey()) .descriptor(new ConnectorDescriptor.Builder() .connectorId("old") .build()) .build(); final Connector oldConnector = new Connector.Builder() .id("old") .addAction(oldAction) .putProperty("username", new ConfigurationProperty.Builder() .componentProperty(false) .secret(true) .build()) .putProperty("password", new ConfigurationProperty.Builder() .componentProperty(false) .secret(true) .build()) .putProperty("token", new ConfigurationProperty.Builder() .componentProperty(true) .secret(true) .build()) .build(); Step s1 = new Step.Builder() .stepKind(StepKind.endpoint) .connection(new Connection.Builder() .id(KeyGenerator.createKey()) .connector(oldConnector) .build()) .putConfiguredProperty("username", "my-username-1") .putConfiguredProperty("password", "my-password-1") .putConfiguredProperty("token", "my-token-1") .action(oldAction) .build(); TestResourceManager resourceManager = new TestResourceManager(); ProjectGeneratorConfiguration configuration = new ProjectGeneratorConfiguration(); ProjectGenerator generator = new ProjectGenerator(configuration, resourceManager, TestConstants.MAVEN_PROPERTIES); Integration integration = new Integration.Builder() .createFrom(resourceManager.newIntegration(s1)) .putConfiguredProperty("integration", "property") .build(); assertThatExceptionOfType(UnsupportedOperationException.class).isThrownBy(() -> generator.generateApplicationProperties(integration)) .withMessage("Old style of connectors from camel-connector are not supported anymore, please be sure that integration json satisfy connector.getComponentScheme().isPresent() || descriptor.getComponentScheme().isPresent()"); }