Search in sources :

Example 51 with Integration

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

the class ConnectorHandlerTest method shouldAugmentWithConnectorUsage.

@Test
public void shouldAugmentWithConnectorUsage() {
    final Connector connector1 = newConnector("1");
    final Connector connector2 = newConnector("2");
    final Connector connector3 = newConnector("3");
    final Step step1a = new Step.Builder().action(newActionBy(connector1)).build();
    final Step step1b = new Step.Builder().action(newActionBy(connector1)).build();
    final Step step2 = new Step.Builder().action(newActionBy(connector2)).build();
    final Integration deployment1 = newIntegration(Arrays.asList(step1a, step1b));
    final Integration deployment2 = newIntegration(Collections.singletonList(step2));
    final Integration deployment3 = newIntegration(Collections.singletonList(step2));
    when(dataManager.fetchAll(Integration.class)).thenReturn(new ListResult.Builder<Integration>().addItem(deployment1, deployment2, deployment3).build());
    final List<Connector> augmented = handler.augmentedWithUsage(Arrays.asList(connector1, connector2, connector3));
    assertThat(augmented).contains(usedConnector(connector1, 1), usedConnector(connector2, 2), usedConnector(connector3, 0));
}
Also used : ListResult(io.syndesis.common.model.ListResult) Connector(io.syndesis.common.model.connection.Connector) Integration(io.syndesis.common.model.integration.Integration) Step(io.syndesis.common.model.integration.Step) Test(org.junit.Test)

Example 52 with Integration

use of io.syndesis.common.model.integration.Integration 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)

Example 53 with Integration

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

the class UpdaterITCase method updaterShouldValidateAfterPatching.

@Test
public void updaterShouldValidateAfterPatching() {
    dataManager.create(new Integration.Builder().name("Existing integration").build());
    final Integration integration = new Integration.Builder().name("New integration").build();
    final ResponseEntity<Integration> created = post("/api/v1/integrations", integration, Integration.class, tokenRule.validToken(), HttpStatus.OK);
    final String integrationId = created.getBody().getId().get();
    final ResponseEntity<List<Violation>> response = patch("/api/v1/integrations/" + integrationId, Collections.singletonMap("name", "Existing integration"), new ParameterizedTypeReference<List<Violation>>() {
    }, tokenRule.validToken(), HttpStatus.BAD_REQUEST);
    assertThat(response.getBody()).containsOnly(new Violation.Builder().error("UniqueProperty").property("name").message("Value 'Existing integration' is not unique").build());
}
Also used : Violation(io.syndesis.common.model.Violation) Integration(io.syndesis.common.model.integration.Integration) List(java.util.List) Test(org.junit.Test)

Example 54 with Integration

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

the class TagFinderTest method findTags.

@Test
public void findTags() {
    Integration integration = new Integration.Builder().addTag("tag1").addTag("tag2").build();
    Connection connection = new Connection.Builder().addTag("tag2").addTag("tag3").build();
    ListResult<String> allTags = new TagFinder().add(ListResult.of(integration)).add(ListResult.of(connection)).getResult();
    Assert.assertEquals(3, allTags.getTotalCount());
    Assert.assertTrue(allTags.getItems().contains("tag1"));
    Assert.assertTrue(allTags.getItems().contains("tag2"));
    Assert.assertTrue(allTags.getItems().contains("tag3"));
}
Also used : Integration(io.syndesis.common.model.integration.Integration) Connection(io.syndesis.common.model.connection.Connection) Test(org.junit.Test)

Example 55 with Integration

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

the class PublishHandler method hasPublishedDeployments.

/**
 * Check if Integration has active deployments.
 * @param deployment The specified {@link IntegrationDeployment}.
 * @return  The true if there are, false otherwise.
 */
private boolean hasPublishedDeployments(IntegrationDeployment deployment) {
    Integration integration = deployment.getSpec();
    String id = Labels.validate(integration.getId().orElseThrow(() -> new IllegalStateException("Couldn't find the id of the integration")));
    String version = String.valueOf(integration.getVersion());
    Map<String, String> labels = new HashMap<>();
    labels.put(OpenShiftService.INTEGRATION_ID_LABEL, id);
    return (int) openShiftService().getDeploymentsByLabel(labels).stream().filter(d -> !version.equals(d.getMetadata().getLabels().get(OpenShiftService.DEPLOYMENT_VERSION_LABEL))).filter(d -> d.getSpec().getReplicas() > 0).count() > 0;
}
Also used : StateUpdate(io.syndesis.server.controller.StateUpdate) Properties(java.util.Properties) IntegrationProjectGenerator(io.syndesis.integration.api.IntegrationProjectGenerator) StringWriter(java.io.StringWriter) Set(java.util.Set) IOException(java.io.IOException) HashMap(java.util.HashMap) ControllersConfigurationProperties(io.syndesis.server.controller.ControllersConfigurationProperties) DeploymentData(io.syndesis.server.openshift.DeploymentData) SyndesisServerException(io.syndesis.common.util.SyndesisServerException) Map(java.util.Map) DataManager(io.syndesis.server.dao.manager.DataManager) OpenShiftService(io.syndesis.server.openshift.OpenShiftService) Integration(io.syndesis.common.model.integration.Integration) IntegrationDeploymentState(io.syndesis.common.model.integration.IntegrationDeploymentState) Collections(java.util.Collections) StateChangeHandler(io.syndesis.server.controller.StateChangeHandler) InputStream(java.io.InputStream) Labels(io.syndesis.common.util.Labels) IntegrationDeployment(io.syndesis.common.model.integration.IntegrationDeployment) Integration(io.syndesis.common.model.integration.Integration) HashMap(java.util.HashMap)

Aggregations

Integration (io.syndesis.common.model.integration.Integration)57 Test (org.junit.Test)19 Step (io.syndesis.common.model.integration.Step)17 List (java.util.List)16 Connection (io.syndesis.common.model.connection.Connection)15 Connector (io.syndesis.common.model.connection.Connector)11 DataManager (io.syndesis.server.dao.manager.DataManager)11 IOException (java.io.IOException)11 Set (java.util.Set)10 InputStream (java.io.InputStream)9 ArrayList (java.util.ArrayList)9 Collectors (java.util.stream.Collectors)9 IntegrationDeployment (io.syndesis.common.model.integration.IntegrationDeployment)8 IntegrationDeploymentState (io.syndesis.common.model.integration.IntegrationDeploymentState)8 Autowired (org.springframework.beans.factory.annotation.Autowired)8 IntegrationProjectGenerator (io.syndesis.integration.api.IntegrationProjectGenerator)7 Map (java.util.Map)7 Action (io.syndesis.common.model.action.Action)6 ConnectorAction (io.syndesis.common.model.action.ConnectorAction)6 StepKind (io.syndesis.common.model.integration.StepKind)6