@Override
  public Stream<FileSlice> getLatestFileSlicesBeforeOrOn(String partitionPath, String maxCommitTime,
      boolean includeFileSlicesInPendingCompaction) {
    return execute(partitionPath, maxCommitTime, includeFileSlicesInPendingCompaction,
        preferredView::getLatestFileSlicesBeforeOrOn, (path, commitTime, includeSlices) -> getSecondaryView().getLatestFileSlicesBeforeOrOn(path, commitTime, includeSlices));
  }
@Test
  public void testGetLatestFileSlicesBeforeOrOn() {
    Stream<FileSlice> actual;
    Stream<FileSlice> expected = testFileSliceStream;
    String partitionPath = "/table2";
    String maxCommitTime = "2020-01-01";

    when(primary.getLatestFileSlicesBeforeOrOn(partitionPath, maxCommitTime, false))
        .thenReturn(testFileSliceStream);
    actual = fsView.getLatestFileSlicesBeforeOrOn(partitionPath, maxCommitTime, false);
    assertEquals(expected, actual);
    verify(secondaryViewSupplier, never()).get();

    resetMocks();
    when(secondaryViewSupplier.get()).thenReturn(secondary);
    when(primary.getLatestFileSlicesBeforeOrOn(partitionPath, maxCommitTime, false))
        .thenThrow(new RuntimeException());
    when(secondary.getLatestFileSlicesBeforeOrOn(partitionPath, maxCommitTime, false))
        .thenReturn(testFileSliceStream);
    actual = fsView.getLatestFileSlicesBeforeOrOn(partitionPath, maxCommitTime, false);
    assertEquals(expected, actual);

    resetMocks();
    when(secondary.getLatestFileSlicesBeforeOrOn(partitionPath, maxCommitTime, false))
        .thenReturn(testFileSliceStream);
    actual = fsView.getLatestFileSlicesBeforeOrOn(partitionPath, maxCommitTime, false);
    assertEquals(expected, actual);

    resetMocks();
    when(secondary.getLatestFileSlicesBeforeOrOn(partitionPath, maxCommitTime, false))
        .thenThrow(new RuntimeException());
    assertThrows(RuntimeException.class, () -> {
      fsView.getLatestFileSlicesBeforeOrOn(partitionPath, maxCommitTime, false);
    });
  }