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