Skip to content

Commit

Permalink
Updates document entity documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
otaviojava committed Mar 9, 2021
1 parent 10e83df commit ff24ab9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ static DocumentEntity of(String name, List<Document> documents) {
* @return a new instance converted to informed class
* @throws NullPointerException when there are null parameters
*/
<T> T find(String documentName, TypeSupplier<T> type);
<T> Optional<T> find(String documentName, TypeSupplier<T> type);

/**
* Returns the number of elements in this list.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import org.junit.jupiter.api.Test;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Optional;
Expand Down Expand Up @@ -126,7 +127,8 @@ public void shouldNotFindValue() {
public void shouldFindTypeSupplier() {
Document column = Document.of("name", "name");
DocumentEntity entity = DocumentEntity.of("entity", singletonList(column));
List<String> names = entity.find("name", new TypeReference<List<String>>() {});
List<String> names = entity.find("name", new TypeReference<List<String>>() {})
.orElse(Collections.emptyList());
Assertions.assertNotNull(names);
Assertions.assertFalse(names.isEmpty());
}
Expand All @@ -135,7 +137,8 @@ public void shouldFindTypeSupplier() {
public void shouldNotFindTypeSupplier() {
Document column = Document.of("name", "name");
DocumentEntity entity = DocumentEntity.of("entity", singletonList(column));
List<String> names = entity.find("not_found", new TypeReference<List<String>>() {});
List<String> names = entity.find("not_found", new TypeReference<List<String>>() {})
.orElse(Collections.emptyList());
Assertions.assertNotNull(names);
Assertions.assertTrue(names.isEmpty());
}
Expand Down

0 comments on commit ff24ab9

Please sign in to comment.