@Test
public void recreateExistingCachedCheckpoint() throws IOException {

    FileSystem fsMock = mock(FileSystem.class);
    Path returnedPath = new Path("testPath");
    FsBasedCheckpointer cptr = new FsBasedCheckpointer(fsMock, (ignored, alsoIgnored) -> returnedPath);
    FSDataOutputStream outputStreamMock = mock(FSDataOutputStream.class);
    doReturn(outputStreamMock).when(fsMock).create(returnedPath);
    when(fsMock.exists(returnedPath)).thenReturn(true);
    when(fsMock.create(returnedPath)).thenReturn(outputStreamMock);
    Assert.assertFalse(cptr.tryCheckpoint(1, Instant.MIN));
    verify(fsMock, times(1)).exists(returnedPath);
    Assert.assertFalse(cptr.tryCheckpoint(1, Instant.MIN));
    verify(fsMock, never()).create(returnedPath);
    // Second time, the cache should be used
    verifyNoMoreInteractions(fsMock);
    verifyZeroInteractions(outputStreamMock);
}