FilterOperator implements Filter { public static Builder builder() { return new Builder(); } @VisibleForTesting  FilterOperator(Operator operator, List<Filter> conditions); static Builder builder(); static FilterOperator or(Filter... filters); static FilterOperator and(Filter... filters); static FilterOperator not(Filter... filters); Operator getOperator(); List<Filter> getConditions(); @Override final boolean equals(Object obj); @Override final int hashCode(); @Override String toString(); @Override String prettyPrint(String indentation);  }
@Test(expected = IllegalStateException.class) public void builderShouldThrowWhenOperatorIsNotGiven() { FilterOperator.builder().build(); }
@Test(expected = NullPointerException.class) public void builderShouldThrowWhenOperatorIsNull() { FilterOperator.builder().operator(null); }
@Test(expected = IllegalStateException.class) public void builderShouldThrowWhenConditionsIsEmpty() { FilterOperator.builder().operator(Operator.AND).build(); }
@Test public void builderShouldWork() { ImmutableList<Filter> conditions = ImmutableList.of(FilterCondition.builder().build()); FilterOperator expectedFilterOperator = new FilterOperator(Operator.AND, conditions); FilterOperator filterOperator = FilterOperator.builder() .operator(Operator.AND) .conditions(conditions) .build(); assertThat(filterOperator).isEqualToComparingFieldByField(expectedFilterOperator); }