// 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);