Search in sources :

Example 11 with ConnectorSettings

use of io.syndesis.common.model.connection.ConnectorSettings in project syndesis by syndesisio.

the class CustomSwaggerConnectorITCase method shouldCreateCustomConnectorInfoForUploadedSwagger.

@Test
public void shouldCreateCustomConnectorInfoForUploadedSwagger() throws IOException {
    final ConnectorSettings connectorSettings = new ConnectorSettings.Builder().connectorTemplateId(TEMPLATE_ID).build();
    final ResponseEntity<Connector> response = post("/api/v1/connectors/custom", multipartBodyForInfo(connectorSettings, getClass().getResourceAsStream("/io/syndesis/server/runtime/test-swagger.json")), Connector.class, tokenRule.validToken(), HttpStatus.OK, multipartHeaders());
    final Connector got = response.getBody();
    assertThat(got).isNotNull();
}
Also used : Connector(io.syndesis.common.model.connection.Connector) ConnectorSettings(io.syndesis.common.model.connection.ConnectorSettings) Test(org.junit.Test)

Example 12 with ConnectorSettings

use of io.syndesis.common.model.connection.ConnectorSettings in project syndesis by syndesisio.

the class CustomSwaggerConnectorITCase method shouldOfferCustomConnectorInfoForUploadedSwagger.

@Test
public void shouldOfferCustomConnectorInfoForUploadedSwagger() throws IOException {
    final ConnectorSettings connectorSettings = new ConnectorSettings.Builder().connectorTemplateId(TEMPLATE_ID).build();
    final ResponseEntity<ConnectorSummary> response = post("/api/v1/connectors/custom/info", multipartBodyForInfo(connectorSettings, getClass().getResourceAsStream("/io/syndesis/server/runtime/test-swagger.json")), ConnectorSummary.class, tokenRule.validToken(), HttpStatus.OK, multipartHeaders());
    final ConnectorSummary expected = // \
    new ConnectorSummary.Builder().name(// 
    "Todo App API").description(// 
    "unspecified").actionsSummary(// 
    TestConfiguration.ACTIONS_SUMMARY).addWarning(new Violation.Builder().error("missing-response-schema").message("Operation DELETE /api/{id} does not provide a response schema for code 204").build()).build();
    final ConnectorSummary got = response.getBody();
    assertThat(got).isEqualToIgnoringGivenFields(expected, "icon");
    assertThat(got.getIcon()).startsWith("data:image");
}
Also used : ConnectorSummary(io.syndesis.common.model.connection.ConnectorSummary) Violation(io.syndesis.common.model.Violation) ConnectorSettings(io.syndesis.common.model.connection.ConnectorSettings) Test(org.junit.Test)

Example 13 with ConnectorSettings

use of io.syndesis.common.model.connection.ConnectorSettings in project syndesis by syndesisio.

the class CustomConnectorITCase method shouldCreateNewCustomConnectors.

@Test
public void shouldCreateNewCustomConnectors() {
    final ConnectorSettings connectorSettings = new ConnectorSettings.Builder().connectorTemplateId(TEMPLATE_ID).build();
    final ResponseEntity<Connector> response = post("/api/v1/connectors/custom", connectorSettings, Connector.class);
    final Connector created = response.getBody();
    assertThat(created).isNotNull();
    assertThat(created.getDescription()).isEqualTo("test-description");
    assertThat(dataManager.fetch(Connector.class, response.getBody().getId().get())).isNotNull();
}
Also used : Connector(io.syndesis.common.model.connection.Connector) ConnectorSettings(io.syndesis.common.model.connection.ConnectorSettings) Test(org.junit.Test)

Example 14 with ConnectorSettings

use of io.syndesis.common.model.connection.ConnectorSettings in project syndesis by syndesisio.

the class BaseSwaggerConnectorGeneratorTest method shouldIncorporateGivenConfiguredProperties.

@Test
public void shouldIncorporateGivenConfiguredProperties() throws IOException {
    final String specification = resource("/swagger/reverb.swagger.yaml");
    final ConnectorSettings connectorSettings = // 
    new ConnectorSettings.Builder().name(// 
    "Reverb API").description(// 
    "Invokes Reverb API").icon(// 
    "fa-music").putConfiguredProperty("specification", // 
    specification).putConfiguredProperty("tokenEndpoint", "http://some.token.url").build();
    final Connector connector = generator.generate(SWAGGER_TEMPLATE, connectorSettings);
    assertThat(connector.getConfiguredProperties()).containsEntry("tokenEndpoint", "http://some.token.url");
}
Also used : Connector(io.syndesis.common.model.connection.Connector) ConnectorSettings(io.syndesis.common.model.connection.ConnectorSettings) Test(org.junit.Test)

Example 15 with ConnectorSettings

use of io.syndesis.common.model.connection.ConnectorSettings in project syndesis by syndesisio.

the class BaseSwaggerGeneratorExampleTest method shouldGenerateAsExpected.

