/** Testing Preparer with empty constraint. Expect: nothing changes. */
 @Test
 public void testPreparerWithEmptyConstraint() throws InterceptorException {
   final AttributeConstraintModel constraint = new AttributeConstraintModel();
   preparer.onPrepare(constraint, null);
   assertNull(constraint.getTarget());
   assertNull(constraint.getType());
   assertNull(constraint.getAnnotation());
   assertNull(constraint.getQualifier());
 }
  /**
   * Testing preparer, descriptor is set, other attributes filled with dummy data. Expect:
   * descriptor overwrites all other fields.
   */
  @Test
  public void testPreparerWithAttributeDescriptorOnly() throws InterceptorException {
    final AttributeConstraintModel constraint = new AttributeConstraintModel();
    constraint.setDescriptor(prodModCodeAD);
    constraint.setAnnotation(Min.class);
    constraint.setType(new ComposedTypeModel());
    constraint.setTarget(LanguageModel.class);
    constraint.setQualifier("xxx");

    final ProductModel productModel = new ProductModel();
    expect(modelService.create(prodModCT.getCode())).andReturn(productModel);
    modelService.detach(productModel);
    expectLastCall();

    replay(modelService);
    preparer.onPrepare(constraint, null);
    verify(modelService);

    assertEquals(ProductModel.class, constraint.getTarget());
    assertEquals(prodModCT, constraint.getType());
    assertEquals(Min.class, constraint.getAnnotation());
    assertEquals("code", constraint.getQualifier());
  }