/** * Build a Result object from the given ResultData * * @param resultData data to use to build Result */ public static CommandResult buildResult(ResultData resultData) { return new LegacyCommandResult(resultData); }
@Test public void resultWithFileDoesHaveFileToDownload() { Path fileToDownload = Paths.get(".").toAbsolutePath(); CommandResult commandResult = new LegacyCommandResult(fileToDownload); assertThat(commandResult.hasFileToDownload()).isTrue(); assertThat(commandResult.nextLine()).isEqualTo(fileToDownload.toString() + LINE_SEPARATOR); assertThat(commandResult.getFileToDownload()).isEqualTo(fileToDownload); } }
@Test public void emptyResultHasOneEmptyLine() { CommandResult commandResult = new LegacyCommandResult(new InfoResultData()); Assertions.assertThat(commandResult.nextLine()).isEqualTo(""); Assertions.assertThat(commandResult.hasNextLine()).isFalse(); }
@Test public void resultWithOneLineHasOneLine() { CommandResult commandResult = new LegacyCommandResult(new InfoResultData("oneLine")); assertThat(commandResult.nextLine()).isEqualTo("oneLine" + LINE_SEPARATOR); assertThat(commandResult.hasNextLine()).isFalse(); }
@Test public void emptyResultDoesNotHaveFileToDownload() { CommandResult commandResult = new LegacyCommandResult(new InfoResultData()); Assertions.assertThat(commandResult.hasFileToDownload()).isFalse(); }
@Test public void resultWithTwoLinesHasTwoLines() { InfoResultData resultData = new InfoResultData(); resultData.addLine("lineOne"); resultData.addLine("lineTwo"); CommandResult commandResult = new LegacyCommandResult(resultData); assertThat(commandResult.nextLine()) .isEqualTo("lineOne" + LINE_SEPARATOR + "lineTwo" + LINE_SEPARATOR); assertThat(commandResult.hasNextLine()).isFalse(); }
FileUtils.deleteDirectory(tempDir.toFile()); result = new LegacyCommandResult(exportedLogsZipFile); } finally { ExportLogsFunction.destroyExportLogsRegion(cache);