ReportingDataCleaner { public static void main(String[] args) { String reportingFolder = args[0]; Path reportingPath = Paths.get(reportingFolder); if (Files.exists(reportingPath)) { System.out.println("Starting processing " + reportingPath.toString()); start(reportingPath); } else { System.out.println(reportingPath.toString() + " not exists."); } } private  ReportingDataCleaner(); static void main(String[] args);  }
@Test public void testOverrideCorrectFlowAndCheckContent() throws Exception { Path userFile = Paths.get(userPath.toString(), "123_minute.bin"); int count = 360; fillWithData(userFile, count); ReportingDataCleaner.main(new String[] {reportingPath.toString()}); assertEquals(16 * 360, Files.size(userFile)); ByteBuffer userReportingData = FileUtils.read(Paths.get(userPath.toString(), "123_minute.bin"), 360); for (int i = 0; i < 360; i++) { double value = userReportingData.getDouble(); long ts = userReportingData.getLong(); assertEquals(i, (int) value); assertEquals(ts, i); } }
@Test public void testOverrideCorrectFlowAndCheckContent2() throws Exception { Path userFile = Paths.get(userPath.toString(), "123_minute.bin"); int count = 720; fillWithData(userFile, count); ReportingDataCleaner.main(new String[] {reportingPath.toString()}); assertEquals(11520, Files.size(userFile)); ByteBuffer userReportingData = FileUtils.read(Paths.get(userPath.toString(), "123_minute.bin"), 360); for (int i = 360; i < 720; i++) { double value = userReportingData.getDouble(); long ts = userReportingData.getLong(); assertEquals(i, (int) value); assertEquals(ts, i); } }
@Test public void testDoNotOverrideSmallFile() throws Exception { Path userFile = Paths.get(userPath.toString(), "123_minute.bin"); int count = 1; fillWithData(userFile, count); ReportingDataCleaner.main(new String[] {reportingPath.toString()}); assertEquals(16 * count, Files.size(userFile)); }
@Test public void testDoNotOverrideSmallFile2() throws Exception { Path userFile = Paths.get(userPath.toString(), "123_minute.bin"); int count = 360; fillWithData(userFile, count); ReportingDataCleaner.main(new String[] {reportingPath.toString()}); assertEquals(16 * count, Files.size(userFile)); }