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