@Test
  public void testAddPatternConstraint() throws Exception {
    final String message = "Message";
    getShell()
        .execute(
            CONSTRAINT_PLUGIN_NAME
                + " Pattern --onProperty "
                + PROPERTY_NAME
                + " --regexp [a-z]* --message "
                + message);
    getShell()
        .execute(
            CONSTRAINT_PLUGIN_NAME
                + " Pattern --onProperty "
                + PROPERTY_NAME
                + " --regexp [a-z]* --onAccessor");

    final JavaClass fooClass = getJavaClassFromResource(getShell().getCurrentResource());
    final Field<JavaClass> property = fooClass.getField(PROPERTY_NAME);

    assertNotNull(property);
    assertTrue(property.hasAnnotation(Pattern.class));
    assertEquals("[a-z]*", property.getAnnotation(Pattern.class).getStringValue("regexp"));
    assertEquals(message, property.getAnnotation(Pattern.class).getStringValue("message"));
    assertEquals(null, property.getAnnotation(Pattern.class).getStringValue("flags"));

    final Method<JavaClass> accessor = fooClass.getMethod(PROPERTY_ACESSOR_NAME);

    assertNotNull(accessor);
    assertTrue(accessor.hasAnnotation(Pattern.class));
    assertEquals("[a-z]*", accessor.getAnnotation(Pattern.class).getStringValue("regexp"));
  }
  @Test
  public void testAddDigitsConstraint() throws Exception {
    final String message = "Message";
    getShell()
        .execute(
            CONSTRAINT_PLUGIN_NAME
                + " Digits --onProperty "
                + PROPERTY_NAME
                + " --integer 3 --fraction 4 --message "
                + message);
    getShell()
        .execute(
            CONSTRAINT_PLUGIN_NAME
                + " Digits --onProperty "
                + PROPERTY_NAME
                + " --integer 4 --fraction 3 --onAccessor");

    final JavaClass fooClass = getJavaClassFromResource(getShell().getCurrentResource());
    final Field<JavaClass> property = fooClass.getField(PROPERTY_NAME);

    assertNotNull(property);
    assertTrue(property.hasAnnotation(Digits.class));
    assertEquals("3", property.getAnnotation(Digits.class).getLiteralValue("integer"));
    assertEquals("4", property.getAnnotation(Digits.class).getLiteralValue("fraction"));
    assertEquals(message, property.getAnnotation(Digits.class).getStringValue("message"));

    final Method<JavaClass> accessor = fooClass.getMethod(PROPERTY_ACESSOR_NAME);

    assertNotNull(accessor);
    assertTrue(accessor.hasAnnotation(Digits.class));
    assertEquals("4", accessor.getAnnotation(Digits.class).getLiteralValue("integer"));
    assertEquals("3", accessor.getAnnotation(Digits.class).getLiteralValue("fraction"));
  }
  @Test
  public void testAddValidConstraint() throws Exception {
    getShell().execute(CONSTRAINT_PLUGIN_NAME + " Valid --onProperty " + PROPERTY_NAME);
    getShell()
        .execute(CONSTRAINT_PLUGIN_NAME + " Valid --onProperty " + PROPERTY_NAME + " --onAccessor");

    final JavaClass fooClass = getJavaClassFromResource(getShell().getCurrentResource());
    final Field<JavaClass> property = fooClass.getField(PROPERTY_NAME);

    assertNotNull(property);
    assertTrue(property.hasAnnotation(Valid.class));

    final Method<JavaClass> accessor = fooClass.getMethod(PROPERTY_ACESSOR_NAME);

    assertNotNull(accessor);
    assertTrue(accessor.hasAnnotation(Valid.class));
  }