Skip to content

Commit

Permalink
test: create mock to avoid NPE at graph
Browse files Browse the repository at this point in the history
Signed-off-by: Otavio Santana <otaviopolianasantana@gmail.com>
  • Loading branch information
otaviojava committed Nov 18, 2023
1 parent 0049cd1 commit 0452723
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public Graph getGraphMock() {
when(vertex.keys()).thenReturn(singleton("name"));
when(vertex.value("name")).thenReturn("nameMock");
when(graphMock.addVertex(Mockito.anyString())).thenReturn(vertex);

when(graphMock.vertices(Mockito.any())).thenReturn(Collections.emptyIterator());
return graphMock;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import org.apache.tinkerpop.gremlin.structure.Vertex;
import org.eclipse.jnosql.communication.Settings;

import java.util.Collections;
import java.util.Iterator;
import java.util.Optional;

Expand Down Expand Up @@ -51,7 +52,7 @@ public GraphComputer compute() throws IllegalArgumentException {

@Override
public Iterator<Vertex> vertices(Object... vertexIds) {
return null;
return Collections.emptyIterator();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ void shouldSave() {

@Test
void shouldInjectRepository() {
repositoryMock.save(Book.builder().withName("book").build());
repositoryMock.save(Book.builder().withName("book").withAge(12).build());
assertNotNull(repository.findById("10"));
}

Expand Down

0 comments on commit 0452723

Please sign in to comment.