@Test public void invalidGroup() throws Persistence.PersistenceException { Persistence persistence = mock(Persistence.class); Channel channel = new DefaultChannel(mock(Context.class), UUIDUtils.randomUUID().toString(), persistence, mock(Ingestion.class), mAppCenterHandler); /* Enqueue a log before group is registered = failure. */ Log log = mock(Log.class); channel.enqueue(log, TEST_GROUP, Flags.DEFAULTS); verify(log, never()).setDevice(any(Device.class)); verify(log, never()).setTimestamp(any(Date.class)); verify(persistence, never()).putLog(eq(log), eq(TEST_GROUP), anyInt()); /* Trying remove group that not registered. */ channel.removeGroup(TEST_GROUP); verify(mAppCenterHandler, never()).removeCallbacks(any(Runnable.class)); }
Log log = mock(Log.class); channel.enqueue(log, "", DEFAULTS); verify(log).setDevice(device); verify(log).setTimestamp(any(Date.class)); when(log2.getTimestamp()).thenReturn(new Date(123L)); channel.enqueue(log2, "", DEFAULTS); verify(log2, never()).setDevice(any(Device.class)); verify(log2, never()).setTimestamp(any(Date.class)); Log log3 = mock(Log.class); channel.enqueue(log3, "", DEFAULTS); verify(log3).setDevice(device2); verify(log3).setTimestamp(any(Date.class));
log.setDevice(mDevice);
for (Log log : logs) { log.setSid(sid); log.setDevice(device);