### Question:
MissingTrackers implements Warning { @Override public boolean active() { double completion = 0; Set<Integer> ids = new HashSet<>(); for (SegmentStatus info : trackerInfos) { int segmentId = info.getSegmentId(); if (!ids.contains(segmentId))completion += 1d/info.getOnePartOf(); ids.add(segmentId); } return completion < 1; } MissingTrackers(Iterable<SegmentStatus> trackerInfos); @Override boolean active(); @Override String message();  }### Answer:
@Test public void testActive() { List<EventProcessorInfo.SegmentStatus> eventTrackerInfoList = asList(newBuilder().setSegmentId(1) .setOnePartOf(2).build(), newBuilder().setSegmentId(2) .setOnePartOf(4).build()); MissingTrackers warning = new MissingTrackers(eventTrackerInfoList); assertTrue(warning.active()); }
@Test public void testNotActive() { List<EventProcessorInfo.SegmentStatus> eventTrackerInfoList = asList(newBuilder().setSegmentId(1) .setOnePartOf(2).build(), newBuilder().setSegmentId(2) .setOnePartOf(2).build()); MissingTrackers warning = new MissingTrackers(eventTrackerInfoList); assertFalse(warning.active()); }
@Test public void testActiveWithDuplicatesSegments() { List<EventProcessorInfo.SegmentStatus> eventTrackerInfoList = asList(newBuilder().setSegmentId(1) .setOnePartOf(2).build(), newBuilder().setSegmentId(1) .setOnePartOf(4).build()); MissingTrackers warning = new MissingTrackers(eventTrackerInfoList); assertTrue(warning.active()); }
@Test public void testNotActiveWithDuplicatesSegments() { List<EventProcessorInfo.SegmentStatus> eventTrackerInfoList = asList(newBuilder().setSegmentId(1) .setOnePartOf(2).build(), newBuilder().setSegmentId(2) .setOnePartOf(2).build(), newBuilder().setSegmentId(1) .setOnePartOf(2).build(), newBuilder().setSegmentId(2) .setOnePartOf(2).build() ); Warning warning = new MissingTrackers(eventTrackerInfoList); assertFalse(warning.active()); }