StatusCodesFilter { public List<StatusCode> filter(List<StatusCode> codes) { return FluentIterable.from(codes).filter(new StatusCodeFilterPredicate()).toList(); } StatusCodesFilter(int lowerBound, int upperBound, List<Integer> filterCodes); List<StatusCode> filter(List<StatusCode> codes);  }
@Test public void testFilter_emptyList() { statusCodes = Lists.newArrayList(); tested = getTested(0, 600, new ArrayList<Integer>()); tested.filter(statusCodes); assertThat(statusCodes, notNullValue()); assertThat(statusCodes, is((empty()))); }
@Test(expected = NullPointerException.class) public void testFilter_nullList() { statusCodes = null; tested = getTested(0, 600, new ArrayList<Integer>()); tested.filter(statusCodes); }
@TestWith({"0,18", "100,18", "101,17", "199,16", "200,15", "300,12", "400,9", "500,3",}) public void testFilter_lowerBound(int lowerBound, int expectedSize) { tested = getTested(lowerBound, 600, new ArrayList<Integer>()); List<StatusCode> result = tested.filter(statusCodes); assertThat(result.size(), is(expectedSize)); }
@TestWith({"0,0", "100,1", "101,2", "199,3", "200,4", "300,7", "400,10", "500,16",}) public void testFilter_upperBound(int upperBound, int expectedSize) { tested = getTested(0, upperBound, new ArrayList<Integer>()); List<StatusCode> result = tested.filter(statusCodes); assertThat(result.size(), is(expectedSize)); }
@TestWith({"0,600,18", "100,500,16", "400,600,9"}) public void testFilter_bounds(int lowerBound, int upperBound, int expectedSize) { tested = getTested(lowerBound, upperBound, new ArrayList<Integer>()); List<StatusCode> result = tested.filter(statusCodes); assertThat(result.size(), is(expectedSize)); }
@TestWith({"100;200;201,18", "400;401;499,18", "404,18"}) public void testFilter_filterCodes(String filterCodesParam, int expectedSize) { tested = getTested(0, 600, prepareFilterCodes(filterCodesParam)); List<StatusCode> result = tested.filter(statusCodes); assertThat(result.size(), is(expectedSize)); }
@TestWith({"100;200;201,100,200,5", "400;401;499,100,400,12"}) public void testFilter_boundsWithFilterCodes(String filterCodesParam, int lowerBound, int upperBound, int expectedSize) { tested = getTested(lowerBound, upperBound, prepareFilterCodes(filterCodesParam)); List<StatusCode> result = tested.filter(statusCodes); assertThat(result.size(), is(expectedSize)); }