@Test public void testTemplatingCustomizer() { TestResourceManager manager = new TestResourceManager(); Integration integration = manager.newIntegration( new Step.Builder() .stepKind(StepKind.template) .putConfiguredProperty("language", "MUSTACHE") .build(), new Step.Builder() .stepKind(StepKind.template) .putConfiguredProperty("language", "VELOCITY") .build() ); IntegrationDeployment deployment = new IntegrationDeployment.Builder() .userId("user") .id("idId") .spec(integration) .build(); CamelKIntegrationCustomizer customizer = new TemplatingCustomizer(); io.syndesis.server.controller.integration.camelk.crd.Integration i = customizer.customize( deployment, new io.syndesis.server.controller.integration.camelk.crd.Integration(), EnumSet.of(Exposure.SERVICE) ); assertThat(i.getSpec().getDependencies()).anyMatch(s -> s.startsWith("mvn:org.apache.camel:camel-mustache")); assertThat(i.getSpec().getDependencies()).anyMatch(s -> s.startsWith("mvn:org.apache.camel:camel-velocity")); }
@Override public Integration customize(IntegrationDeployment deployment, Integration integration, EnumSet<Exposure> exposure) { Set<TemplateStepLanguage> languages = deployment.getSpec().getFlows().stream() .flatMap(f -> f.getSteps().stream()) .filter(s -> s.getStepKind() == StepKind.template) .flatMap(s -> asStream(Optional.of(s.getConfiguredProperties().get("language")))) .map(TemplateStepLanguage::stepLanguage) .collect(Collectors.toSet()); if (!languages.isEmpty()) { IntegrationSpec.Builder spec = new IntegrationSpec.Builder(); if (integration.getSpec() != null) { spec = spec.from(integration.getSpec()); } for (TemplateStepLanguage lan : languages) { spec = spec.addDependencies("mvn:" + lan.mavenDependency()); } integration.setSpec(spec.build()); } return integration; }
TemplatingCustomizer implements CamelKIntegrationCustomizer { @Override public Integration customize(IntegrationDeployment deployment, Integration integration, EnumSet<Exposure> exposure) { Set<TemplateStepLanguage> languages = deployment.getSpec().getFlows().stream() .flatMap(f -> f.getSteps().stream()) .filter(s -> s.getStepKind() == StepKind.template) .flatMap(s -> asStream(Optional.of(s.getConfiguredProperties().get("language")))) .map(TemplateStepLanguage::stepLanguage) .collect(Collectors.toSet()); if (!languages.isEmpty()) { IntegrationSpec.Builder spec = new IntegrationSpec.Builder(); if (integration.getSpec() != null) { spec = spec.from(integration.getSpec()); } for (TemplateStepLanguage lan : languages) { spec = spec.addDependencies("mvn:" + lan.mavenDependency()); } integration.setSpec(spec.build()); } return integration; } }
TemplatingCustomizer implements CamelKIntegrationCustomizer { @Override public Integration customize(IntegrationDeployment deployment, Integration integration, EnumSet<Exposure> exposure) { Set<TemplateStepLanguage> languages = deployment.getSpec().getFlows().stream() .flatMap(f -> f.getSteps().stream()) .filter(s -> s.getStepKind() == StepKind.template) .flatMap(s -> asStream(Optional.of(s.getConfiguredProperties().get("language")))) .map(TemplateStepLanguage::stepLanguage) .collect(Collectors.toSet()); if (!languages.isEmpty()) { IntegrationSpec.Builder spec = new IntegrationSpec.Builder(); if (integration.getSpec() != null) { spec = spec.from(integration.getSpec()); } for (TemplateStepLanguage lan : languages) { spec = spec.addDependencies("mvn:" + lan.mavenDependency()); } integration.setSpec(spec.build()); } return integration; }  }
TemplatingCustomizer implements CamelKIntegrationCustomizer { @Override public Integration customize(IntegrationDeployment deployment, Integration integration, EnumSet<Exposure> exposure) { Set<TemplateStepLanguage> languages = deployment.getSpec().getFlows().stream() .flatMap(f -> f.getSteps().stream()) .filter(s -> s.getStepKind() == StepKind.template) .flatMap(s -> asStream(Optional.of(s.getConfiguredProperties().get("language")))) .map(TemplateStepLanguage::stepLanguage) .collect(Collectors.toSet()); if (!languages.isEmpty()) { IntegrationSpec.Builder spec = new IntegrationSpec.Builder(); if (integration.getSpec() != null) { spec = spec.from(integration.getSpec()); } for (TemplateStepLanguage lan : languages) { spec = spec.addDependencies("mvn:" + lan.mavenDependency()); } integration.setSpec(spec.build()); } return integration; }  @Override Integration customize(IntegrationDeployment deployment, Integration integration, EnumSet<Exposure> exposure); }
TemplatingCustomizer implements CamelKIntegrationCustomizer { @Override public Integration customize(IntegrationDeployment deployment, Integration integration, EnumSet<Exposure> exposure) { Set<TemplateStepLanguage> languages = deployment.getSpec().getFlows().stream() .flatMap(f -> f.getSteps().stream()) .filter(s -> s.getStepKind() == StepKind.template) .flatMap(s -> asStream(Optional.of(s.getConfiguredProperties().get("language")))) .map(TemplateStepLanguage::stepLanguage) .collect(Collectors.toSet()); if (!languages.isEmpty()) { IntegrationSpec.Builder spec = new IntegrationSpec.Builder(); if (integration.getSpec() != null) { spec = spec.from(integration.getSpec()); } for (TemplateStepLanguage lan : languages) { spec = spec.addDependencies("mvn:" + lan.mavenDependency()); } integration.setSpec(spec.build()); } return integration; }  @Override Integration customize(IntegrationDeployment deployment, Integration integration, EnumSet<Exposure> exposure);  }