builder.addAllActions(actions); builder.putConfiguredProperty("specification", SwaggerHelper.serialize(swagger));
protected final Connector basicConnector(final ConnectorTemplate connectorTemplate, final ConnectorSettings connectorSettings) { final Swagger swagger = parseSpecification(connectorSettings, false).getModel(); // could be either JSON of the Swagger specification or a URL to one final String specification = requiredSpecification(connectorSettings); if (specification.startsWith("http")) { swagger.vendorExtension(URL_EXTENSION, URI.create(specification)); } final Connector baseConnector = baseConnectorFrom(connectorTemplate, connectorSettings); final Connector.Builder builder = new Connector.Builder().createFrom(baseConnector); final Map<String, String> alreadyConfiguredProperties = builder.build().getConfiguredProperties(); connectorTemplate.getConnectorProperties().forEach((propertyName, template) -> { final Optional<ConfigurationProperty> maybeProperty = PropertyGenerators.createProperty(propertyName, swagger, template); maybeProperty.ifPresent(property -> { builder.putProperty(propertyName, property); if (!alreadyConfiguredProperties.containsKey(propertyName)) { final String defaultValue = property.getDefaultValue(); if (defaultValue != null) { builder.putConfiguredProperty(propertyName, defaultValue); } } }); }); return builder.build(); }
protected final Connector basicConnector(final ConnectorTemplate connectorTemplate, final ConnectorSettings connectorSettings) { final Swagger swagger = parseSpecification(connectorSettings, false).getModel(); // could be either JSON of the Swagger specification or a URL to one final String specification = requiredSpecification(connectorSettings); if (specification.startsWith("http")) { swagger.vendorExtension(URL_EXTENSION, URI.create(specification)); } final Connector baseConnector = baseConnectorFrom(connectorTemplate, connectorSettings); final Connector.Builder builder = new Connector.Builder().createFrom(baseConnector); final Map<String, String> alreadyConfiguredProperties = builder.build().getConfiguredProperties(); connectorTemplate.getConnectorProperties().forEach((propertyName, template) -> { final Optional<ConfigurationProperty> maybeProperty = PropertyGenerators.createProperty(propertyName, swagger, template); maybeProperty.ifPresent(property -> { builder.putProperty(propertyName, property); if (!alreadyConfiguredProperties.containsKey(propertyName)) { final String defaultValue = property.getDefaultValue(); if (defaultValue != null) { builder.putConfiguredProperty(propertyName, defaultValue); } } }); }); return builder.build(); }
.putConfiguredProperty("prop1", "value1")//
builder.addAllActions(actions); builder.putConfiguredProperty("specification", SwaggerHelper.serialize(swagger));
.putConfiguredProperty("prop1", "value1")//
@Test public void shouldCreateBaseConnectorsWithGivenNameAndDescription() { final ConnectorSettings settings = new ConnectorSettings.Builder().name("given-name").description("given-description") .putConfiguredProperty("property2", "value2").build(); final Connector connector = generator.baseConnectorFrom(template, settings); assertThat(connector).isEqualToIgnoringGivenFields(// new Connector.Builder()// .name("given-name")// .description("given-description")// .connectorGroup(template.getConnectorGroup())// .connectorGroupId("template-group")// .properties(template.getConnectorProperties())// .putConfiguredProperty("property2", "value2").build(), "id", "icon"); assertThat(connector.getIcon()).isEqualTo("data:image/svg+xml,dummy"); } }
@Test public void shouldCreateBaseConnectors() { final ConnectorSettings settings = new ConnectorSettings.Builder().putConfiguredProperty("property2", "value2").build(); final Connector connector = generator.baseConnectorFrom(template, settings); assertThat(connector).isEqualToIgnoringGivenFields(// new Connector.Builder()// .name("test-name")// .description("test-description")// .connectorGroup(template.getConnectorGroup())// .connectorGroupId("template-group")// .properties(template.getConnectorProperties())// .putConfiguredProperty("property2", "value2")// .build(), "id", "icon"); assertThat(connector.getIcon()).isEqualTo("data:image/svg+xml,dummy"); }
@Override public Connector generate(final ConnectorTemplate connectorTemplate, final ConnectorSettings connectorSettings) { return new Connector.Builder().createFrom(baseConnectorFrom(connectorTemplate, connectorSettings)) .putAllProperties(connectorProperties).putConfiguredProperty("prop1", "value1").addAction(action).build(); }
@Override public Connector generate(final ConnectorTemplate connectorTemplate, final ConnectorSettings connectorSettings) { return new Connector.Builder().createFrom(baseConnectorFrom(connectorTemplate, connectorSettings)) .putAllProperties(connectorProperties).putConfiguredProperty("prop1", "value1").addAction(action).build(); }