Package in.partake.base

Examples of in.partake.base.DateTime


        assertThat(modified.getTryAfter(), is(now.nSecAfter(600))); // 5 min later
    }

    @Test
    public void sendTwitterMessageWithTwitterExceptionExceededLimit() throws Exception {
        DateTime now = TimeUtil.getCurrentDateTime();
        TimeUtil.setCurrentDateTime(now);

        HttpResponse res = mock(HttpResponse.class);
        doReturn(400).when(res).getStatusCode();
        doReturn("100").when(res).getResponseHeader(eq("X-RateLimit-Limit"));
        doReturn("100").when(res).getResponseHeader(eq("X-RateLimit-Remaining"));
        doReturn("1").when(res).getResponseHeader(eq("X-RateLimit-Reset"));
        doThrow(new TwitterException("message", res)).when(PartakeApp.getTwitterService()).updateStatus(anyString(), anyString(), eq(TWITTER_MESSAGE_WILLFAIL_MESSAGE));

        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);
View Full Code Here


        // assertThat(modified.getTryAfter(), is(now.nSecAfter(1))); // 1 sec after.
    }

    @Test
    public void sendTwitterMessageWithTwitterExceptionCausedByUnauthorized() throws Exception {
        DateTime now = TimeUtil.getCurrentDateTime();
        TimeUtil.setCurrentDateTime(now);

        HttpResponse res = mock(HttpResponse.class);
        doReturn(401).when(res).getStatusCode();
        doReturn(null).when(res).getResponseHeader(eq("X-RateLimit-Limit"));
        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));

        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);
View Full Code Here

        assertThat(user.getTwitterLinkage().getAccessTokenSecret(), is(nullValue()));
    }

    @Test
    public void sendTwitterMessageWithInvalidId() throws Exception {
        DateTime now = TimeUtil.getCurrentDateTime();
        TimeUtil.setCurrentDateTime(now);

        HttpResponse res = mock(HttpResponse.class);
        doReturn(null).when(res).getResponseHeader(eq("X-RateLimit-Limit"));
        doReturn(null).when(res).getResponseHeader(eq("X-RateLimit-Remaining"));
View Full Code Here

        assertThat(modified, is(nullValue()));
    }

    @Test
    public void sendTwitterMessageWithInvalidUserId() throws Exception {
        DateTime now = TimeUtil.getCurrentDateTime();
        TimeUtil.setCurrentDateTime(now);

        HttpResponse res = mock(HttpResponse.class);
        doReturn(null).when(res).getResponseHeader(eq("X-RateLimit-Limit"));
        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));

        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);
View Full Code Here

        assertThat(modified, is(nullValue()));
    }

    @Test
    public void sendTwitterMessageWithNoTwitterLinkUser() throws Exception {
        DateTime now = TimeUtil.getCurrentDateTime();
        TimeUtil.setCurrentDateTime(now);

        HttpResponse res = mock(HttpResponse.class);
        doReturn(null).when(res).getResponseHeader(eq("X-RateLimit-Limit"));
        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));

        String twitterMessageId = UUID.randomUUID().toString();
        TwitterMessage message = new TwitterMessage(twitterMessageId, USER_NO_TWITTER_LINK_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);
View Full Code Here

        assertThat(modified, is(nullValue()));
    }

    @Test
    public void sendTwitterMessageWithNoAuthorizedTwitterLinkUser() throws Exception {
        DateTime now = TimeUtil.getCurrentDateTime();
        TimeUtil.setCurrentDateTime(now);

        HttpResponse res = mock(HttpResponse.class);
        doReturn(null).when(res).getResponseHeader(eq("X-RateLimit-Limit"));
        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));

        String twitterMessageId = UUID.randomUUID().toString();
        TwitterMessage message = new TwitterMessage(twitterMessageId, USER_TWITTER_NOAUTH_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);
View Full Code Here

        assertThat(loadUserReceivedMessage(USER_RECEIVED_MESSAGE_INQUEUE_ID).getDelivery(), is(MessageDelivery.SUCCESS));
    }

    @Test
    public void sendInvalidatedMessage() throws Exception {
        DateTime now = TimeUtil.getCurrentDateTime();
        DateTime before = now.nDayBefore(1);

        UUID uuid = UUID.randomUUID();
        MessageEnvelope envelope = MessageEnvelope.createForTwitterMessage(uuid.toString(), TWITTER_MESSAGE_INQUEUE_ID, before);
        queueEnvelope(envelope);
View Full Code Here

    }

    @Override
    public EventActivity create(long pkNumber, String pkSalt, int objNumber) {
        UUID uuid = new UUID(pkNumber, ("activity" + pkSalt).hashCode());
        return new EventActivity(uuid.toString(), "eventId", "title" + objNumber, "content", new DateTime(objNumber % 10));
    }
View Full Code Here

            protected Void doExecute(PartakeConnection con, IPartakeDAOs daos) throws DAOException, PartakeException {
                String eventId = "eventId-findByEventId-0-" + System.currentTimeMillis();

                con.beginTransaction();
                for (int i = 0; i < 10; ++i) {
                    EventActivity activity = new EventActivity(dao.getFreshId(con), eventId, "title-" + i, "content", new DateTime(i));
                    dao.put(con, activity);
                }
                con.commit();

                List<EventActivity> activities = dao.findByEventId(con, eventId, 10);
View Full Code Here



                con.beginTransaction();
                for (int i = 0; i < 10; ++i) {
                    EventActivity activity = new EventActivity(dao.getFreshId(con), eventId1, "title-" + i, "content", new DateTime(i));
                    dao.put(con, activity);
                }
                for (int i = 0; i < 10; ++i) {
                    EventActivity activity = new EventActivity(dao.getFreshId(con), eventId2, "title-" + i, "content", new DateTime(i));
                    dao.put(con, activity);
                }
                con.commit();

                List<EventActivity> activities1 = dao.findByEventId(con, eventId1, 10);
View Full Code Here

TOP

Related Classes of in.partake.base.DateTime

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.