@Test public void testSetAndGetFilter() { assertThat(category.getFilter()).isNull(); category.setFilter(new StartsWith()); assertThat(category.getFilter()).isEqualTo(new StartsWith()); category.setFilter(null); assertThat(category.getFilter()).isNull(); }
@Test public void testGetFilters() { assertThat(category.getFilterTypes()) .containsOnly( new StringEquals(), new StringNotEquals(), new StartsWith(), new EndsWith(), new EqualsIgnoreCase(), new NotEqualsIgnoreCase(), new Contains()); final IFilterType<String> filterType = category.getFilterTypes().get(0); filterType.setFilterValue("12345"); assertThat(category.getFilterTypes().contains(filterType)).isFalse(); }
@Test public void testHashCode() { assertThat(category.hashCode()).isEqualTo(new ForeNameCategory().hashCode()); assertThat(category.hashCode()).isEqualTo(category.hashCode()); assertThat(category.hashCode()).isEqualTo(new LocationCategory().hashCode()); category.setFilter(new StringEquals()); final ForeNameCategory other = new ForeNameCategory(); other.setFilter(new StringEquals()); assertThat(category.hashCode()).isEqualTo(other.hashCode()); final LocationCategory different = new LocationCategory(); different.setFilter(new StringEquals()); assertThat(category.hashCode()).isEqualTo(different.hashCode()); }
@Test public void testEquals() { assertThat(category).isEqualTo(new ForeNameCategory()); assertThat(category).isEqualTo(category); assertThat(category).isNotEqualTo(null); assertThat(category).isNotEqualTo(new LocationCategory()); assertThat(category).isNotEqualTo("category"); category.setFilter(new StringEquals()); final ForeNameCategory other = new ForeNameCategory(); assertThat(category).isNotEqualTo(other); assertThat(other).isNotEqualTo(category); other.setFilter(new StringEquals()); assertThat(category).isEqualTo(other); final LocationCategory different = new LocationCategory(); different.setFilter(new StringEquals()); category.getFilter().setFilterValue("juppi <- :)"); assertThat(category).isNotEqualTo(different); assertThat(different).isNotEqualTo(category); }
@Test public void testIsMatchingFilter() { assertThat(category.isMatchingFilter(null)).isFalse(); final Participant p = new Participant( "Musterfrau", "Maxi", Gender.FEMALE, Denomination.CATHOLIC, new Date(100000000), "street", 12, "city", CountyCouncil.COUNTY_RHEIN_PFALZ); assertThat(category.isMatchingFilter(p)).isFalse(); final StartsWith startsWith = new StartsWith(); startsWith.setFilterValue("Maxi"); category.setFilter(startsWith); assertThat(category.isMatchingFilter(p)).isTrue(); final EndsWith endsWith = new EndsWith(); endsWith.setFilterValue("maxi"); category.setFilter(endsWith); assertThat(category.isMatchingFilter(p)).isFalse(); }
@Test public void testGetShortDescription() { assertThat(category.getShortDescription()) .isEqualTo(Text.FILTER_CAT_PARTICIPANT_FORE_NAME.text()); assertThat(category.getShortDescription()).isEqualTo(Text.PARTICIPANT_FORENAME.text()); }