@Test public void someStepsDoNotUseConnectionsAndShouldNotBeConsidered() { final Step stepWithoutConnection = new Step.Builder().build(); final Integration integration = testIntegration().withFlowConnections(c1, c2).withFlowStepsUsingConnections(c1, c3).addFlow(new Flow.Builder().addStep(stepWithoutConnection).build()).build(); when(dataManager.fetchAll(Integration.class)).thenReturn(ListResult.of(integration)); assertThat(handler.augmentedWithUsage(c1)).isEqualTo(connectionUsed(c1, 2)); assertThat(handler.augmentedWithUsage(c2)).isEqualTo(connectionUsed(c2, 1)); assertThat(handler.augmentedWithUsage(c3)).isEqualTo(connectionUsed(c3, 1)); assertThat(handler.augmentedWithUsage(asList(c1, c2, c3))).containsOnly(connectionUsed(c1, 2), connectionUsed(c2, 1), connectionUsed(c3, 1)); }
@Test public void overviewGetShouldAugmentWithConnectionUsage() { final Step stepWithoutConnection = new Step.Builder().build(); final Integration usesC1 = testIntegration().withFlowConnections(c1).build(); final Integration usesC1andC2 = testIntegration().withFlowConnections(c1, c2).build(); final Integration usesC1andC2andC3 = testIntegration().withFlowConnections(c1, c2).withFlowStepsUsingConnections(c1, c3).addFlow(new Flow.Builder().addStep(stepWithoutConnection).build()).build(); when(dataManager.fetchAll(Integration.class)).thenReturn(ListResult.of(usesC1, usesC1andC2, usesC1andC2andC3)); when(dataManager.fetch(Connection.class, "c1")).thenReturn(c1); final ConnectionOverview overview = handler.get("c1"); assertThat(overview).isNotNull(); assertThat(overview.getUses()).isPresent(); assertThat(overview.getUses()).hasValue(4); }
.flows(Collections.singleton(new Flow.Builder().id(id + ":flow").addStep(modStep).build())) .build();
@Test public void shouldNotExposeWebHooksVia3scaleWhen3scaleIsEnabled() { final ControllersConfigurationProperties properties = new ControllersConfigurationProperties(); properties.setExposeVia3scale(true); final ExposureDeploymentDataCustomizer customizer = new ExposureDeploymentDataCustomizer(properties); final IntegrationDeployment webHookIntegration = new IntegrationDeployment.Builder() .spec(new Integration.Builder() .addFlow(new Flow.Builder().addStep(new Step.Builder().action(new ConnectorAction.Builder() .descriptor(new ConnectorDescriptor.Builder().connectorId("webhook").build()).addTag("expose") .build()).build()).build()) .build()) .build(); assertThat(customizer.determineExposure(webHookIntegration)).containsOnly(Exposure.SERVICE, Exposure.ROUTE); } }
private Integration newSqlIntegration(String id, Connection connection) { return new Integration.Builder() .id(id) .name(id) .addFlow(new Flow.Builder().id(id + ":flow").addStep(newSqlStep(connection)).build()) .createdAt(INTEGRATION_CREATED_AT) .updatedAt(INTEGRATION_UPDATED_AT) .build(); }