Search in sources :

Example 1 with ConnectorGroup

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

the class ReadApiClientDataTest method deserializeModelDataTest.

@Test
public void deserializeModelDataTest() throws IOException {
    Integration integrationIn = new Integration.Builder().tags(new TreeSet<>(Arrays.asList("tag1", "tag2"))).createdAt(System.currentTimeMillis()).build();
    String integrationJson = Json.writer().writeValueAsString(integrationIn);
    Integration integrationOut = Json.reader().forType(Integration.class).readValue(integrationJson);
    // serialize
    ConnectorGroup cg = new ConnectorGroup.Builder().id("label").name("label").build();
    ModelData<ConnectorGroup> mdIn = new ModelData<>(Kind.ConnectorGroup, cg);
    Assert.assertEquals("{\"id\":\"label\",\"name\":\"label\"}", mdIn.getDataAsJson());
    // deserialize
    String json = Json.writer().writeValueAsString(mdIn);
    ModelData<?> mdOut = Json.reader().forType(ModelData.class).readValue(json);
    Assert.assertEquals("{\"id\":\"label\",\"name\":\"label\"}", mdOut.getDataAsJson());
}
Also used : ModelData(io.syndesis.common.model.ModelData) Integration(io.syndesis.common.model.integration.Integration) ConnectorGroup(io.syndesis.common.model.connection.ConnectorGroup) Test(org.junit.Test)

Example 2 with ConnectorGroup

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

the class CustomConnectorHandlerTest method shouldCreateNewConnectorsBasedOnConnectorTemplates.

@Test
public void shouldCreateNewConnectorsBasedOnConnectorTemplates() {
    final Map<String, ConfigurationProperty> properties = new HashMap<>();
    properties.put("prop1", new ConfigurationProperty.Builder().build());
    final Map<String, ConfigurationProperty> connectorProperties = new HashMap<>();
    connectorProperties.put("prop2", new ConfigurationProperty.Builder().build());
    connectorProperties.put("prop3", new ConfigurationProperty.Builder().build());
    final ConnectorGroup group = new ConnectorGroup.Builder().name("connector template group").build();
    final ConnectorTemplate connectorTemplate = // 
    new ConnectorTemplate.Builder().id(// 
    "connector-template-id").name(// 
    "connector template").properties(properties).connectorProperties(// 
    connectorProperties).connectorGroup(// 
    group).build();
    final ConnectorAction action = new ConnectorAction.Builder().name("action").build();
    when(dataManager.fetch(ConnectorTemplate.class, "connector-template-id")).thenReturn(connectorTemplate);
    when(dataManager.create(any(Connector.class))).thenAnswer(invocation -> invocation.getArgumentAt(0, Connector.class));
    when(applicationContext.getBean("connector-template-id", ConnectorGenerator.class)).thenReturn(new ConnectorGenerator() {

        @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 ConnectorSummary info(final ConnectorTemplate connectorTemplate, final ConnectorSettings connectorSettings) {
            return null;
        }
    });
    final Connector created = // 
    new CustomConnectorHandler(dataManager, applicationContext, iconDao).create(// 
    new ConnectorSettings.Builder().connectorTemplateId(// 
    "connector-template-id").name(// 
    "new connector").description(// 
    "new connector description").icon(// 
    "new connector icon").putConfiguredProperty("prop1", // 
    "value1").putConfiguredProperty("unknown-prop", // 
    "unknown-value").build());
    final Connector expected = // 
    new Connector.Builder().id(// 
    created.getId()).name(// 
    "new connector").description(// 
    "new connector description").icon(// 
    "new connector icon").connectorGroup(// 
    group).properties(// 
    connectorProperties).putConfiguredProperty("prop1", // 
    "value1").addAction(// 
    action).build();
    assertThat(created).isEqualTo(expected);
}
Also used : ConfigurationProperty(io.syndesis.common.model.connection.ConfigurationProperty) Connector(io.syndesis.common.model.connection.Connector) HashMap(java.util.HashMap) ConnectorGenerator(io.syndesis.server.connector.generator.ConnectorGenerator) ConnectorSettings(io.syndesis.common.model.connection.ConnectorSettings) ConnectorSummary(io.syndesis.common.model.connection.ConnectorSummary) ConnectorTemplate(io.syndesis.common.model.connection.ConnectorTemplate) ConnectorGroup(io.syndesis.common.model.connection.ConnectorGroup) ConnectorAction(io.syndesis.common.model.action.ConnectorAction) Test(org.junit.Test)

Aggregations

ConnectorGroup (io.syndesis.common.model.connection.ConnectorGroup)2 Test (org.junit.Test)2 ModelData (io.syndesis.common.model.ModelData)1 ConnectorAction (io.syndesis.common.model.action.ConnectorAction)1 ConfigurationProperty (io.syndesis.common.model.connection.ConfigurationProperty)1 Connector (io.syndesis.common.model.connection.Connector)1 ConnectorSettings (io.syndesis.common.model.connection.ConnectorSettings)1 ConnectorSummary (io.syndesis.common.model.connection.ConnectorSummary)1 ConnectorTemplate (io.syndesis.common.model.connection.ConnectorTemplate)1 Integration (io.syndesis.common.model.integration.Integration)1 ConnectorGenerator (io.syndesis.server.connector.generator.ConnectorGenerator)1 HashMap (java.util.HashMap)1