AdminPasswordFileManagerImpl extends ComponentSupport implements AdminPasswordFileManager { @Override public String readFile() throws IOException { if (adminPasswordFile.exists()) { return new String(Files.readAllBytes(adminPasswordFile.toPath()), StandardCharsets.UTF_8); } return null; } @Inject  AdminPasswordFileManagerImpl(final ApplicationDirectories applicationDirectories); @Override boolean writeFile(String password); @Override boolean exists(); @Override String getPath(); @Override String readFile(); @Override void removeFile(); final ApplicationDirectories applicationDirectories; }
@Test public void testReadFile() throws Exception { File passwordFile = new File(applicationDirectories.getWorkDirectory(), "admin.password"); Files.write(passwordFile.toPath(), "testpass".getBytes("UTF-8")); assertThat(underTest.readFile(), is("testpass")); }