Search in sources :

Example 1 with IntegrationOverview

use of io.syndesis.common.model.integration.IntegrationOverview in project syndesis by syndesisio.

the class IntegrationHandler method toCurrentIntegrationOverview.

public IntegrationOverview toCurrentIntegrationOverview(Integration integration) {
    final DataManager dataManager = getDataManager();
    final String id = integration.getId().get();
    final IntegrationOverview.Builder builder = new IntegrationOverview.Builder().createFrom(integration);
    // add board
    DataManagerSupport.fetchBoard(dataManager, IntegrationBulletinBoard.class, id).ifPresent(builder::board);
    // Defaults
    builder.isDraft(true);
    builder.currentState(IntegrationDeploymentState.Unpublished);
    builder.targetState(IntegrationDeploymentState.Unpublished);
    // Get the latest connection.
    builder.connections(integration.getConnections().stream().map(this::toCurrentConnection).collect(Collectors.toList()));
    // Get the latest steps.
    builder.steps(integration.getSteps().stream().map(this::toCurrentSteps).collect(Collectors.toList()));
    for (IntegrationDeployment deployment : dataManager.fetchAll(IntegrationDeployment.class, new IdPrefixFilter<>(id + ":"), ReverseFilter.getInstance())) {
        builder.addDeployment(IntegrationDeploymentOverview.of(deployment));
        if (deployment.getVersion() == integration.getVersion()) {
            builder.isDraft(deployment.getVersion() != integration.getVersion());
            builder.targetState(deployment.getTargetState());
            builder.currentState(deployment.getCurrentState());
            builder.deploymentVersion(deployment.getVersion());
        }
    }
    return builder.build();
}
Also used : IntegrationOverview(io.syndesis.common.model.integration.IntegrationOverview) IntegrationBulletinBoard(io.syndesis.common.model.bulletin.IntegrationBulletinBoard) IntegrationDeployment(io.syndesis.common.model.integration.IntegrationDeployment) DataManager(io.syndesis.server.dao.manager.DataManager)

Example 2 with IntegrationOverview

use of io.syndesis.common.model.integration.IntegrationOverview in project syndesis by syndesisio.

the class IntegrationsITCase method patchIntegrationDescription.

@Test
public void patchIntegrationDescription() {
    Integration integration = new Integration.Builder().id("3001").name("test").description("My first description").build();
    post("/api/v1/integrations", integration, Integration.class);
    ResponseEntity<IntegrationOverview> result = get("/api/v1/integrations/3001", IntegrationOverview.class);
    assertThat(result.getBody().getDescription()).as("description").isEqualTo(Optional.of("My first description"));
    // Do the PATCH API call:
    Map<String, Object> patchDoc = Collections.singletonMap("description", "The second description");
    patch("/api/v1/integrations/3001", patchDoc);
    result = get("/api/v1/integrations/3001", IntegrationOverview.class);
    assertThat(result.getBody().getDescription()).as("description").isEqualTo(Optional.of("The second description"));
}
Also used : Integration(io.syndesis.common.model.integration.Integration) IntegrationOverview(io.syndesis.common.model.integration.IntegrationOverview) Test(org.junit.Test)

Example 3 with IntegrationOverview

use of io.syndesis.common.model.integration.IntegrationOverview in project syndesis by syndesisio.

the class IntegrationsITCase method createAndGetIntegration.

@Test
public void createAndGetIntegration() {
    // Verify that the integration does not exist.
    get("/api/v1/integrations/2001", RestError.class, tokenRule.validToken(), HttpStatus.NOT_FOUND);
    // Create the integration.
    Integration integration = new Integration.Builder().id("2001").name("test").build();
    post("/api/v1/integrations", integration, Integration.class);
    // Validate we can now fetch it.
    ResponseEntity<IntegrationOverview> result = get("/api/v1/integrations/2001", IntegrationOverview.class);
    assertThat(result.getBody().getName()).as("name").isEqualTo("test");
    // Create another integration.
    integration = new Integration.Builder().id("2002").name("test2").build();
    post("/api/v1/integrations", integration, Integration.class);
    // Check the we can list the integrations.
    ResponseEntity<IntegrationListResult> list = get("/api/v1/integrations", IntegrationListResult.class);
    assertThat(list.getBody().getTotalCount()).as("total count").isEqualTo(2);
    assertThat(list.getBody().getItems()).as("items").hasSize(2);
    // We should be able to export the integration too.
    ResponseEntity<byte[]> exportData = get("/api/v1/integration-support/export.zip?id=2001", byte[].class);
    assertThat(exportData.getBody()).isNotNull();
    // Lets delete it
    delete("/api/v1/integrations/2001");
    // We should not be able to fetch it again..
    get("/api/v1/integrations/2001", RestError.class, tokenRule.validToken(), HttpStatus.NOT_FOUND);
    // The list size should get smaller
    list = get("/api/v1/integrations", IntegrationListResult.class);
    assertThat(list.getBody().getTotalCount()).as("total count").isEqualTo(1);
    assertThat(list.getBody().getItems()).as("items").hasSize(1);
    // Lets now re-import the integration:
    post("/api/v1/integration-support/import", exportData.getBody(), byte[].class);
}
Also used : Integration(io.syndesis.common.model.integration.Integration) IntegrationOverview(io.syndesis.common.model.integration.IntegrationOverview) Test(org.junit.Test)

Aggregations

IntegrationOverview (io.syndesis.common.model.integration.IntegrationOverview)3 Integration (io.syndesis.common.model.integration.Integration)2 Test (org.junit.Test)2 IntegrationBulletinBoard (io.syndesis.common.model.bulletin.IntegrationBulletinBoard)1 IntegrationDeployment (io.syndesis.common.model.integration.IntegrationDeployment)1 DataManager (io.syndesis.server.dao.manager.DataManager)1