Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -810,4 +810,19 @@ public void attributeNotExistAttributeAnnotationWords() {
private <T> Set<T> set(T... ts) {
return Set.of(ts);
}

@Test(expected = NoSuchElementException.class)
public void first_throwsNoSuchElementException_whenNoElements() {
createExampleElementQuery().first();
}

@Test(expected = NoSuchElementException.class)
public void last_throwsNoSuchElementException_whenNoElements() {
createExampleElementQuery().last();
}

@Test(expected = NoSuchElementException.class)
public void get_throwsNoSuchElementException_whenNoElements() {
createExampleElementQuery().get(0);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -1241,6 +1241,9 @@ public T waitForFirst(long timeOutInSeconds) {
*/
public T last() {
List<T> all = all();
if (all.isEmpty()) {
throw new NoSuchElementException(getNoSuchElementMessage(null));
}
return all.get(all.size() - 1);
}

Expand Down