private List<Flow> getFlowsInitialize() { return Integration.super.getFlows(); }
private static Stream<Step> allSteps(Integration integration) { return integration.getFlows().stream().flatMap(f -> f.getSteps().stream()); }
/** * Collect dependencies. */ default Collection<Dependency> collectDependencies(Integration integration) { return collectDependencies(integration.getFlows().stream().flatMap(flow -> flow.getSteps().stream()).collect(Collectors.toList()), true); }
@Override public void configure() throws Exception { final Integration integration = loadIntegration(); final List<Flow> flows = integration.getFlows(); for (int f = 0; f < flows.size(); f++) { configureFlow(flows.get(f), String.valueOf(f)); } }
static boolean needsExposure(final IntegrationDeployment integrationDeployment) { return integrationDeployment.getSpec() .getFlows().stream().flatMap(f -> f.getSteps().stream()) .flatMap(step -> Optionals.asStream(step.getAction())) .flatMap(action -> action.getTags().stream()) .anyMatch("expose"::equals); } }
@Override public Integration updateFlowExcerpts(Integration integration) { // Update excerpt for api provider endpoints only if (integration == null || !integration.getTags().contains("api-provider")) { return integration; } return new Integration.Builder() .createFrom(integration) .flows(integration.getFlows().stream() .map(this::flowWithExcerpts) .collect(Collectors.toList())) .build(); }
@Test public void testSanitizeConnectors() { TestResourceManager resourceManager = new TestResourceManager(); resourceManager.put(TestConstants.TIMER_CONNECTOR.getId().get(), TestConstants.TIMER_CONNECTOR); Integration source = resourceManager.newIntegration( new Step.Builder() .stepKind(StepKind.endpoint) .connection(new Connection.Builder() .id("timer-connection") .connectorId(TestConstants.TIMER_CONNECTOR.getId().get()) .build()) .putConfiguredProperty("period", "5000") .action(TestConstants.PERIODIC_TIMER_ACTION) .build() ); final Optional<Connection> unsanitizedConnection = source.getFlows().get(0).getSteps().get(0).getConnection(); assertThat(unsanitizedConnection.isPresent()).isTrue(); assertThat(unsanitizedConnection.get().getConnector().isPresent()).isFalse(); Integration sanitized = ProjectGeneratorHelper.sanitize(source, resourceManager); final Optional<Connection> sanitizedConnection = sanitized.getFlows().get(0).getSteps().get(0).getConnection(); assertThat(sanitizedConnection.isPresent()).isTrue(); assertThat(sanitizedConnection.get().getConnector().isPresent()).isTrue(); assertThat(sanitizedConnection.get().getConnector().get()).isEqualTo(TestConstants.TIMER_CONNECTOR); }
final List<Flow> flows = integration.getFlows();
@Test public void testEmptyOperationSummary() throws IOException { ProvidedApiTemplate template = new ProvidedApiTemplate(dummyConnection(), "fromAction", "toAction"); String specification = TestHelper.resource("/swagger/empty-summary.json"); SwaggerAPIGenerator generator = new SwaggerAPIGenerator(); APIIntegration apiIntegration = generator.generateIntegration(specification, template); assertThat(apiIntegration).isNotNull(); assertThat(apiIntegration.getIntegration().getFlows()).hasSize(3); List<Flow> flows = apiIntegration.getIntegration().getFlows(); assertThat(flows).filteredOn(idEndsWith("-1")).first().hasFieldOrPropertyWithValue("name", "Receiving GET request on /hi"); assertThat(flows).filteredOn(idEndsWith("-2")).first().hasFieldOrPropertyWithValue("name", "post operation"); assertThat(flows).filteredOn(idEndsWith("-3")).first().hasFieldOrPropertyWithValue("name", "Receiving PUT request on /hi"); }
@Test public void testSanitizeDefaultScheduler() { TestResourceManager resourceManager = new TestResourceManager(); Integration source = resourceManager.newIntegration( new Step.Builder() .stepKind(StepKind.endpoint) .connection(new Connection.Builder() .id("timer-connection") .connector(TestConstants.HTTP_CONNECTOR) .build()) .putConfiguredProperty("schedulerExpression", "1s") .action(TestConstants.HTTP_GET_ACTION) .build() ); assertThat(source.getFlows().get(0).getScheduler().isPresent()).isFalse(); Integration sanitized = ProjectGeneratorHelper.sanitize(source, resourceManager); final Flow sanitizedFlow = sanitized.getFlows().get(0); assertThat(sanitizedFlow.getScheduler().isPresent()).isTrue(); assertThat(sanitizedFlow.getScheduler().get()).hasFieldOrPropertyWithValue("type", Scheduler.Type.timer); assertThat(sanitizedFlow.getScheduler().get()).hasFieldOrPropertyWithValue("expression", "1s"); assertThat(sanitizedFlow.getSteps().get(0).getStepKind()).isEqualTo(StepKind.endpoint); assertThat(sanitizedFlow.getSteps().get(0).getConfiguredProperties()).doesNotContainKey("scheduler-type"); assertThat(sanitizedFlow.getSteps().get(0).getConfiguredProperties()).doesNotContainKey("scheduler-expression"); }
@Test public void testSanitizeScheduler() { TestResourceManager resourceManager = new TestResourceManager(); Integration source = resourceManager.newIntegration( new Step.Builder() .stepKind(StepKind.endpoint) .connection(new Connection.Builder() .id("timer-connection") .connector(TestConstants.HTTP_CONNECTOR) .build()) .putConfiguredProperty("schedulerType", "timer") .putConfiguredProperty("schedulerExpression", "1s") .action(TestConstants.HTTP_GET_ACTION) .build() ); assertThat(source.getFlows().get(0).getScheduler().isPresent()).isFalse(); Integration sanitized = ProjectGeneratorHelper.sanitize(source, resourceManager); final Flow sanitizedFlow = sanitized.getFlows().get(0); assertThat(sanitizedFlow.getScheduler().isPresent()).isTrue(); assertThat(sanitizedFlow.getScheduler().get()).hasFieldOrPropertyWithValue("type", Scheduler.Type.timer); assertThat(sanitizedFlow.getScheduler().get()).hasFieldOrPropertyWithValue("expression", "1s"); assertThat(sanitizedFlow.getSteps().get(0).getStepKind()).isEqualTo(StepKind.endpoint); assertThat(sanitizedFlow.getSteps().get(0).getConfiguredProperties()).doesNotContainKey("scheduler-type"); assertThat(sanitizedFlow.getSteps().get(0).getConfiguredProperties()).doesNotContainKey("scheduler-expression"); }
.createFrom(sqlIntegration.getFlows().get(0).getSteps().get(0)) .connection(modSqlConnection) .build();
.createFrom(sqlIntegration.getFlows().get(0).getSteps().get(0)) .connection(modSqlConnection) .build();
); final Flow flow = integration.getFlows().get(0); final Flow flowWithScheduler = flow.builder() .scheduler(new Scheduler.Builder()
.build()); final Flow flow = integration.getFlows().get(0); final Flow flowWithScheduler = flow.builder() .scheduler(new Scheduler.Builder()
.build()); final Flow flow = integration.getFlows().get(0); final Flow flowWithScheduler = flow.builder() .scheduler(new Scheduler.Builder()