### Question:
HasSameItemsAsListMatcher extends TypeSafeDiagnosingMatcher<List<? extends T>> { @Factory public static <T> HasSameItemsAsListMatcher<T> hasSameItemsAsList(List<? extends T> correctList) { return new HasSameItemsAsListMatcher<>(correctList); } HasSameItemsAsListMatcher(List<? extends T> expect); HasSameItemsAsListMatcher<T> useWrapperFactory(WrapperFactory<T> wrapperFactory); HasSameItemsAsListMatcher<T> sameSorted(); @Override void describeTo(Description description); @Factory static HasSameItemsAsListMatcher<T> hasSameItemsAsList(List<? extends T> correctList);  }### Answer:
@Test public void listNotSameOrderButEqual() throws Exception { List<String> actual = asList("1", "2", "3"); List<String> expected = asList("3", "2", "1"); assertThat(actual, HasSameItemsAsListMatcher.hasSameItemsAsList(expected)); }
@Test(expected = AssertionError.class) public void listNotEqualSortedAndContainsNewItems() throws Exception { List<Integer> actual = asList(1, 2, 3, 4); List<Integer> expected = asList(3, 2, 1); assertThat(actual, HasSameItemsAsListMatcher.hasSameItemsAsList(expected)); }
@Test(expected = AssertionError.class) public void listNotEqualSortedAndNotContainsSomeItems() throws Exception { List<String> actual = asList("1", "2", "3"); List<String> expected = asList("3", "2", "1", "4"); assertThat(actual, HasSameItemsAsListMatcher.hasSameItemsAsList(expected)); }
@Test(expected = AssertionError.class) public void actualListHasLastItemTwice() throws Exception { List<String> actual = asList("1", "2", "3", "3"); List<String> expected = asList("1", "2", "3"); assertThat(actual, HasSameItemsAsListMatcher.hasSameItemsAsList(expected)); }
@Test(expected = AssertionError.class) public void actualListHasNotLastItemTwice() throws Exception { List<String> actual = asList("1", "2", "2", "3"); List<String> expected = asList("1", "2", "3"); assertThat(actual, HasSameItemsAsListMatcher.hasSameItemsAsList(expected)); }
@Test(expected = AssertionError.class) public void expectedListHasNotLastItemTwice() throws Exception { List<String> actual = asList("1", "2", "3"); List<String> expected = asList("1", "2", "2", "3"); assertThat(actual, HasSameItemsAsListMatcher.hasSameItemsAsList(expected)); }