HasToStringContaining { public static <T> Matcher<T> hasToStringContainingInOrder(final Object... items) { final List<String> strings = new ArrayList<>(); for (final Object item : items) { strings.add(item.toString()); } return hasToString(stringContainsInOrder(strings)); } private  HasToStringContaining(); static Matcher<T> hasToStringContainingInOrder(final Object... items);  }
@Test public void testHasToStringContainingInOrderSuccessOnCorrectOrder() throws Exception { final UUID id = UUID.randomUUID(); final String field = "A value"; final Date date = new Date(); final AClass aClass = AClass.builder().id(id).field(field).date(date).build(); assertThat(aClass, hasToStringContainingInOrder(id, field, date)); }
@Test public void testHasToStringContainingInOrderFailsOnWrongOrder() throws Exception { final UUID id = UUID.randomUUID(); final String field = "A value"; final Date date = new Date(); final AClass aClass = AClass.builder().id(id).field(field).date(date).build(); assertThat(aClass, not(hasToStringContainingInOrder(field, id, date))); }