コード例 #1
0
 @Test
 public void testFirstTimestampIsNow() {
   message.setTime(new GregorianCalendar(2000, 01, 01).getTimeInMillis());
   ArgumentCaptor<GPSLocationMessage> messageCaptor =
       ArgumentCaptor.forClass(GPSLocationMessage.class);
   long now = (new Date()).getTime();
   decorator.sendGPSLocationMessage(message);
   verify(decoratedSimulator, only()).sendGPSLocationMessage(messageCaptor.capture());
   assertTimestampsAreCloseEnough(now, messageCaptor.getValue().getTime());
 }
コード例 #2
0
 @Test
 public void testTwoEmptyTimestampsMake1SecondDifference() {
   ArgumentCaptor<GPSLocationMessage> messageCaptor =
       ArgumentCaptor.forClass(GPSLocationMessage.class);
   long start = (new Date()).getTime();
   GPSLocationMessage message1 = new GPSLocationMessage();
   GPSLocationMessage message2 = new GPSLocationMessage();
   decorator.sendGPSLocationMessage(message1);
   long midde = (new Date()).getTime();
   decorator.sendGPSLocationMessage(message2);
   long end = (new Date()).getTime();
   verify(decoratedSimulator, times(2)).sendGPSLocationMessage(messageCaptor.capture());
   List<GPSLocationMessage> decoratedMessages = messageCaptor.getAllValues();
   long startByTracker = decoratedMessages.get(0).getTime();
   long endByTracker = decoratedMessages.get(1).getTime();
   assertTimestampsAreCloseEnough(start, startByTracker);
   assertTimestampsAreCloseEnough(start, midde);
   assertTimestampsAreCloseEnough(end, endByTracker);
   assertTimestampsAreCloseEnough(startByTracker + 1000, endByTracker);
 }
コード例 #3
0
 @Test
 public void testTwoTimestampsHaveSameDifference() {
   ArgumentCaptor<GPSLocationMessage> messageCaptor =
       ArgumentCaptor.forClass(GPSLocationMessage.class);
   long start = (new Date()).getTime();
   GPSLocationMessage message1 = new GPSLocationMessage();
   message1.setTime(new GregorianCalendar(2012, 12, 12, 12, 12, 12).getTimeInMillis());
   GPSLocationMessage message2 = new GPSLocationMessage();
   message2.setTime(new GregorianCalendar(2012, 12, 12, 12, 12, 14).getTimeInMillis());
   decorator.sendGPSLocationMessage(message1);
   long midde = (new Date()).getTime();
   decorator.sendGPSLocationMessage(message2);
   long end = (new Date()).getTime();
   verify(decoratedSimulator, times(2)).sendGPSLocationMessage(messageCaptor.capture());
   List<GPSLocationMessage> decoratedMessages = messageCaptor.getAllValues();
   long startByTracker = decoratedMessages.get(0).getTime();
   long endByTracker = decoratedMessages.get(1).getTime();
   assertTimestampsAreCloseEnough(start, startByTracker);
   assertTimestampsAreCloseEnough(start, midde);
   assertTimestampsAreCloseEnough(end, endByTracker);
   assertTimestampsAreCloseEnough(startByTracker + 2000, endByTracker);
 }
コード例 #4
0
 @Test
 public void testDecorates() {
   decorator.sendGPSLocationMessage(message);
   verify(decoratedSimulator, only()).sendGPSLocationMessage(message);
 }