LoadIO { public String showSavedFiles(Args args) { StringBuilder sb = new StringBuilder(); savedFileNameList = savedFileNameList(args); int index = savedFileNameList.size() - 1; if (index >= 0) { for (String fileName : savedFileNameList) { String timestamp = parseTimestamp(args, fileName); try { sb.append(index--).append(": ").append(DATE_FORMAT_PRINT.format(DATE_FORMAT_SAVE.parse(timestamp))).append("\n"); } catch (ParseException e) { e.printStackTrace(); } } } else { sb.append(NO_SAVED_FILE + "\n"); } return sb.toString(); } LoadIO(Load load); String save(Args args); void load(Args args, String input); String showSavedFiles(Args args); static final String NO_SAVED_FILE; }
@Test public void testNoDirectory() throws Exception { String[] argsRaw = {"zookeeper", "table"}; Args args = new StatArgs(argsRaw); Load load = new Load(new LevelClass(TableName.class), args); LoadIO loadIO = createLoadIO(load); try { Files.delete(Paths.get(LoadIO.DIRECTORY_NAME)); } catch (NoSuchFileException ignored) { } assertTrue(loadIO.showSavedFiles(args).startsWith(LoadIO.NO_SAVED_FILE)); }