Package com.streamreduce.core.model

Examples of com.streamreduce.core.model.Connection$Builder


    public void testUpdateConnection_failsValidationIfS3OutboundBucketExists() throws Exception {
        createPreExistingBucket();

        awsConnection.setAccount(testAccount);
        awsConnection.setUser(testUser);
        Connection createdConnection = connectionService.createConnection(awsConnection);

        //AWS creds for jason@nodeable.com, but Dave gets billed so feel free to use these for fun and profit
        String anotherAccessKey = "AKIAJYE3KRM4KGQ43OKQ";
        String anotherSecretKey = "LplQfj37z4R0Uj00gErN0qLTr0ek8FHFrm30CUba";
        createdConnection.addOutboundConfiguration(new OutboundConfiguration.Builder()
                .protocol("s3")
                .dataTypes(OutboundDataType.PROCESSED)
                .namespace(bucketName)
                .credentials(new ConnectionCredentials(anotherAccessKey, anotherSecretKey))
                .build());
View Full Code Here


    @Autowired
    ConnectionProviderFactory connectionProviderFactory;

    @Test
    public void testJiraConnectionCRUD() throws Exception {
        Connection tmpConnection = new Connection.Builder()
                .alias("Nodeable Jira")
                .description("Nodeable's Jira instance.")
                .credentials(new ConnectionCredentials(jiraProperties.getString("nodeable.jira.username"),
                        jiraProperties.getString("nodeable.jira.password")))
                .provider(connectionProviderFactory.connectionProviderFromId(ProviderIdConstants.JIRA_PROVIDER_ID))
                .url(jiraProperties.getString("nodeable.jira.url"))
                .authType(AuthType.USERNAME_PASSWORD)
                .user(testUser)
                .build();

        Connection connection = connectionService.createConnection(tmpConnection);

        // Set lastActivity
        HashMap<String, String> metadata = new HashMap<>();
        metadata.put("last_activity_poll", Long.toString(System.currentTimeMillis()));
        connection.setMetadata(metadata);

        assertNotNull(connection.getId());

        /* Verify the projects returned look like what we expect.  (This is fragile and depends on us knowing
           the projects the Jira user we're testing with has access to.
         */
        validateJiraProjectHostingInventoryItems(connection);
        pollForProjectHostingActivity(connection);

        /* Test reading back the connection */
        connection = connectionService.getConnection(connection.getId());
        assertNotNull(connection);

        /* Test reading all Jira connections */
        assertEquals(1, connectionService.getConnections(ProjectHostingProvider.TYPE, testUser).size());

        /* Test updating a connection */
        connection.setCredentials(new ConnectionCredentials(jiraProperties.getString("nodeable.jira.username"),
                jiraProperties.getString("nodeable.jira.password")));
        connection.setDescription("Updated description.");
        connection = connectionService.updateConnection(connection);

        assertEquals("Updated description.", connectionService.getConnection(connection.getId()).getDescription());

        /* Test deleting a connection */
        connectionService.deleteConnection(connection);

        try {
            connectionService.getConnection(connection.getId());
            fail("Should not be able to find a Jira connection with a deleted id.");
        } catch (ConnectionNotFoundException e) {
            // Expected
        }
    }
View Full Code Here

                .protocol("s3")
                .namespace("com.streamreduce.bucket")
                .dataTypes(OutboundDataType.PROCESSED)
                .build();

        Connection feedConnection = new Connection.Builder()
                .alias("EC2 Test Connection Test")
                .description("Reports the status of Amazon Elastic Compute Cloud (N. California).")
                .visibility(SobaObject.Visibility.ACCOUNT)
                .provider(connectionProviderFactory.connectionProviderFromId(ProviderIdConstants.FEED_PROVIDER_ID))
                .user(testUser)
                .authType(AuthType.NONE)
                .url("status.aws.amazon.com/rss/ec2-us-west-1.rss?junkParam")
                .build();

        Connection createdFeedConnection = connectionService.createConnection(feedConnection);

        createdFeedConnection.setOutboundConfigurations(Sets.newHashSet(outboundConfiguration));
        connectionService.updateConnection(createdFeedConnection);

        Connection retrievedConnection = connectionService.getConnection(createdFeedConnection.getId());

        Assert.assertEquals(createdFeedConnection.getId(), retrievedConnection.getId());
        Assert.assertEquals(createdFeedConnection.getOutboundConfigurations(),
                retrievedConnection.getOutboundConfigurations());
    }
View Full Code Here

    /**
     * Test creating a FeedProvider within a Connection.
     */
    @Test
    public void testCreateConnectionForFeedProvider() {
        Connection feedConnection = new Connection.Builder()
                .alias("EC2 Test Connection")
                .description("Reports the status of Amazon Elastic Compute Cloud (N. California).")
                .visibility(SobaObject.Visibility.ACCOUNT)
                .provider(connectionProviderFactory.connectionProviderFromId(ProviderIdConstants.FEED_PROVIDER_ID))
                .user(testUser)
                .hashtag("US-CA")
                .authType(AuthType.NONE)
                .url("http://status.aws.amazon.com/rss/ec2-us-west-1.rss?junkParam")
                .authType(AuthType.NONE)
                .build();
        try {
            Connection createdConnection = connectionService.createConnection(feedConnection);
            Connection retrievedConnection = connectionService.getConnection(createdConnection.getId());
            assertEquals(createdConnection.getId(), retrievedConnection.getId());
        } catch (Exception e) {
            logger.error("creating a feedConnection should not fail", e);
            fail("creating a feedConnection should not fail");
        }
    }
