Created
December 27, 2016 23:15
-
-
Save upkarlidder/a2c7c2e17c62e0aff1248432dee2a2ee to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static Matcher<List<Book>> containsTitle(final String title){ | |
return new BaseMatcher<List<Book>>() { | |
@Override | |
public boolean matches(Object item) { | |
List<Book> books = (List<Book>) item; | |
List<Book> booksFiltered = books.stream() | |
.filter(b -> b.getTitle().equalsIgnoreCase(title)) | |
.collect(Collectors.toList()); | |
return !booksFiltered.isEmpty(); | |
} | |
@Override | |
public void describeTo(Description description) { | |
description.appendText("The books list does not contain ").appendText(title); | |
} | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment