Integration newIntegration(Step... steps) { for (int i = 0; i < steps.length; i++) { steps[i].getConnection().filter(r -> r.getId().isPresent()).ifPresent( resource -> this.put(resource.getId().get(), resource) ); steps[i].getAction().filter(ConnectorAction.class::isInstance).map(ConnectorAction.class::cast).filter(r -> r.getId().isPresent()).ifPresent( resource -> this.put(resource.getId().get(), resource) ); steps[i].getExtension().filter(r -> r.getId().isPresent()).ifPresent( resource -> this.put(resource.getId().get(), resource) ); steps[i] = new Step.Builder().createFrom(steps[i]).build(); } return new Integration.Builder() .id("test-integration") .name("Test Integration") .description("This is a test integration!") .addFlow(new Flow.Builder() .steps(Arrays.asList(steps)) .build()) .build(); } }
.id(integrationId) .addTag("api-provider") .createdAt(System.currentTimeMillis())
@Test public void shouldDeleteIntegrationsUpdatingDeploymentsAndDeletingOpensShiftResources() { final Integration integration = new Integration.Builder().id("to-delete").build(); when(dataManager.fetch(Integration.class, "to-delete")).thenReturn(integration); final Integration firstIntegration = new Integration.Builder().createFrom(integration).name("first to delete") .build(); final IntegrationDeployment deployment1 = new IntegrationDeployment.Builder().spec(firstIntegration).version(1) .targetState(IntegrationDeploymentState.Unpublished) .stepsDone(Collections.singletonMap("deploy", "something")).build(); final Integration secondIntegration = new Integration.Builder().createFrom(integration).name("second to delete") .build(); final IntegrationDeployment deployment2 = new IntegrationDeployment.Builder().spec(secondIntegration).version(2) .currentState(IntegrationDeploymentState.Published).targetState(IntegrationDeploymentState.Published) .stepsDone(Collections.singletonMap("deploy", "something")).build(); when(dataManager.fetchAllByPropertyValue(IntegrationDeployment.class, "integrationId", "to-delete")) .thenReturn(Stream.of(deployment1, deployment2)); final ArgumentCaptor<Integration> updated = ArgumentCaptor.forClass(Integration.class); doNothing().when(dataManager).update(updated.capture()); handler.delete("to-delete"); assertThat(updated.getValue()).isEqualToIgnoringGivenFields( new Integration.Builder().createFrom(integration).isDeleted(true).build(), "updatedAt"); verify(dataManager).update(new IntegrationDeployment.Builder().spec(firstIntegration).version(1) .currentState(IntegrationDeploymentState.Pending).targetState(IntegrationDeploymentState.Unpublished) .build().deleted()); verify(dataManager).update(new IntegrationDeployment.Builder().spec(secondIntegration).version(2) .currentState(IntegrationDeploymentState.Published).targetState(IntegrationDeploymentState.Unpublished) .build().deleted().deleted()); verify(openShiftService).delete("first to delete"); verify(openShiftService).delete("second to delete"); }
.id("test-integration") .name("Test Integration") .description("This is a test integration!")
@Override protected Integration loadIntegration() throws IOException { return new Integration.Builder() .id("asw-integration") .name("asw-integration") .addFlow(new Flow.Builder()
protected static Integration newIntegration(Step... steps) { for (int i = 0; i < steps.length; i++) { steps[i] = new Step.Builder().createFrom(steps[i]).build(); } return new Integration.Builder() .id("test-integration") .name("Test Integration") .description("This is a test integration!") .addFlow(new Flow.Builder() .steps(Arrays.asList(steps)) .build()) .build(); }
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(); }
private static Integration newIntegration(List<Step> steps) { return new Integration.Builder() .id("test") .name("test") .addFlow(new Flow.Builder().steps(steps).build()) .build(); } }
protected final Integration newIntegration() { return new Integration.Builder() .id("test-integration") .name("Test Integration") .description("This is a test integration!") .addFlow(new Flow.Builder().steps(createSteps()).build()) .build(); }