AbstractSimpleComparableMatcher extends AbstractSimpleMatcher { @Override protected final boolean matches(Parameter parameter, Object actual, Object expected) { if (!(actual instanceof Comparable) || !(expected instanceof Comparable)) { throw new InvalidArgumentException("Expected property to be comparable: " + parameter.getPath()); } return matches((Comparable) actual, (Comparable) expected); }    }
@Test(expectedExceptions = InvalidArgumentException.class, expectedExceptionsMessageRegExp = ".*x.y.z.*") public void testWhenActualIsNotComparable() { final NotMatchingSimpleComparableMatcher matcher = new NotMatchingSimpleComparableMatcher(); matcher.matches(new ImmutableParameter("x.y.z", null, null, null), new Object(), 2); }
@Test(expectedExceptions = InvalidArgumentException.class, expectedExceptionsMessageRegExp = ".*x.y.z.*") public void testWhenPivotIsNotComparable() { final NotMatchingSimpleComparableMatcher matcher = new NotMatchingSimpleComparableMatcher(); matcher.matches(new ImmutableParameter("x.y.z", null, null, null), 1, new Object()); }
@Test public void testWhenBothAreComparable() { final NotMatchingSimpleComparableMatcher matcher = new NotMatchingSimpleComparableMatcher(); matcher.matches(new ImmutableParameter("x.y.z", null, null, null), 1, 2); }