@Override public Log create() { return new StartServiceLog(); } }
/** * Queue start service log. */ @WorkerThread private void sendStartServiceLog() { if (!mStartedServicesNamesToLog.isEmpty() && isInstanceEnabled()) { List<String> allServiceNamesToStart = new ArrayList<>(mStartedServicesNamesToLog); mStartedServicesNamesToLog.clear(); StartServiceLog startServiceLog = new StartServiceLog(); startServiceLog.setServices(allServiceNamesToStart); mChannel.enqueue(startServiceLog, CORE_GROUP, Flags.DEFAULTS); } }
@Test public void ignoreStartService() { Log startServiceLog = spy(new StartServiceLog()); mSessionTracker.onPreparingLog(startServiceLog, TEST_GROUP); verify(mChannel, never()).enqueue(any(Log.class), anyString(), anyInt()); verify(startServiceLog, never()).setSid(any(UUID.class)); }
@Test public void compareDifferentType() { TestUtils.compareSelfNullClass(new StartServiceLog()); }
@Test public void startServiceLog() throws JSONException { StartServiceLog log = new StartServiceLog(); List<String> services = new ArrayList<>(); services.add("FIRST"); services.add("SECOND"); log.setServices(services); UUID sid = UUIDUtils.randomUUID(); log.setSid(sid); log.setTimestamp(new Date()); /* Verify serialize and deserialize. */ LogSerializer serializer = new DefaultLogSerializer(); serializer.addLogFactory(StartServiceLog.TYPE, new StartServiceLogFactory()); String payload = serializer.serializeLog(log); Log actualContainer = serializer.deserializeLog(payload, null); assertEquals(log, actualContainer); }
@Test public void compare() { /* Empty objects. */ StartServiceLog a = new StartServiceLog(); StartServiceLog b = new StartServiceLog(); checkEquals(a, b); checkEquals(a.getType(), StartServiceLog.TYPE); UUID sid = UUIDUtils.randomUUID(); a.setSid(sid); checkNotEquals(a, b); b.setSid(sid); checkEquals(a, b); /* Services. */ List<String> services = new ArrayList<>(); services.add("FIRST"); services.add("SECOND"); a.setServices(services); checkEquals(a.getServices(), services); checkNotEquals(a, b); b.setServices(new ArrayList<String>()); checkNotEquals(a, b); b.setServices(services); checkEquals(a, b); } }