Source:
public void testAvailableSegmentMetadataIsRealtime() { Map<SegmentId, AvailableSegmentMetadata> segmentsMetadata = schema.getSegmentMetadataSnapshot(); final List<DataSegment> segments = segmentsMetadata.values() .stream() .map(AvailableSegmentMetadata::getSegment) .collect(Collectors.toList()); final DataSegment existingSegment = segments.stream() .filter(segment -> segment.getDataSource().equals("foo3")) .findFirst() .orElse(null); final AvailableSegmentMetadata metadata = segmentsMetadata.get(existingSegment.getId()); Assert.assertEquals(metadata.isRealtime(), 1L); final ImmutableDruidServer historicalServer = druidServers.stream() .filter(s -> s.getType().equals(ServerType.HISTORICAL)) .findAny() .orElse(null); Assert.assertNotNull(historicalServer); final DruidServerMetadata historicalServerMetadata = historicalServer.getMetadata(); schema.addSegment(historicalServerMetadata, existingSegment); segmentsMetadata = schema.getSegmentMetadataSnapshot(); DataSegment currentSegment = segments.stream() .filter(segment -> segment.getDataSource().equals("foo3")) .findFirst() .orElse(null); AvailableSegmentMetadata currentMetadata = segmentsMetadata.get(currentSegment.getId()); Assert.assertEquals(currentMetadata.isRealtime(), 1L); ImmutableDruidServer realtimeServer = druidServers.stream() .filter(s -> s.getType().equals(ServerType.REALTIME)) .findAny() .orElse(null); schema.removeServerSegment(realtimeServer.getMetadata(), existingSegment); segmentsMetadata = schema.getSegmentMetadataSnapshot(); currentSegment = segments.stream() .filter(segment -> segment.getDataSource().equals("foo3")) .findFirst() .orElse(null); currentMetadata = segmentsMetadata.get(currentSegment.getId()); Assert.assertEquals(currentMetadata.isRealtime(), 0L); }

Target:
public void testAvailableSegmentMetadataIsRealtime() { Map<SegmentId, AvailableSegmentMetadata> segmentsMetadata = schema.getSegmentMetadataSnapshot(); final List<DataSegment> segments = segmentsMetadata.values() .stream() .map(AvailableSegmentMetadata::getSegment) .collect(Collectors.toList()); final DataSegment existingSegment = segments.stream() .filter(segment -> segment.getDataSource().equals("foo3")) .findFirst() .orElse(null); Assert.assertNotNull(existingSegment); final AvailableSegmentMetadata metadata = segmentsMetadata.get(existingSegment.getId()); Assert.assertEquals(1L, metadata.isRealtime()); final ImmutableDruidServer historicalServer = druidServers.stream() .filter(s -> s.getType().equals(ServerType.HISTORICAL)) .findAny() .orElse(null); Assert.assertNotNull(historicalServer); final DruidServerMetadata historicalServerMetadata = historicalServer.getMetadata(); schema.addSegment(historicalServerMetadata, existingSegment); segmentsMetadata = schema.getSegmentMetadataSnapshot(); DataSegment currentSegment = segments.stream() .filter(segment -> segment.getDataSource().equals("foo3")) .findFirst() .orElse(null); Assert.assertNotNull(currentSegment); AvailableSegmentMetadata currentMetadata = segmentsMetadata.get(currentSegment.getId()); Assert.assertEquals(0L, currentMetadata.isRealtime()); ImmutableDruidServer realtimeServer = druidServers.stream() .filter(s -> s.getType().equals(ServerType.REALTIME)) .findAny() .orElse(null); Assert.assertNotNull(realtimeServer); schema.removeServerSegment(realtimeServer.getMetadata(), existingSegment); segmentsMetadata = schema.getSegmentMetadataSnapshot(); currentSegment = segments.stream() .filter(segment -> segment.getDataSource().equals("foo3")) .findFirst() .orElse(null); Assert.assertNotNull(currentSegment); currentMetadata = segmentsMetadata.get(currentSegment.getId()); Assert.assertEquals(0L, currentMetadata.isRealtime()); }