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));
}
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);
}
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());
}
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"));
}
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;
}
Aggregations