### Question:
CheckAggregateDefinitionValidator implements ConstraintValidator<CheckAggregateDefinition, ClientQueryAggregatedField>,
        ValidationErrorDescriptorBuilder { @Override public boolean isValid(ClientQueryAggregatedField value, ConstraintValidatorContext context) { boolean isDefault = (value.getAggregateFunction() == null && value.getAggregateExpression() == null); boolean isBuiltin = (value.getAggregateFunction() != null && !value.getAggregateFunction().isEmpty()); boolean isCustom = (value.getAggregateExpression() != null && !value.getAggregateExpression().isEmpty()) || (value.getExpressionContainer() != null); return isDefault || (isBuiltin && !isCustom) || (isCustom && !isBuiltin); }  @Override void initialize(CheckAggregateDefinition constraintAnnotation); @Override boolean isValid(ClientQueryAggregatedField value, ConstraintValidatorContext context); @Override ErrorDescriptor build(ConstraintViolation violation);  }### Answer:
@Test public void isValidAggregate_true_without_AggregateFunction() { ClientQueryAggregatedField instance = new ClientQueryAggregatedField(); assertTrue(validator.isValid(instance, context)); }
@Test public void isValidAggregate_true_with_ExpressionContainer_and_without_AggregateFunction() { ClientQueryAggregatedField instance = new ClientQueryAggregatedField() .setExpressionContainer(TEST_EXPRESSION_CONTAINER); assertTrue(validator.isValid(instance, context)); }
@Test public void isValidAggregate_true_without_ExpressionContainer_and_with_AggregateFunction() { ClientQueryAggregatedField instance = new ClientQueryAggregatedField() .setAggregateFunction(TEST_AGGREGATE_FUNCTION); assertTrue(validator.isValid(instance, context)); }
@Test public void isValidAggregate_false_with_ExpressionContainer_and_with_AggregateFunction() { ClientQueryAggregatedField instance = new ClientQueryAggregatedField() .setAggregateFunction(TEST_AGGREGATE_FUNCTION) .setExpressionContainer(TEST_EXPRESSION_CONTAINER); assertFalse(validator.isValid(instance, context)); }
@Test public void isValidAggregate_true_with_empty_in_ExpressionContainer_and_without_AggregateExpression() { ClientQueryAggregatedField instance = new ClientQueryAggregatedField() .setExpressionContainer(new ClientExpressionContainer("")); assertTrue(validator.isValid(instance, context)); }
@Test public void isValidAggregate_true_with_nonEmpty_in_ExpressionContainer_and_without_AggregateExpression() { ClientQueryAggregatedField instance = new ClientQueryAggregatedField() .setExpressionContainer(new ClientExpressionContainer("TEST_STRING")); assertTrue(validator.isValid(instance, context)); }
@Test public void isValidAggregate_true_with_null_in_ExpressionContainer_and_without_AggregateExpression() { ClientQueryAggregatedField instance = new ClientQueryAggregatedField() .setExpressionContainer(new ClientExpressionContainer().setString(null)); assertTrue(validator.isValid(instance, context)); }
@Test public void isValidAggregate_true_without_ExpressionContainer_and_with_nonEmpty_AggregateFunction() { ClientQueryAggregatedField instance = new ClientQueryAggregatedField() .setAggregateFunction(TEST_AGGREGATE_FUNCTION); assertTrue(validator.isValid(instance, context)); }
@Test public void isValidAggregate_false_without_ExpressionContainer_and_with_Empty_AggregateFunction() { ClientQueryAggregatedField instance = new ClientQueryAggregatedField() .setAggregateFunction(""); assertFalse(validator.isValid(instance, context)); }