LineBreakProvider { public String getLineBreak() { if (config.lineBreakPolicy.equals(LineBreakPolicy.forceCRLF)) { return StringValue.CarriageReturn + StringValue.LineFeed; } else if (config.lineBreakPolicy.equals(LineBreakPolicy.forceLF)) { return StringValue.LineFeed; } else if (config.lineBreakPolicy.equals(LineBreakPolicy.forceNewFileCRLF)) { if (currentLineBreak == null) { return StringValue.CarriageReturn + StringValue.LineFeed; } else { return getLineBreakFromCurrentLineBreak(currentLineBreak); } } else if (config.lineBreakPolicy.equals(LineBreakPolicy.forceNewFileLF)) { if (currentLineBreak == null) { return StringValue.LineFeed; } else { return getLineBreakFromCurrentLineBreak(currentLineBreak); } } return StringValue.CarriageReturn + StringValue.LineFeed; } LineBreakProvider(Configuration config, CurrentLineBreak currentLineBreak); String getLineBreak();  }
@Test public void getLineBreak_A$_FORCE_CRLF() throws Exception { Configuration config = new Configuration(); config.lineBreakPolicy = LineBreakPolicy.forceCRLF; CurrentLineBreak currentLineBreak = CurrentLineBreak.LF; LineBreakProvider target = new LineBreakProvider(config, currentLineBreak); String actual = target.getLineBreak(); String expected = "\r\n"; assertThat(actual, is(equalTo(expected))); }
@Test public void getLineBreak_A$_FORCE_LF() throws Exception { Configuration config = new Configuration(); config.lineBreakPolicy = LineBreakPolicy.forceLF; CurrentLineBreak currentLineBreak = CurrentLineBreak.CRLF; LineBreakProvider target = new LineBreakProvider(config, currentLineBreak); String actual = target.getLineBreak(); String expected = "\n"; assertThat(actual, is(equalTo(expected))); }
@Test public void getLineBreak_A$_CRLF_NEW_FILE_ONLY_1() throws Exception { Configuration config = new Configuration(); config.lineBreakPolicy = LineBreakPolicy.forceNewFileCRLF; CurrentLineBreak currentLineBreak = CurrentLineBreak.LF; LineBreakProvider target = new LineBreakProvider(config, currentLineBreak); String actual = target.getLineBreak(); String expected = "\n"; assertThat(actual, is(equalTo(expected))); }
@Test public void getLineBreak_A$_CRLF_NEW_FILE_ONLY_2() throws Exception { Configuration config = new Configuration(); config.lineBreakPolicy = LineBreakPolicy.forceNewFileCRLF; CurrentLineBreak currentLineBreak = null; LineBreakProvider target = new LineBreakProvider(config, currentLineBreak); String actual = target.getLineBreak(); String expected = "\r\n"; assertThat(actual, is(equalTo(expected))); }
@Test public void getLineBreak_A$_LF_NEW_FILE_ONLY_1() throws Exception { Configuration config = new Configuration(); config.lineBreakPolicy = LineBreakPolicy.forceNewFileLF; CurrentLineBreak currentLineBreak = CurrentLineBreak.CRLF; LineBreakProvider target = new LineBreakProvider(config, currentLineBreak); String actual = target.getLineBreak(); String expected = "\r\n"; assertThat(actual, is(equalTo(expected))); }
@Test public void getLineBreak_A$_LF_NEW_FILE_ONLY_2() throws Exception { Configuration config = new Configuration(); config.lineBreakPolicy = LineBreakPolicy.forceNewFileLF; CurrentLineBreak currentLineBreak = null; LineBreakProvider target = new LineBreakProvider(config, currentLineBreak); String actual = target.getLineBreak(); String expected = "\n"; assertThat(actual, is(equalTo(expected))); }