Search in sources :

Example 66 with Connection

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

the class SetupITCase method updateOauthApp.

@Test
public void updateOauthApp() {
    // Validate initial state assumptions.
    getOauthApps();
    OAuthAppHandler.OAuthApp twitter = new OAuthAppHandler.OAuthApp();
    twitter.clientId = "test-id";
    twitter.clientSecret = "test-secret";
    http(HttpMethod.PUT, "/api/v1/setup/oauth-apps/twitter", twitter, null, tokenRule.validToken(), HttpStatus.NO_CONTENT);
    ResponseEntity<OAuthAppHandler.OAuthApp[]> result = get("/api/v1/setup/oauth-apps", OAuthAppHandler.OAuthApp[].class);
    List<OAuthAppHandler.OAuthApp> apps = Arrays.asList(result.getBody());
    assertThat(apps.size()).isEqualTo(2);
    twitter = apps.stream().filter(x -> "twitter".equals(x.id)).findFirst().get();
    assertThat(twitter.id).isEqualTo("twitter");
    assertThat(twitter.name).isEqualTo("Twitter");
    assertThat(twitter.icon).isEqualTo("fa-twitter");
    assertThat(twitter.clientId).isEqualTo("test-id");
    assertThat(twitter.clientSecret).isEqualTo("test-secret");
    // Now that we have configured the app, we should be able to create the
    // connection factory.
    // The connection factory is setup async so we might need to wait a little bit
    // for it to register.
    given().ignoreExceptions().await().atMost(10, SECONDS).pollInterval(1, SECONDS).until(() -> {
        final CredentialProvider twitterCredentialProvider = locator.providerWithId("twitter");
        // preparing is something we could not do with a `null` ConnectionFactory
        assertThat(twitterCredentialProvider).isNotNull().isInstanceOfSatisfying(OAuth1CredentialProvider.class, p -> {
            final Connection connection = new Connection.Builder().build();
            final CredentialFlowState flowState = new OAuth1CredentialFlowState.Builder().accessToken(new OAuthToken("value", "secret")).connectorId("connectorId").build();
            final Connection appliedTo = p.applyTo(connection, flowState);
            // test that the updated values are used
            assertThat(appliedTo.getConfiguredProperties()).contains(entry("consumerKey", "test-id"), entry("consumerSecret", "test-secret"));
        });
        return true;
    });
}
Also used : Arrays(java.util.Arrays) CredentialFlowState(io.syndesis.server.credential.CredentialFlowState) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) HttpMethod(org.springframework.http.HttpMethod) Autowired(org.springframework.beans.factory.annotation.Autowired) Test(org.junit.Test) OAuthToken(org.springframework.social.oauth1.OAuthToken) Assertions.entry(org.assertj.core.api.Assertions.entry) Awaitility.given(org.awaitility.Awaitility.given) OAuth1CredentialFlowState(io.syndesis.server.credential.OAuth1CredentialFlowState) HttpStatus(org.springframework.http.HttpStatus) List(java.util.List) Connection(io.syndesis.common.model.connection.Connection) CredentialProvider(io.syndesis.server.credential.CredentialProvider) CredentialProviderLocator(io.syndesis.server.credential.CredentialProviderLocator) ResponseEntity(org.springframework.http.ResponseEntity) OAuth1CredentialProvider(io.syndesis.server.credential.OAuth1CredentialProvider) OAuthAppHandler(io.syndesis.server.endpoint.v1.handler.setup.OAuthAppHandler) SECONDS(java.util.concurrent.TimeUnit.SECONDS) CredentialFlowState(io.syndesis.server.credential.CredentialFlowState) OAuth1CredentialFlowState(io.syndesis.server.credential.OAuth1CredentialFlowState) Connection(io.syndesis.common.model.connection.Connection) OAuth1CredentialFlowState(io.syndesis.server.credential.OAuth1CredentialFlowState) OAuthAppHandler(io.syndesis.server.endpoint.v1.handler.setup.OAuthAppHandler) OAuthToken(org.springframework.social.oauth1.OAuthToken) CredentialProvider(io.syndesis.server.credential.CredentialProvider) OAuth1CredentialProvider(io.syndesis.server.credential.OAuth1CredentialProvider) Test(org.junit.Test)

Example 67 with Connection

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

the class TagFinderTest method findTags.

@Test
public void findTags() {
    Integration integration = new Integration.Builder().addTag("tag1").addTag("tag2").build();
    Connection connection = new Connection.Builder().addTag("tag2").addTag("tag3").build();
    ListResult<String> allTags = new TagFinder().add(ListResult.of(integration)).add(ListResult.of(connection)).getResult();
    Assert.assertEquals(3, allTags.getTotalCount());
    Assert.assertTrue(allTags.getItems().contains("tag1"));
    Assert.assertTrue(allTags.getItems().contains("tag2"));
    Assert.assertTrue(allTags.getItems().contains("tag3"));
}
Also used : Integration(io.syndesis.common.model.integration.Integration) Connection(io.syndesis.common.model.connection.Connection) Test(org.junit.Test)

Example 68 with Connection

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

the class EquivalencerTest method shouldHaveNonEquivalentObjectsDescription.

