ConsistentRangeConstraintValidator implements
        Validator<ConsistentRangeConstraint> { @Override public boolean isValid(Object value) { if (value instanceof Port) { Port port = (Port) value; Integer from = port.getFrom(); Integer to = port.getTo(); return (from == null && to == null) || (from != null && to != null); } return false; }  @Override void initialize(ConsistentRangeConstraint parameters); @Override boolean isValid(Object value);  }
@Test public void isValidParametarNotFile() { assertFalse("string object is valid.", validator .isValid("a string object")); }
@Test public void isValid() { Port port = new Port(); port.setFrom(null); port.setTo(null); assertTrue(validator.isValid(port)); }
@Test public void isValid2() { Port port = new Port(); port.setFrom(2); port.setTo(2); assertTrue(validator.isValid(port)); }
@Test public void isValid3() { Port port = new Port(); port.setFrom(null); port.setTo(2); assertFalse(validator.isValid(port)); }
@Test public void isValid4() { Port port = new Port(); port.setFrom(2); port.setTo(null); assertFalse(validator.isValid(port)); }