Package com.streamreduce.core.model.messages

Examples of com.streamreduce.core.model.messages.SobaMessage


        Assert.assertFalse("Encountered unexpanded template token in email content: " + emailContent, emailContent.contains("${"));
    }

    @Test
    public void testSendUserMessageAddedEmail() throws Exception {
        SobaMessage sobaMessage = new SobaMessage.Builder()
                .sender(testUser)
                .providerId("test")
                .visibility(SobaObject.Visibility.ACCOUNT)
                .transformedMessage(LOREM_IPSUM)
                .type(MessageType.USER)
                .build();
        sobaMessage.setId(new ObjectId());

        when(mockUserService.allEnabledUsersForAccount(testAccount)).thenReturn(Lists.newArrayList(testUser));

        testSenderUser.setId(new ObjectId());
        emailService.sendUserMessageAddedEmail(testSenderUser, sobaMessage);
View Full Code Here


        Assert.assertFalse("Encountered unexpanded template token.", emailContent.contains("${"));
    }

    @Test
    public void testSendUserMessageAddedEmail_userConfigDisabled() throws Exception {
        SobaMessage sobaMessage = new SobaMessage.Builder()
                .sender(testUser)
                .providerId("test")
                .visibility(SobaObject.Visibility.ACCOUNT)
                .transformedMessage(LOREM_IPSUM)
                .type(MessageType.USER)
                .build();
        sobaMessage.setId(new ObjectId());

        testUser.getConfig().put(User.ConfigKeys.RECEIVES_NEW_MESSAGE_NOTIFICATIONS, false);

        when(mockUserService.allEnabledUsersForAccount(testAccount)).thenReturn(Lists.newArrayList(testUser));
View Full Code Here

    @Test
    public void testIncludesSenderConnectionId() {
        SobaObject sender = createValidSender();

        SobaMessage sobaMessage = new SobaMessage.Builder()
                .type(MessageType.INVENTORY_ITEM)
                .visibility(SobaObject.Visibility.ACCOUNT)
                .sender(sender)
                .build();
        SobaMessageResponseDTO responseDTO = SobaMessageResponseDTO.fromSobaMessage(sobaMessage);
View Full Code Here

    @Test
    public void testSendProcessedMessage() throws Exception {
        //Verify that we create a file on WebHDFS named processed/connId/messageId

        SobaMessage sobaMessage = new SobaMessage.Builder()
                .sender(createTestUser())
                .providerId("test")
                .visibility(SobaObject.Visibility.ACCOUNT)
                .transformedMessage("Foo")
                .type(MessageType.USER)
                .connection(testConnection)
                .build();
        sobaMessage.setId(new ObjectId());

        outboundClient.putProcessedMessage(sobaMessage);
        String expectedPath = "processed/" + sobaMessage.getConnectionId() + "/" + sobaMessage.getId();
        byte[] payload = webHDFSClient.readFile(expectedPath);
        assertTrue(payload.length > 0);

        String actualAsString = new String(payload);
        JSONObject actual = JSONObject.fromObject(actualAsString);
View Full Code Here

    @Test
    public void testSendInsightMessage() throws Exception {
        //Verify that we create a file on WebHDFS named insight/connId/messageId

        SobaMessage sobaMessage = new SobaMessage.Builder()
                .sender(createTestUser())
                .providerId("test")
                .visibility(SobaObject.Visibility.ACCOUNT)
                .transformedMessage("Foo")
                .type(MessageType.NODEBELLY)
                .connection(testConnection)
                .build();
        sobaMessage.setId(new ObjectId());

        outboundClient.putInsightMessage(sobaMessage);
        String expectedPath = "insight/" + sobaMessage.getConnectionId() + "/" + sobaMessage.getId();

        byte[] payload = webHDFSClient.readFile(expectedPath);
        assertTrue(payload.length > 0);

        String actualAsString = new String(payload);
View Full Code Here

        JSONObject imgPayload = TestUtils.createValidSampleIMGPayload();
        Connection testIMGConnection = TestUtils.createIMGConnectionWithSpecificOutboundDatatypes(OutboundDataType.PROCESSED);
        testIMGConnection.setAccount(testAccount);
        testIMGConnection.setUser(testUser);
        testIMGConnection = connectionService.createConnection(testIMGConnection);
        SobaMessage sobaMessage = new SobaMessage.Builder()
                .connection(testIMGConnection)
                .dateGenerated(System.currentTimeMillis())
                .hashtags(Sets.newHashSet("#foo"))
                .sender(testIMGConnection)
                .transformedMessage(imgPayload.getString("message"))
                .type(MessageType.GATEWAY)
                .visibility(SobaObject.Visibility.ACCOUNT)
                .build();
        sobaMessage.setId(new ObjectId());

        outboundStorageService.sendSobaMessage(sobaMessage, testIMGConnection);
        Thread.sleep(TimeUnit.SECONDS.toMillis(10));

        String expectedBucketName = "com.streamreduce." + testIMGConnection.getAccount().getId();
        String key = "processed/" + sobaMessage.getConnectionId() + "/" + sobaMessage.getId();

        ConnectionCredentials creds = new ArrayList<>(
                testIMGConnection.getOutboundConfigurations()).get(0).getCredentials();
        s3TestUtils = new S3TestUtils(creds);
View Full Code Here

        JSONObject imgPayload = TestUtils.createValidSampleIMGPayload();
        Connection testIMGConnection =
                TestUtils.createIMGConnectionWithSpecificOutboundDatatypes(
                        OutboundDataType.RAW, OutboundDataType.INSIGHT, OutboundDataType.EVENT);
        SobaMessage sobaMessage = new SobaMessage.Builder()
                .connection(testIMGConnection)
                .dateGenerated(System.currentTimeMillis())
                .hashtags(Sets.newHashSet("#foo"))
                .sender(testIMGConnection)
                .transformedMessage(imgPayload.getString("message"))
                .type(MessageType.GATEWAY)
                .visibility(SobaObject.Visibility.ACCOUNT)
                .build();
        sobaMessage.setId(new ObjectId());

        outboundStorageService.sendSobaMessage(sobaMessage, testIMGConnection);

        ConnectionCredentials creds = new ArrayList<>(
                testIMGConnection.getOutboundConfigurations()).get(0).getCredentials();
        s3TestUtils = new S3TestUtils(creds);

        String expectedBucketName = "com.streamreduce." + testIMGConnection.getAccount().getId();
        String prefix = "processed/" + sobaMessage.getConnectionId() + "/";
        List<Blob> payloads = s3TestUtils.getBlobsFromS3(expectedBucketName, prefix);

        Assert.assertEquals(0, payloads.size());
    }
View Full Code Here

        testIMGConnection.setUser(testUser);
        testIMGConnection.setAccount(testAccount);
        testIMGConnection.setId(null);
        connectionService.createConnection(testIMGConnection);

        SobaMessage sobaMessage = new SobaMessage.Builder()
                .connection(testIMGConnection)
                .dateGenerated(System.currentTimeMillis())
                .hashtags(Sets.newHashSet("#foo"))
                .sender(testIMGConnection)
                .transformedMessage(imgPayload.getString("message"))
                .type(MessageType.NODEBELLY) //This is a fakeout... no Nodebelly/Insight Message looks like this.
                .visibility(SobaObject.Visibility.ACCOUNT)
                .build();
        sobaMessage.setId(new ObjectId());

        outboundStorageService.sendSobaMessage(sobaMessage, testIMGConnection);
        Thread.sleep(TimeUnit.SECONDS.toMillis(10));     //give this some time to go through the queue

        ConnectionCredentials creds = new ArrayList<>(
                testIMGConnection.getOutboundConfigurations()).get(0).getCredentials();
        s3TestUtils = new S3TestUtils(creds);

        String expectedBucketName = "com.streamreduce." + testIMGConnection.getAccount().getId();
        String prefix = "insight/" + sobaMessage.getConnectionId() + "/";
        Blob payload = s3TestUtils.getFirstBlobFromS3ThatMatchesPrefix(expectedBucketName, prefix);

        //Test that what made it to S3 is the same thing we get when we turn the sobaMessage into a dto
        JSONObject actualJSONPayloadFromS3 = JSONObject.fromObject(IOUtils.toString(payload.getPayload().getInput()));
        StringWriter sw = new StringWriter();
View Full Code Here

        JSONObject imgPayload = TestUtils.createValidSampleIMGPayload();
        Connection testIMGConnection =
                TestUtils.createIMGConnectionWithSpecificOutboundDatatypes(
                        OutboundDataType.INSIGHT);
        SobaMessage sobaMessage = new SobaMessage.Builder()
                .connection(testIMGConnection)
                .dateGenerated(System.currentTimeMillis())
                .hashtags(Sets.newHashSet("#foo"))
                .sender(testIMGConnection)
                .transformedMessage(imgPayload.getString("message"))
                .type(MessageType.GATEWAY)
                .visibility(SobaObject.Visibility.ACCOUNT)
                .build();
        sobaMessage.setId(new ObjectId());

        outboundStorageService.sendSobaMessage(sobaMessage, testIMGConnection);

        ConnectionCredentials creds = new ArrayList<>(
                testIMGConnection.getOutboundConfigurations()).get(0).getCredentials();
        s3TestUtils = new S3TestUtils(creds);

        String expectedBucketName = "com.streamreduce." + testIMGConnection.getAccount().getId();
        String prefix = "insight/" + sobaMessage.getConnectionId() + "/";
        List<Blob> payloads = s3TestUtils.getBlobsFromS3(expectedBucketName, prefix);

        Assert.assertEquals(0, payloads.size());
    }
View Full Code Here

        testIMGConnection.setAccount(testAccount);
        testIMGConnection.setUser(testUser);
        testIMGConnection = connectionService.createConnection(testIMGConnection);


        SobaMessage sobaMessage = new SobaMessage.Builder()
                .connection(testIMGConnection)
                .dateGenerated(System.currentTimeMillis())
                .hashtags(Sets.newHashSet("#foo"))
                .sender(testIMGConnection)
                .transformedMessage(imgPayload.getString("message"))
                .type(MessageType.GATEWAY)
                .visibility(SobaObject.Visibility.ACCOUNT)
                .build();
        sobaMessage.setId(new ObjectId());

        outboundStorageService.sendSobaMessage(sobaMessage, testIMGConnection);
        Thread.sleep(TimeUnit.SECONDS.toMillis(10));

        String expectedBucketName = "com.streamreduce." + testIMGConnection.getAccount().getId();
        String key = "processed/" + sobaMessage.getConnectionId() + "/" + sobaMessage.getId();

        ConnectionCredentials credentials = new ArrayList<>(
                testIMGConnection.getOutboundConfigurations()).get(0).getCredentials();
        s3TestUtils = new S3TestUtils(credentials);
View Full Code Here

TOP

Related Classes of com.streamreduce.core.model.messages.SobaMessage

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.