View Full Code Here

    public void testCreateTwitterConnectionWithValidOAuthToken() throws Exception {
        ConnectionCredentials credentials = new ConnectionCredentials();

        credentials.setOauthToken(twitterProperties.getString("nodeable.integrations.twitter.oauth_token"));
        credentials.setOauthTokenSecret(twitterProperties.getString("nodeable.integrations.twitter.oauth_secret"));
        Connection twitterConnection = connectionService.createConnection(new Connection.Builder()
                .account(getTestAccount())
                .alias("Test Twiter Connection")
                .authType(AuthType.OAUTH)
                .credentials(credentials)
                .provider(connectionProviderFactory.connectionProviderFromId(ProviderIdConstants.TWITTER_PROVIDER_ID))
                .user(getTestUser())
                .visibility(SobaObject.Visibility.ACCOUNT)
                .build());
        ConnectionCredentials twitterCredentials = twitterConnection.getCredentials();

        Assert.assertNotNull(twitterCredentials.getOauthToken());
        Assert.assertNotNull(twitterCredentials.getOauthTokenSecret());
        Assert.assertEquals("Nodeable", twitterCredentials.getIdentity());
    }
View Full Code Here

    @Test
    public void testCreateConnectionForFeedDoesNotTryToInsertHttp() throws Exception {
        //Tests that ConnectionService.createConnection will attempt to insert an "http://" protocol in front of a URL
        //in the event that a URL does not specify a protocol

        Connection feedConnection = new Connection.Builder()
                .alias("EC2 Test Connection")
                .description("Reports the status of Amazon Elastic Compute Cloud (N. California).")
                .visibility(SobaObject.Visibility.ACCOUNT)
                .provider(connectionProviderFactory.connectionProviderFromId(ProviderIdConstants.FEED_PROVIDER_ID))
                .user(testUser)
                .authType(AuthType.NONE)
                .url("status.aws.amazon.com/rss/ec2-us-west-1.rss?junkParam")
                .build();

        Connection createdConnection = connectionService.createConnection(feedConnection);
        assertEquals("http://status.aws.amazon.com/rss/ec2-us-west-1.rss?junkParam", createdConnection.getUrl());
    }
View Full Code Here

     * Test creating a FeedProvider within a Connection.
     */
    @Test(expected = RuntimeException.class)
    public void testCreateConnectionForFeedProviderWithValidButNotRSSUrl() throws Exception {
        //Exercises behavior when we try to create a feed connection from a url that does not return an RSS/Atom payload.
        Connection feedConnection = new Connection.Builder()
                .alias("EC2 Test Connection")
                .description("Reports the status of Amazon Elastic Compute Cloud (N. California).")
                .visibility(SobaObject.Visibility.ACCOUNT)
                .provider(connectionProviderFactory.connectionProviderFromId(ProviderIdConstants.FEED_PROVIDER_ID))
                .user(testUser)
View Full Code Here

    @Test
    public void testCreateConnectionForFeedTriesToInsertHttp() throws Exception {
        //Tests that ConnectionService.createConnection will attempt to insert an "http://" protocol in front of a URL
        //in the event that a URL does not specify a protocol

        Connection feedConnection = new Connection.Builder()
                .alias("EC2 Test Connection")
                .description("Reports the status of Amazon Elastic Compute Cloud (N. California).")
                .visibility(SobaObject.Visibility.ACCOUNT)
                .provider(connectionProviderFactory.connectionProviderFromId(ProviderIdConstants.FEED_PROVIDER_ID))
                .user(testUser)
                .authType(AuthType.NONE)
                .url("status.aws.amazon.com/rss/ec2-us-west-1.rss?junkParam")
                .build();

        Connection createdConnection = connectionService.createConnection(feedConnection);
        assertEquals("http://status.aws.amazon.com/rss/ec2-us-west-1.rss?junkParam", createdConnection.getUrl());
    }
View Full Code Here

    private Account testAccount;

    @Before
    public void setUp() {
        Connection c = TestUtils.createTestFeedConnection();
        c.setExternalId("ABC-DEF-123456789");
        testAccount = c.getAccount();
        accountDAO.save(testAccount);
        userDAO.save(c.getUser());
        connectionDAO.save(c);
    }
View Full Code Here

                .protocol("s3")
                .namespace("my.bucket.name.here")
                .dataTypes(OutboundDataType.PROCESSED)
                .build();

        Connection testConnection = new Connection.Builder()
                .alias("EC2 Test Connection")
                .description("Reports the status of Amazon Elastic Compute Cloud (N. California).")
                .visibility(SobaObject.Visibility.ACCOUNT)
                .provider(connectionProviderFactory.connectionProviderFromId(ProviderIdConstants.CUSTOM_PROVIDER_ID))
                .user(testUser)
                .authType(AuthType.NONE)
                .outboundConfigurations(outboundConfiguration)
                .build();

        ObjectId objectId = connectionService.createConnection(testConnection).getId();

        Connection loadedFeedConnection = connectionService.getConnection(objectId);
        for (OutboundConfiguration loadedOutboundConfiguration : loadedFeedConnection.getOutboundConfigurations()) {
            Assert.assertEquals(loadedFeedConnection, loadedOutboundConfiguration.getOriginatingConnection());
        }
    }
View Full Code Here

TOP

Related Classes of com.streamreduce.core.model.Connection$Builder

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.