Package in.partake.model.dto

Examples of in.partake.model.dto.MessageEnvelope


public class MessageEnvelopeTestDataProvider extends TestDataProvider<MessageEnvelope> {
    @Override
    public MessageEnvelope create(long pkNumber, String pkSalt, int objNumber) {
        UUID uuid = new UUID(pkNumber, pkSalt.hashCode());
        MessageEnvelope envelope = new MessageEnvelope(uuid.toString(), "userMessageId", null, null, 0, null, null, null, new DateTime(objNumber), null);
        return envelope;
    }
View Full Code Here


    }

    @Override
    public List<MessageEnvelope> createSamples() {
        List<MessageEnvelope> array = new ArrayList<MessageEnvelope>();
        array.add(new MessageEnvelope(new UUID(0, 0).toString(), "userMessageId", null, null, 0, null, null, null, new DateTime(0), null));
        array.add(new MessageEnvelope(new UUID(0, 1).toString(), "userMessageId", null, null, 0, null, null, null, new DateTime(0), null));
        array.add(new MessageEnvelope(new UUID(0, 0).toString(), "userMessageId1", null, null, 0, null, null, null, new DateTime(0), null));
        array.add(new MessageEnvelope(new UUID(0, 0).toString(), "userMessageId", "hoge", null, 0, null, null, null, new DateTime(0), null));
        array.add(new MessageEnvelope(new UUID(0, 0).toString(), "userMessageId", null, "fuga", 0, null, null, null, new DateTime(0), null));
        array.add(new MessageEnvelope(new UUID(0, 0).toString(), "userMessageId", null, null, 1, null, null, null, new DateTime(0), null));
        array.add(new MessageEnvelope(new UUID(0, 0).toString(), "userMessageId", null, null, 0, new DateTime(0), null, null, new DateTime(0), null));
        array.add(new MessageEnvelope(new UUID(0, 0).toString(), "userMessageId", null, null, 0, null, new DateTime(0), null, new DateTime(0), null));
        array.add(new MessageEnvelope(new UUID(0, 0).toString(), "userMessageId", null, null, 0, null, null, new DateTime(0), new DateTime(0), null));
        array.add(new MessageEnvelope(new UUID(0, 0).toString(), "userMessageId", null, null, 0, null, null, null, new DateTime(1), null));
        array.add(new MessageEnvelope(new UUID(0, 0).toString(), "userMessageId", null, null, 0, null, null, null, new DateTime(0), new DateTime(0)));
        return array;
    }
View Full Code Here

    }

    @Test
    public void sendTwitterMessage() throws Exception {
        UUID uuid = UUID.randomUUID();
        MessageEnvelope envelope = MessageEnvelope.createForTwitterMessage(uuid.toString(), TWITTER_MESSAGE_INQUEUE_ID, null);
        queueEnvelope(envelope);

        new SendMessageEnvelopeTask().run();

        List<MessageEnvelope> rest = loadEnvelopes();
View Full Code Here

        String twitterMessageId = UUID.randomUUID().toString();
        TwitterMessage message = new TwitterMessage(twitterMessageId, DEFAULT_USER_ID, TWITTER_MESSAGE_WILLFAIL_MESSAGE, MessageDelivery.INQUEUE, new DateTime(0), null);
        storeTwitterMessage(message);

        UUID envelopeId = UUID.randomUUID();
        MessageEnvelope envelope = new MessageEnvelope(envelopeId.toString(), null, twitterMessageId, null, 0, null, null, now.nHourAfter(1), now, null);
        queueEnvelope(envelope);

        new SendMessageEnvelopeTask().run();

        // |modified| should not be changed.
        MessageEnvelope modified = loadEnvelope(envelopeId.toString());
        assertThat(modified.getNumTried(), is(0));
        assertThat(modified.getLastTriedAt(), is(nullValue()));
    }
View Full Code Here

        String twitterMessageId = UUID.randomUUID().toString();
        TwitterMessage message = new TwitterMessage(twitterMessageId, DEFAULT_USER_ID, TWITTER_MESSAGE_WILLFAIL_MESSAGE, MessageDelivery.INQUEUE, new DateTime(0), null);
        storeTwitterMessage(message);

        UUID envelopeId = UUID.randomUUID();
        MessageEnvelope envelope = MessageEnvelope.createForTwitterMessage(envelopeId.toString(), twitterMessageId, null);
        queueEnvelope(envelope);

        new SendMessageEnvelopeTask().run();

        MessageEnvelope modified = loadEnvelope(envelopeId.toString());
        assertThat(modified.getNumTried(), is(1));
        assertThat(modified.getLastTriedAt(), is(now));
        assertThat(modified.getTryAfter(), is(now.nSecAfter(600)));
    }
