@Test public void shouldWriteToOutputFileWhenNotUsingOutputDirAndIsSet() { when(mojo.getOutputFile()).thenReturn(OUTPUT_FILE); String output = builder.buildFrom(INPUT_FILE, mojo); assertThat(output, equalTo(fileUtils.createFullPath(BASE_DIR, OUTPUT_FILE))); }
@Test public void shouldPrefixBasedirWhenNotUsingOutputBasedir() { when(mojo.getOutputDir()).thenReturn(OUTPUT_DIR); String output = builder.buildFrom(INPUT_FILE, mojo); assertThat(output, equalTo(fileUtils.createFullPath(BASE_DIR, OUTPUT_DIR, "input"))); }
@Test public void shouldPreservePathWhenPreserveIsEnabled() { when(mojo.isPreserveDir()).thenReturn(true); when(mojo.getOutputDir()).thenReturn(OUTPUT_DIR); String output = builder.buildFrom(INPUT_FILE, mojo); assertThat(output, equalTo(fileUtils.createFullPath(BASE_DIR, OUTPUT_DIR, INPUT_FILE))); }
public List<Replacement> replacementsForFile( String tokenValueMapFile, boolean commentsEnabled, boolean unescape, String encoding) throws IOException { String contents = fileUtils.readFile(tokenValueMapFile, encoding); BufferedReader reader = new BufferedReader(new StringReader(contents)); String fragment = null; List<Replacement> replacements = new ArrayList<Replacement>(); while ((fragment = reader.readLine()) != null) { fragment = fragment.trim(); if (ignoreFragment(fragment, commentsEnabled)) { continue; } appendReplacement(replacements, fragment, unescape, encoding); } return replacements; }
@Test public void shouldReturnInputFileWithBaseDirWhenNoOutputDirOrNoOutputFile() { String output = builder.buildFrom(INPUT_FILE, mojo); assertThat(output, equalTo(fileUtils.createFullPath(BASE_DIR, INPUT_FILE))); }