@Test
public void shouldHaveNonEquivalentObjectsDescription() {
    ConnectorAction action1 = connectorAction("Invoke SQL");
    Connector connector1 = connectorWithDescription(action1, "My accurate description");
    Connection conn1 = connection(connector1);
    Integration integration1 = new Integration.Builder().name("myIntegration").addConnection(conn1).build();
    Connector connector2 = connectorWithDescription(action1, "My new description");
    Connection conn2 = connection(connector2);
    Integration integration2 = new Integration.Builder().name("myIntegration").addConnection(conn2).build();
    Equivalencer equiv = new Equivalencer();
    boolean equivalent = equiv.equivalent(integration1, integration2);
    assertFalse(equivalent);
    String message = equiv.failureMessage();
    assertEquals(expectedMessage("description", "My accurate description", "My new description", ntPair("myIntegration", "Integration"), ntPair("PostgresDB", "Connection"), ntPair("sql", "Connector")), message);
}
Also used : Connector(io.syndesis.common.model.connection.Connector) Integration(io.syndesis.common.model.integration.Integration) Connection(io.syndesis.common.model.connection.Connection) ConnectorAction(io.syndesis.common.model.action.ConnectorAction) Test(org.junit.Test)

Example 69 with Connection

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

the class EquivalencerTest method shouldHaveNonEquivalentObjects3.

@Test
public void shouldHaveNonEquivalentObjects3() {
    ConnectorAction action1 = connectorAction("Invoke SQL");
    Connector connector1 = connector(action1);
    Connection conn1 = connection(connector1);
    Integration integration1 = new Integration.Builder().name("myIntegration").addConnection(conn1).addConnection(conn1).build();
    ConnectorAction action2 = connectorAction("Invoke PL-SQL");
    Connector connector2 = connector(action2);
    Connection conn2 = connection(connector2);
    Integration integration2 = new Integration.Builder().name("myIntegration").addConnection(conn1).addConnection(conn2).build();
    Equivalencer equiv = new Equivalencer();
    boolean equivalent = equiv.equivalent(integration1, integration2);
    assertFalse(equivalent);
    String message = equiv.failureMessage();
    assertEquals(expectedMessage("name", "Invoke SQL", "Invoke PL-SQL", ntPair("myIntegration", "Integration"), ntPair("PostgresDB", "Connection"), ntPair("sql", "Connector"), ntPair("Invoke SQL", "ConnectorAction")), message);
}
Also used : Connector(io.syndesis.common.model.connection.Connector) Integration(io.syndesis.common.model.integration.Integration) Connection(io.syndesis.common.model.connection.Connection) ConnectorAction(io.syndesis.common.model.action.ConnectorAction) Test(org.junit.Test)

Example 70 with Connection

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

the class ProjectGeneratorTest method testGenerateApplicationPropertiesOldStyle.

@Test
public void testGenerateApplicationPropertiesOldStyle() throws IOException {
    // ******************
    // OLD STYLE
    // ******************
    final ConnectorAction oldAction = new ConnectorAction.Builder().id(KeyGenerator.createKey()).descriptor(new ConnectorDescriptor.Builder().connectorId("old").build()).build();
    final Connector oldConnector = new Connector.Builder().id("old").addAction(oldAction).putProperty("username", new ConfigurationProperty.Builder().componentProperty(false).secret(true).build()).putProperty("password", new ConfigurationProperty.Builder().componentProperty(false).secret(true).build()).putProperty("token", new ConfigurationProperty.Builder().componentProperty(true).secret(true).build()).build();
    // ******************
    // Integration
    // ******************
    Step s1 = new Step.Builder().stepKind(StepKind.endpoint).connection(new Connection.Builder().id(KeyGenerator.createKey()).connector(oldConnector).build()).putConfiguredProperty("username", "my-username-1").putConfiguredProperty("password", "my-password-1").putConfiguredProperty("token", "my-token-1").action(oldAction).build();
    TestResourceManager resourceManager = new TestResourceManager();
    ProjectGeneratorConfiguration configuration = new ProjectGeneratorConfiguration();
    ProjectGenerator generator = new ProjectGenerator(configuration, resourceManager, TestConstants.MAVEN_PROPERTIES);
    Integration integration = new Integration.Builder().createFrom(resourceManager.newIntegration(s1)).putConfiguredProperty("integration", "property").build();
    assertThatExceptionOfType(UnsupportedOperationException.class).isThrownBy(() -> generator.generateApplicationProperties(integration)).withMessage("Old style of connectors from camel-connector are not supported anymore, please be sure that integration json satisfy connector.getComponentScheme().isPresent() || descriptor.getComponentScheme().isPresent()");
}
Also used : ConfigurationProperty(io.syndesis.common.model.connection.ConfigurationProperty) Connector(io.syndesis.common.model.connection.Connector) Integration(io.syndesis.common.model.integration.Integration) Connection(io.syndesis.common.model.connection.Connection) Step(io.syndesis.common.model.integration.Step) IntegrationProjectGenerator(io.syndesis.integration.api.IntegrationProjectGenerator) ConnectorAction(io.syndesis.common.model.action.ConnectorAction) Test(org.junit.Test)

Aggregations

Connection (io.syndesis.common.model.connection.Connection)111 Connector (io.syndesis.common.model.connection.Connector)65 Test (org.junit.Test)48 Step (io.syndesis.common.model.integration.Step)40 Integration (io.syndesis.common.model.integration.Integration)38 ConnectorAction (io.syndesis.common.model.action.ConnectorAction)26 ConnectorDescriptor (io.syndesis.common.model.action.ConnectorDescriptor)26 List (java.util.List)24 HashMap (java.util.HashMap)21 Action (io.syndesis.common.model.action.Action)18 ConfigurationProperty (io.syndesis.common.model.connection.ConfigurationProperty)18 ArrayList (java.util.ArrayList)17 Map (java.util.Map)16 IOException (java.io.IOException)14 InputStream (java.io.InputStream)14 IntegrationDeployment (io.syndesis.common.model.integration.IntegrationDeployment)13 StepDefinition (io.syndesis.qe.bdd.entities.StepDefinition)12 DataManager (io.syndesis.server.dao.manager.DataManager)11 Given (cucumber.api.java.en.Given)10 Flow (io.syndesis.common.model.integration.Flow)10