View Full Code Here

        String twitterMessageId = UUID.randomUUID().toString();
        TwitterMessage message = new TwitterMessage(twitterMessageId, DEFAULT_USER_ID, TWITTER_MESSAGE_WILLFAIL_MESSAGE, MessageDelivery.INQUEUE, new DateTime(0), null);
        storeTwitterMessage(message);

        UUID envelopeId = UUID.randomUUID();
        MessageEnvelope envelope = MessageEnvelope.createForTwitterMessage(envelopeId.toString(), twitterMessageId, null);
        queueEnvelope(envelope);

        new SendMessageEnvelopeTask().run();

        MessageEnvelope modified = loadEnvelope(envelopeId.toString());
        assertThat(modified.getNumTried(), is(1));
        assertThat(modified.getLastTriedAt(), is(now));
        assertThat(modified.getTryAfter(), is(now.nSecAfter(600))); // 5 min later
    }
View Full Code Here

        String twitterMessageId = UUID.randomUUID().toString();
        TwitterMessage message = new TwitterMessage(twitterMessageId, DEFAULT_USER_ID, TWITTER_MESSAGE_WILLFAIL_MESSAGE, MessageDelivery.INQUEUE, new DateTime(0), null);
        storeTwitterMessage(message);

        UUID envelopeId = UUID.randomUUID();
        MessageEnvelope envelope = MessageEnvelope.createForTwitterMessage(envelopeId.toString(), twitterMessageId, null);
        queueEnvelope(envelope);

        new SendMessageEnvelopeTask().run();

        MessageEnvelope modified = loadEnvelope(envelopeId.toString());
        assertThat(modified.getNumTried(), is(1));
        assertThat(modified.getLastTriedAt(), is(now));
        // TODO: We should think how to test this.
        // assertThat(modified.getTryAfter(), is(now.nSecAfter(1))); // 1 sec after.
    }
View Full Code Here

        String twitterMessageId = UUID.randomUUID().toString();
        TwitterMessage message = new TwitterMessage(twitterMessageId, DEFAULT_USER_ID, TWITTER_MESSAGE_WILLFAIL_MESSAGE, MessageDelivery.INQUEUE, new DateTime(0), null);
        storeTwitterMessage(message);

        UUID envelopeId = UUID.randomUUID();
        MessageEnvelope envelope = MessageEnvelope.createForTwitterMessage(envelopeId.toString(), twitterMessageId, null);
        queueEnvelope(envelope);

        new SendMessageEnvelopeTask().run();

        // Message Envelop should be removed.
        MessageEnvelope modified = loadEnvelope(envelopeId.toString());
        assertThat(modified, is(nullValue()));

        // User should be unauthorized.
        UserEx user = loadUserEx(DEFAULT_USER_ID);
        assertThat(user.getTwitterLinkage().getAccessToken(), is(nullValue()));
View Full Code Here

        doReturn(null).when(res).getResponseHeader(eq("X-RateLimit-Remaining"));
        doReturn(null).when(res).getResponseHeader(eq("X-RateLimit-Reset"));
        doThrow(new TwitterException("message", res)).when(PartakeApp.getTwitterService()).updateStatus(anyString(), anyString(), eq(TWITTER_MESSAGE_WILLFAIL_MESSAGE));

        UUID envelopeId = UUID.randomUUID();
        MessageEnvelope envelope = MessageEnvelope.createForTwitterMessage(envelopeId.toString(), UUID.randomUUID().toString(), null);
        queueEnvelope(envelope);

        new SendMessageEnvelopeTask().run();

        // The message should be removed from the queue.
        MessageEnvelope modified = loadEnvelope(envelopeId.toString());
        assertThat(modified, is(nullValue()));
    }
View Full Code Here

        String twitterMessageId = UUID.randomUUID().toString();
        TwitterMessage message = new TwitterMessage(twitterMessageId, INVALID_USER_ID, TWITTER_MESSAGE_WILLFAIL_MESSAGE, MessageDelivery.INQUEUE, new DateTime(0), null);
        storeTwitterMessage(message);

        UUID envelopeId = UUID.randomUUID();
        MessageEnvelope envelope = MessageEnvelope.createForTwitterMessage(envelopeId.toString(), twitterMessageId, null);
        queueEnvelope(envelope);

        new SendMessageEnvelopeTask().run();

        // The message should be removed from the queue.
        MessageEnvelope modified = loadEnvelope(envelopeId.toString());
        assertThat(modified, is(nullValue()));
    }
View Full Code Here

TOP

Related Classes of in.partake.model.dto.MessageEnvelope

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.