/** **** */
  private CustomerModel createCustomerModel() {

    final CustomerModel customer = new CustomerModel();

    customer.setName(NAME);
    customer.setUid(DEFAULT_EMAIL);

    final TitleModel titleModel = new TitleModel();
    titleModel.setCode(TITLE);
    customer.setTitle(titleModel);

    return customer;
  }
  /**
   * runtime exception are not affecting validation flag
   *
   * @throws Exception
   */
  @Test
  public void testCheckBSHRuntimeException() throws Exception {
    final DynamicConstraintModel constraint = modelService.create(DynamicConstraintModel.class);
    constraint.setId("dynaOne");
    constraint.setLanguage(ValidatorLanguage.BEANSHELL);
    final ComposedTypeModel titleModel = typeService.getComposedType(TitleModel.class);
    constraint.setType(titleModel);
    constraint.setExpression("return getCode().equals(getName().length());");

    modelService.save(constraint);
    validationService.reloadValidationEngine();
    Assert.assertEquals(constraint.getAnnotation(), Dynamic.class);
    final TitleModel title = modelService.create(TitleModel.class);
    title.setCode("someCode");
    modelService.save(title);
  }
  /**
   * inappropriate BSH script syntax
   *
   * @throws Exception
   */
  @Test
  public void testCheckInvalidBSH() throws Exception {
    final DynamicConstraintModel constraint = modelService.create(DynamicConstraintModel.class);
    constraint.setId("dynaOne");
    constraint.setLanguage(ValidatorLanguage.BEANSHELL);
    final ComposedTypeModel titleModel = typeService.getComposedType(TitleModel.class);
    constraint.setType(titleModel);
    constraint.setExpression("return getCode().equals11111(getName());");

    modelService.save(constraint);

    validationService.reloadValidationEngine();

    Assert.assertEquals(constraint.getAnnotation(), Dynamic.class);

    final TitleModel title = modelService.create(TitleModel.class);

    title.setCode("someCode");
    try {
      modelService.save(title);
    } catch (final Exception e) {
      checkException(e, ModelSavingException.class, ValidationViolationException.class, null);
    }
  }