@SuppressWarnings("PMD.JUnitTestContainsTooManyAsserts")
public void shouldGenerateAsExpected() throws IOException {
    final ConnectorSettings connectorSettings = // 
    new ConnectorSettings.Builder().putConfiguredProperty("specification", // 
    specification).build();
    final Connector generated = generator().generate(SWAGGER_TEMPLATE, connectorSettings);
    final Map<String, String> generatedConfiguredProperties = generated.getConfiguredProperties();
    final String generatedSpecification = generatedConfiguredProperties.get("specification");
    final Map<String, String> expectedConfiguredProperties = expected.getConfiguredProperties();
    final String expectedSpecification = expectedConfiguredProperties.get("specification");
    assertThat(reformatJson(generatedSpecification)).isEqualTo(reformatJson(expectedSpecification));
    assertThat(without(generatedConfiguredProperties, "specification")).containsAllEntriesOf(without(expectedConfiguredProperties, "specification"));
    assertThat(generated.getProperties().keySet()).as("Expecting the same properties to be generated").containsOnlyElementsOf(expected.getProperties().keySet());
    assertThat(generated.getProperties()).containsAllEntriesOf(expected.getProperties());
    assertThat(generated).isEqualToIgnoringGivenFields(expected, "id", "icon", "properties", "configuredProperties", "actions");
    assertThat(generated.getIcon()).startsWith("data:image");
    assertThat(generated.getActions()).hasSameSizeAs(expected.getActions());
    for (final ConnectorAction expectedAction : expected.getActions()) {
        final String actionId = expectedAction.getId().get().replace("_id_", generated.getId().get());
        final Optional<ConnectorAction> maybeGeneratedAction = generated.findActionById(actionId);
        assertThat(maybeGeneratedAction).as("No action with id: " + actionId + " was generated").isPresent();
        final ConnectorAction generatedAction = maybeGeneratedAction.get();
        assertThat(generatedAction).as("Difference found for action: " + actionId).isEqualToIgnoringGivenFields(expectedAction, "id", "descriptor");
        assertThat(generatedAction.getDescriptor().getPropertyDefinitionSteps()).as("Generated and expected action definition property definition steps for action with id: " + actionId + " differs").isEqualTo(expectedAction.getDescriptor().getPropertyDefinitionSteps());
        if (expectedAction.getDescriptor().getInputDataShape().isPresent()) {
            final DataShape generatedInputDataShape = generatedAction.getDescriptor().getInputDataShape().get();
            final DataShape expectedInputDataShape = expectedAction.getDescriptor().getInputDataShape().get();
            assertThat(generatedInputDataShape).as("Generated and expected input data shape for action with id: " + actionId + " differs").isEqualToIgnoringGivenFields(expectedInputDataShape, "specification");
            if (generatedInputDataShape.getKind() == DataShapeKinds.JSON_SCHEMA) {
                assertThat(reformatJson(generatedInputDataShape.getSpecification())).as("Input data shape specification for action with id: " + actionId + " differ").isEqualTo(reformatJson(expectedInputDataShape.getSpecification()));
            } else {
                assertThat(c14Xml(generatedInputDataShape.getSpecification())).as("Input data shape specification for action with id: " + actionId + " differ").isEqualTo(c14Xml(expectedInputDataShape.getSpecification()));
            }
        }
        if (expectedAction.getDescriptor().getOutputDataShape().isPresent()) {
            final DataShape generatedOutputDataShape = generatedAction.getDescriptor().getOutputDataShape().get();
            final DataShape expectedOutputDataShape = expectedAction.getDescriptor().getOutputDataShape().get();
            assertThat(generatedOutputDataShape).as("Generated and expected output data shape for action with id: " + actionId + " differs").isEqualToIgnoringGivenFields(expectedOutputDataShape, "specification");
            if (generatedOutputDataShape.getKind() == DataShapeKinds.JSON_SCHEMA) {
                assertThat(reformatJson(generatedOutputDataShape.getSpecification())).as("Output data shape specification for action with id: " + actionId + " differ").isEqualTo(reformatJson(expectedOutputDataShape.getSpecification()));
            } else {
                assertThat(c14Xml(generatedOutputDataShape.getSpecification())).as("Output data shape specification for action with id: " + actionId + " differ").isEqualTo(c14Xml(expectedOutputDataShape.getSpecification()));
            }
        }
    }
}
Also used : Connector(io.syndesis.common.model.connection.Connector) DocumentBuilder(javax.xml.parsers.DocumentBuilder) ConnectorAction(io.syndesis.common.model.action.ConnectorAction) ConnectorSettings(io.syndesis.common.model.connection.ConnectorSettings) DataShape(io.syndesis.common.model.DataShape)

Aggregations

ConnectorSettings (io.syndesis.common.model.connection.ConnectorSettings)16 Test (org.junit.Test)12 Connector (io.syndesis.common.model.connection.Connector)10 ConnectorSummary (io.syndesis.common.model.connection.ConnectorSummary)7 ConnectorAction (io.syndesis.common.model.action.ConnectorAction)3 ConfigurationProperty (io.syndesis.common.model.connection.ConfigurationProperty)3 ConnectorTemplate (io.syndesis.common.model.connection.ConnectorTemplate)3 ConnectorGenerator (io.syndesis.server.connector.generator.ConnectorGenerator)3 ApiOperation (io.swagger.annotations.ApiOperation)2 DataShape (io.syndesis.common.model.DataShape)2 ActionsSummary (io.syndesis.common.model.action.ActionsSummary)2 IOException (java.io.IOException)2 ApiResponses (io.swagger.annotations.ApiResponses)1 HttpMethod (io.swagger.models.HttpMethod)1 Info (io.swagger.models.Info)1 Operation (io.swagger.models.Operation)1 Path (io.swagger.models.Path)1 Swagger (io.swagger.models.Swagger)1 AbstractSerializableParameter (io.swagger.models.parameters.AbstractSerializableParameter)1 BodyParameter (io.swagger.models.parameters.BodyParameter)1