EqualConstraint extends AbstractPropertyConstraint implements IMatchPropertyConstraint { @Override public void validate(Object propertyValue) throws ConstraintViolationException { if (propertyValue == null) { if (typed != null) { fail(propertyValue); } } else if (typed == null) { fail(propertyValue); } else if (!typed.equals(propertyValue)) { fail(propertyValue); } }  @Override void initialize(IPropertyType<?> propertyType); @Override void setConstraintValue(IPropertyType<?> toscaType, String textValue); @Override void validate(Object propertyValue);  }
@Test public void testEqualConstraintSatisfiedNull() throws ConstraintViolationException { EqualConstraint constraint = new EqualConstraint(); constraint.setEqual(null); constraint.validate(null); }
@Test(expected = ConstraintViolationException.class) public void testEqualConstraintFailNullProperty() throws ConstraintViolationException { EqualConstraint constraint = new EqualConstraint(); constraint.setEqual(null); constraint.validate("value"); }
@Test(expected = ConstraintViolationException.class) public void testEqualConstraintFailNullDef() throws ConstraintViolationException { EqualConstraint constraint = new EqualConstraint(); constraint.setEqual(null); constraint.validate("value"); }
@Test(expected = ConstraintViolationException.class) public void testEqualConstraintFailString() throws ConstraintViolationException { EqualConstraint constraint = new EqualConstraint(); constraint.setEqual("value"); constraint.validate("othervalue"); }