### Question:
LocalFileCheckpointHandler implements CheckpointHandler { @Override public byte[] readCheckpoint(String checkpointName) throws IOException { return getCheckpointContent(getCheckpointFilePath(checkpointName)); } @VisibleForTesting  LocalFileCheckpointHandler(String directory, FileHelper fileHelper); @Override byte[] readCheckpoint(String checkpointName); @Override void saveCheckpoint(String checkpointName, byte[] checkpoint); static final String CONNECTOR_CHECKPOINT_DIRECTORY; }### Answer:
@Test public void testReadCheckpointFileNotExist() throws IOException { LocalFileCheckpointHandler handler = new LocalFileCheckpointHandler("checkpointpath", mockFileHelper); when(mockCheckpointFile.exists()).thenReturn(false); assertNull(handler.readCheckpoint("test_checkpoint")); }
@Test public void testReadCheckpointNotFile() throws IOException { LocalFileCheckpointHandler handler = new LocalFileCheckpointHandler("checkpointpath", mockFileHelper); when(mockCheckpointFile.isFile()).thenReturn(false); thrown.expect(IllegalArgumentException.class); thrown.expectMessage("checkpoint file is not pointing to file"); handler.readCheckpoint("test_checkpoint"); }
@Test public void testReadCheckpointFileSuccess() throws IOException { LocalFileCheckpointHandler handler = new LocalFileCheckpointHandler("checkpointpath", mockFileHelper); assertEquals(golden, handler.readCheckpoint("test_checkpoint")); }
@Test public void testReadMultipleCheckpoints() throws IOException { File fooFile = mock(File.class); when(fooFile.exists()).thenReturn(true); when(fooFile.isFile()).thenReturn(true); when(fooFile.toPath()).thenReturn(createPath("path/foo.txt")); File barFile = mock(File.class); when(barFile.exists()).thenReturn(true); when(barFile.isFile()).thenReturn(true); when(barFile.toPath()).thenReturn(createPath("path/bar.txt")); when(mockFileHelper.getFile(fooFile.toPath())).thenReturn(fooFile); when(mockFileHelper.getFile(barFile.toPath())).thenReturn(barFile); when(mockFileHelper.readFile(fooFile)).thenReturn("foo".getBytes()); when(mockFileHelper.readFile(barFile)).thenReturn("bar".getBytes()); LocalFileCheckpointHandler handler = new LocalFileCheckpointHandler("path", mockFileHelper); assertEquals("foo", new String(handler.readCheckpoint("foo.txt"))); assertEquals("bar", new String(handler.readCheckpoint("bar.txt"))); }