@Test
  public void shouldCreateCsvFileWithExpectedPermissions() throws IOException {

    Assert.assertNotNull(csvFileCsvFilePersisterService);

    Assert.assertTrue("The generated file couldn't be found", Files.exists(testCsvPath));

    Assert.assertTrue("The generated files doesn't have all the expected permissions", Files.getPosixFilePermissions(testCsvPath).containsAll(csvFileCsvFilePersisterService.getCsvPermissions()));

    Assert.assertFalse("The generated file has more than the required permissions", Files.getPosixFilePermissions(testCsvPath).contains(PosixFilePermission.GROUP_EXECUTE));

  }
Guice module for testing service / factory behavior
ambari-server/src/test/java/org/apache/ambari/server/serveraction/users/CsvFilePersisterServiceFunctionalTest.java