FortifyReportFile { boolean exist() { File report = getReportFromProperty(); return report != null; } FortifyReportFile(FortifySensorConfiguration configuration, FileSystem fileSystem);   }
@Test public void testExists() { FortifySensorConfiguration configuration = mock(FortifySensorConfiguration.class); when(configuration.getReportPath()).thenReturn("src/test/resources/report/audit.fvdl"); FileSystem fileSystem = mock(FileSystem.class); when(fileSystem.baseDir()).thenReturn(new File(System.getProperty("user.dir"))); FortifyReportFile fortifyReportFile = new FortifyReportFile(configuration, fileSystem); assertTrue(fortifyReportFile.exist()); }
@Test public void testNotExists() { FortifySensorConfiguration configuration = mock(FortifySensorConfiguration.class); when(configuration.getReportPath()).thenReturn(null); FortifyReportFile fortifyReportFile = new FortifyReportFile(configuration, this.fs); assertFalse(fortifyReportFile.exist()); }
@Test public void testWrongPathExists() { FortifySensorConfiguration configuration = mock(FortifySensorConfiguration.class); when(configuration.getReportPath()).thenReturn("/do/not/exist/audit.fvdl"); FortifyReportFile fortifyReportFile = new FortifyReportFile(configuration, this.fs); try { fortifyReportFile.exist(); fail("An exception is expected!"); } catch (MessageException e) { } }
@Test public void testDirExists() { FortifySensorConfiguration configuration = mock(FortifySensorConfiguration.class); when(configuration.getReportPath()).thenReturn(System.getProperty("user.dir")); FortifyReportFile fortifyReportFile = new FortifyReportFile(configuration, this.fs); try { fortifyReportFile.exist(); fail("An exception is expected!"); } catch (MessageException e) { } }