Search in sources :

Example 6 with Icon

use of io.syndesis.common.model.icon.Icon in project syndesis by syndesisio.

the class CustomConnectorITCase method shouldCreateNewCustomConnectorsFromMultipartWithSpecificationAndIcon.

@Test
public void shouldCreateNewCustomConnectorsFromMultipartWithSpecificationAndIcon() throws IOException {
    final ResponseEntity<Connector> response = post("/api/v1/connectors/custom", multipartBody(new ConnectorSettings.Builder().connectorTemplateId(TEMPLATE_ID).build(), getClass().getResourceAsStream("/io/syndesis/server/runtime/test-image.png"), new ByteArrayInputStream("here-be-specification".getBytes(StandardCharsets.US_ASCII))), Connector.class, tokenRule.validToken(), HttpStatus.OK, multipartHeaders());
    final Connector created = response.getBody();
    assertThat(created).isNotNull();
    assertThat(created.getDescription()).isEqualTo("test-description");
    assertThat(dataManager.fetch(Connector.class, response.getBody().getId().get())).isNotNull();
    assertThat(created.getIcon()).startsWith("db:");
    final Icon icon = dataManager.fetch(Icon.class, created.getIcon().substring(3));
    assertThat(icon.getMediaType()).isEqualTo(MediaType.IMAGE_PNG_VALUE);
    try (InputStream storedIcon = iconDao.read(icon.getId().get());
        InputStream expectedIcon = CustomConnectorITCase.class.getResourceAsStream("/io/syndesis/server/runtime/test-image.png")) {
        assertThat(storedIcon).hasSameContentAs(expectedIcon);
    }
}
Also used : Connector(io.syndesis.common.model.connection.Connector) ByteArrayInputStream(java.io.ByteArrayInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) Icon(io.syndesis.common.model.icon.Icon) Test(org.junit.Test)

Aggregations

Connector (io.syndesis.common.model.connection.Connector)6 Icon (io.syndesis.common.model.icon.Icon)6 BufferedInputStream (java.io.BufferedInputStream)4 IOException (java.io.IOException)4 InputStream (java.io.InputStream)4 Consumes (javax.ws.rs.Consumes)4 MediaType (javax.ws.rs.core.MediaType)4 ApiOperation (io.swagger.annotations.ApiOperation)3 ApiResponses (io.swagger.annotations.ApiResponses)3 POST (javax.ws.rs.POST)3 Produces (javax.ws.rs.Produces)3 ConnectorSettings (io.syndesis.common.model.connection.ConnectorSettings)2 ByteArrayInputStream (java.io.ByteArrayInputStream)2 Path (javax.ws.rs.Path)2 InputPart (org.jboss.resteasy.plugins.providers.multipart.InputPart)2 Test (org.junit.Test)2 Api (io.swagger.annotations.Api)1 ApiResponse (io.swagger.annotations.ApiResponse)1 Dependency (io.syndesis.common.model.Dependency)1 SyndesisServerException (io.syndesis.common.util.SyndesisServerException)1