@Override
  public List<IndexSegment> getSegments() {
    List<IndexSegment> segments = new ArrayList<>(_segmentDataManagers.size());
    for (SegmentDataManager segmentDataManager : _segmentDataManagers) {
      if (segmentDataManager.getReferenceCount() > 0) {
        segments.add(segmentDataManager.getSegment());
      }
    }
    return segments;
  }
@Test
  public void testGetSegments() {
    SegmentDataManager sdm1 = mockSegmentDataManager("seg01", false, 1);
    SegmentDataManager sdm2 = mockSegmentDataManager("seg01", true, 1);
    DuoSegmentDataManager dsdm = new DuoSegmentDataManager(sdm1, sdm2);

    assertTrue(dsdm.hasMultiSegments());
    assertSame(dsdm.getSegment(), sdm1.getSegment());
    assertEquals(dsdm.getSegments(), Arrays.asList(sdm1.getSegment(), sdm2.getSegment()));

    when(sdm1.getReferenceCount()).thenReturn(0);
    assertTrue(dsdm.hasMultiSegments());
    assertSame(dsdm.getSegment(), sdm1.getSegment());
    assertEquals(dsdm.getSegments(), Collections.singletonList(sdm2.getSegment()));

    when(sdm2.getReferenceCount()).thenReturn(0);
    assertTrue(dsdm.hasMultiSegments());
    assertSame(dsdm.getSegment(), sdm1.getSegment());
    assertTrue(dsdm.getSegments().isEmpty());
  }