Last active
February 15, 2017 10:30
-
-
Save sujeet100/114b739ce7012e4f29bcf722417fda3e 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
//Scala | |
assert(books.filter{_.numberOfPages > 100}.take(2) == List(new Book("Refactoring", "Martin", 300), new Book("Extreme Programming", "Bob", 200))) | |
//Java 8 | |
assertThat(books.stream() | |
.filter(book -> book.getNumberOfPages() > 100) | |
.limit(2) | |
.collect(Collectors.toList()) | |
, is(Arrays.asList(new Book("Refactoring", "Martin", 300), new Book("Extreme Programming", "Bob", 200)))); | |
//Groovy | |
assert books.findAll{ it.numberOfPages > 100 }.take(2) == [new Book("Refactoring", "Martin", 300), new Book("Extreme Programming", "Bob", 200)] | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment