@Test public void trimAll_A$String_TrimFilterManagerTest() throws Exception { TrimCommentFilter target = new TrimCommentFilter(); String src = IOUtil.readAsString(IOUtil.getResourceAsStream("inputs/TrimFilterManagerTest.txt"), "UTF-8"); String actual = target.trimAll(src); String expected = "package org.junithelper.core.filter; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import org.junit.Test; import org.junithelper.core.filter.impl.TrimAnnotationFilter; import org.junithelper.core.filter.impl.TrimCommentFilter; import org.junithelper.core.filter.impl.TrimInsideOfBraceFilter; import org.junithelper.core.filter.impl.TrimQuotationFilter; public class TrimFilterManagerTest { @Test public void type() throws Exception { assertNotNull(TrimFilterManager.class); } @Test public void instantiation() throws Exception { TrimFilterManager target = new TrimFilterManager(); assertNotNull(target); } @Test public void addFilter_A$TrimFilterArray_0() throws Exception { TrimFilterManager target = new TrimFilterManager(); TrimFilter[] filters = new TrimFilter[] {}; target.addFilter(filters); assertEquals(0, target.getFilters().size()); } @Test public void addFilter_A$TrimFilterArray_1() throws Exception { TrimFilterManager target = new TrimFilterManager(); TrimFilter[] filters = new TrimFilter[] { new TrimAnnotationFilter() }; target.addFilter(filters); assertEquals(1, target.getFilters().size()); } @Test public void addFilter_A$TrimFilterArray_2() throws Exception { TrimFilterManager target = new TrimFilterManager(); TrimFilter[] filters = new TrimFilter[] { new TrimAnnotationFilter(), new TrimCommentFilter() }; target.addFilter(filters); assertEquals(2, target.getFilters().size()); } @Test public void doTrimAll_A$String_null() throws Exception { TrimFilterManager target = new TrimFilterManager(); target.addFilter(new TrimCommentFilter(), new TrimQuotationFilter()); String src = null; String actual = target.doTrimAll(src); String expected = null; assertEquals(expected, actual); } @Test public void doTrimAll_A$String_notNull() throws Exception { TrimFilterManager target = new TrimFilterManager(); target.addFilter(new TrimCommentFilter(), new TrimInsideOfBraceFilter(), new TrimQuotationFilter()); String src = \"\"; String actual = target.doTrimAll(src); String expected = \"\"; assertEquals(expected, actual); } @Test public void removeFilter_A$Class() throws Exception { TrimFilterManager target = new TrimFilterManager(); target.addFilter(new TrimCommentFilter(), new TrimInsideOfBraceFilter(), new TrimQuotationFilter()); Class<?> filterClass = TrimQuotationFilter.class; target.removeFilter(filterClass); assertEquals(2, target.getFilters().size()); } } "; assertEquals(expected, actual); }
@Override public String trimAll(String src) { if (src == null) { return null; } String[] lines = src.split(RegExp.LF); StringBuilder sb = new StringBuilder(); for (String line : lines) { line = new TrimInsideOfStringFilter().trimAll(line).replaceFirst(" sb.append(line); } String withoutLineComments = sb.toString(); String withoutLineBreak = withoutLineComments.replaceAll("\r|\n", " "); String withoutComments = withoutLineBreak.replaceAll("/\\*.*?\\*/", StringValue.Empty); return withoutComments; }
TrimCommentFilter implements TrimFilter { @Override public String trimAll(String src) { if (src == null) { return null; } String[] lines = src.split(RegExp.LF); StringBuilder sb = new StringBuilder(); for (String line : lines) { line = new TrimInsideOfStringFilter().trimAll(line).replaceFirst(" sb.append(line); } String withoutLineComments = sb.toString(); String withoutLineBreak = withoutLineComments.replaceAll("\r|\n", " "); String withoutComments = withoutLineBreak.replaceAll("/\\*.*?\\*/", StringValue.Empty); return withoutComments; } }
TrimCommentFilter implements TrimFilter { @Override public String trimAll(String src) { if (src == null) { return null; } String[] lines = src.split(RegExp.LF); StringBuilder sb = new StringBuilder(); for (String line : lines) { line = new TrimInsideOfStringFilter().trimAll(line).replaceFirst(" sb.append(line); } String withoutLineComments = sb.toString(); String withoutLineBreak = withoutLineComments.replaceAll("\r|\n", " "); String withoutComments = withoutLineBreak.replaceAll("/\\*.*?\\*/", StringValue.Empty); return withoutComments; }  }
TrimCommentFilter implements TrimFilter { @Override public String trimAll(String src) { if (src == null) { return null; } String[] lines = src.split(RegExp.LF); StringBuilder sb = new StringBuilder(); for (String line : lines) { line = new TrimInsideOfStringFilter().trimAll(line).replaceFirst(" sb.append(line); } String withoutLineComments = sb.toString(); String withoutLineBreak = withoutLineComments.replaceAll("\r|\n", " "); String withoutComments = withoutLineBreak.replaceAll("/\\*.*?\\*/", StringValue.Empty); return withoutComments; }  @Override String trimAll(String src); }
TrimCommentFilter implements TrimFilter { @Override public String trimAll(String src) { if (src == null) { return null; } String[] lines = src.split(RegExp.LF); StringBuilder sb = new StringBuilder(); for (String line : lines) { line = new TrimInsideOfStringFilter().trimAll(line).replaceFirst(" sb.append(line); } String withoutLineComments = sb.toString(); String withoutLineBreak = withoutLineComments.replaceAll("\r|\n", " "); String withoutComments = withoutLineBreak.replaceAll("/\\*.*?\\*/", StringValue.Empty); return withoutComments; }  @Override String trimAll(String src);  }