@Test public void testOpenApiCustomizer() throws Exception { TestResourceManager manager = new TestResourceManager(); Connector connector; ConnectorAction webhookIncomingAction; try (InputStream is = WebhookCustomizerTest.class.getResourceAsStream("/META-INF/syndesis/connector/webhook.json")) { connector = JsonUtils.readFromStream(is, Connector.class); webhookIncomingAction = connector.getActions(ConnectorAction.class).stream() .filter(a -> a.getId().get().equals("io.syndesis:webhook-incoming")) .findFirst() .orElseThrow(IllegalArgumentException::new); } webhookIncomingAction = webhookIncomingAction.builder().descriptor(new ConnectorDescriptor.Builder().connectorId("webhook").build()).build(); Integration integration = manager.newIntegration( new Step.Builder() .stepKind(StepKind.endpoint) .putConfiguredProperty("contextPath", "token") .action(webhookIncomingAction) .connection(new Connection.Builder() .connector(connector) .build()) .build() ); IntegrationDeployment deployment = new IntegrationDeployment.Builder() .userId("user") .id("idId") .spec(integration) .build(); CamelKIntegrationCustomizer customizer = new WebhookCustomizer(); 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().getConfiguration()).hasSize(1); assertThat(i.getSpec().getConfiguration()).anyMatch( c -> Objects.equals("customizer.platform-http.path=/webhook/", c.getValue()) && Objects.equals("property", c.getType()) ); }
@Override public Integration customize(IntegrationDeployment deployment, Integration integration, EnumSet<Exposure> exposure) { IntegrationSpec.Builder spec = new IntegrationSpec.Builder(); if (integration.getSpec() != null) { spec = spec.from(integration.getSpec()); } if (!CamelKSupport.isWebhookPresent(deployment.getSpec())) { return integration; } try { spec.addConfiguration( new ConfigurationSpec.Builder() .type("property") .value("customizer.platform-http.path=/webhook/") .build() ); } catch (Exception e) { throw new IllegalStateException(e); } integration.setSpec(spec.build()); return integration; }
WebhookCustomizer implements CamelKIntegrationCustomizer { @Override public Integration customize(IntegrationDeployment deployment, Integration integration, EnumSet<Exposure> exposure) { IntegrationSpec.Builder spec = new IntegrationSpec.Builder(); if (integration.getSpec() != null) { spec = spec.from(integration.getSpec()); } if (!CamelKSupport.isWebhookPresent(deployment.getSpec())) { return integration; } try { spec.addConfiguration( new ConfigurationSpec.Builder() .type("property") .value("customizer.platform-http.path=/webhook/") .build() ); } catch (Exception e) { throw new IllegalStateException(e); } integration.setSpec(spec.build()); return integration; } }
WebhookCustomizer implements CamelKIntegrationCustomizer { @Override public Integration customize(IntegrationDeployment deployment, Integration integration, EnumSet<Exposure> exposure) { IntegrationSpec.Builder spec = new IntegrationSpec.Builder(); if (integration.getSpec() != null) { spec = spec.from(integration.getSpec()); } if (!CamelKSupport.isWebhookPresent(deployment.getSpec())) { return integration; } try { spec.addConfiguration( new ConfigurationSpec.Builder() .type("property") .value("customizer.platform-http.path=/webhook/") .build() ); } catch (Exception e) { throw new IllegalStateException(e); } integration.setSpec(spec.build()); return integration; }  }
WebhookCustomizer implements CamelKIntegrationCustomizer { @Override public Integration customize(IntegrationDeployment deployment, Integration integration, EnumSet<Exposure> exposure) { IntegrationSpec.Builder spec = new IntegrationSpec.Builder(); if (integration.getSpec() != null) { spec = spec.from(integration.getSpec()); } if (!CamelKSupport.isWebhookPresent(deployment.getSpec())) { return integration; } try { spec.addConfiguration( new ConfigurationSpec.Builder() .type("property") .value("customizer.platform-http.path=/webhook/") .build() ); } catch (Exception e) { throw new IllegalStateException(e); } integration.setSpec(spec.build()); return integration; }  @Override Integration customize(IntegrationDeployment deployment, Integration integration, EnumSet<Exposure> exposure); }
WebhookCustomizer implements CamelKIntegrationCustomizer { @Override public Integration customize(IntegrationDeployment deployment, Integration integration, EnumSet<Exposure> exposure) { IntegrationSpec.Builder spec = new IntegrationSpec.Builder(); if (integration.getSpec() != null) { spec = spec.from(integration.getSpec()); } if (!CamelKSupport.isWebhookPresent(deployment.getSpec())) { return integration; } try { spec.addConfiguration( new ConfigurationSpec.Builder() .type("property") .value("customizer.platform-http.path=/webhook/") .build() ); } catch (Exception e) { throw new IllegalStateException(e); } integration.setSpec(spec.build()); return integration; }  @Override Integration customize(IntegrationDeployment deployment, Integration integration, EnumSet<Exposure> exposure);  }