AbstractBinaryComparableMatcher extends AbstractBinaryMatcher { @Override protected final boolean matches(Parameter parameter, Object value, Object first, Object second) { if (!(value instanceof Comparable) || !(first instanceof Comparable) || !(second instanceof Comparable)) { throw new InvalidArgumentException("Expected values to be comparable: " + parameter.getPath()); } return matches((Comparable) value, (Comparable) first, (Comparable) second); }    }
@Test(expectedExceptions = InvalidArgumentException.class, expectedExceptionsMessageRegExp = ".*x.y.z.*") public void testWhenValueIsNotComparable() { final NotMatchingBinaryComparableMatcher matcher = new NotMatchingBinaryComparableMatcher(); matcher.matches(new ImmutableParameter("x.y.z", null, null, null), new Object(), 1, 2); }
@Test(expectedExceptions = InvalidArgumentException.class, expectedExceptionsMessageRegExp = ".*x.y.z.*") public void testWhenFirstParameterIsNotComparable() { final NotMatchingBinaryComparableMatcher matcher = new NotMatchingBinaryComparableMatcher(); matcher.matches(new ImmutableParameter("x.y.z", null, null, null), 1, new Object(), 2); }
@Test(expectedExceptions = InvalidArgumentException.class, expectedExceptionsMessageRegExp = ".*x.y.z.*") public void testWhenSecondParameterIsNotComparable() { final NotMatchingBinaryComparableMatcher matcher = new NotMatchingBinaryComparableMatcher(); matcher.matches(new ImmutableParameter("x.y.z", null, null, null), 1, 2, new Object()); }
@Test public void testWhenAllAreComparable() { final NotMatchingBinaryComparableMatcher matcher = new NotMatchingBinaryComparableMatcher(); matcher.matches(new ImmutableParameter("x.y.z", null, null, null), 1, 2, 3); }