use of org.eclipse.jnosql.mapping.graph.model.Person in project jnosql-diana by eclipse.
the class AbstractGraphTemplateTest method shouldReturnErrorWhenGetEdgesHasNullDirection.
@Test
public void shouldReturnErrorWhenGetEdgesHasNullDirection() {
assertThrows(NullPointerException.class, () -> {
Person otavio = getGraphTemplate().insert(Person.builder().withAge().withName("Otavio").build());
getGraphTemplate().getEdges(otavio, null);
});
}
use of org.eclipse.jnosql.mapping.graph.model.Person in project jnosql-diana by eclipse.
the class AbstractGraphTemplateTest method shouldDeleteEntities.
@Test
public void shouldDeleteEntities() {
Person otavio = getGraphTemplate().insert(Person.builder().withAge().withName("Otavio").build());
Person poliana = getGraphTemplate().insert(Person.builder().withAge().withName("Poliana").build());
assertTrue(getGraphTemplate().find(otavio.getId()).isPresent());
getGraphTemplate().delete(Arrays.asList(otavio.getId(), poliana.getId()));
assertFalse(getGraphTemplate().find(otavio.getId()).isPresent());
assertFalse(getGraphTemplate().find(poliana.getId()).isPresent());
}
use of org.eclipse.jnosql.mapping.graph.model.Person in project jnosql-diana by eclipse.
the class AbstractGraphTemplateTest method shouldGetErrorWhenEntityIsNotSavedYet.
@Test
public void shouldGetErrorWhenEntityIsNotSavedYet() {
assertThrows(EntityNotFoundException.class, () -> {
Person person = Person.builder().withAge().withId(10L).withName("Otavio").build();
getGraphTemplate().update(person);
});
}
use of org.eclipse.jnosql.mapping.graph.model.Person in project jnosql-diana by eclipse.
the class AbstractGraphTemplateTest method shouldReturnErrorWhenGetEdgesHasNullId2.
@Test
public void shouldReturnErrorWhenGetEdgesHasNullId2() {
assertThrows(IllegalStateException.class, () -> {
Person otavio = Person.builder().withAge().withName("Otavio").build();
getGraphTemplate().getEdges(otavio, Direction.BOTH);
});
}
use of org.eclipse.jnosql.mapping.graph.model.Person in project jnosql-diana by eclipse.
the class AbstractGraphTemplateTest method shouldReturnEdges.
@Test
public void shouldReturnEdges() {
Person otavio = getGraphTemplate().insert(Person.builder().withAge().withName("Otavio").build());
Animal dog = getGraphTemplate().insert(new Animal("dog"));
Book cleanCode = getGraphTemplate().insert(Book.builder().withName("Clean code").build());
EdgeEntity likes = getGraphTemplate().edge(otavio, "likes", dog);
EdgeEntity reads = getGraphTemplate().edge(otavio, "reads", cleanCode);
Collection<EdgeEntity> edgesById = getGraphTemplate().getEdges(otavio, Direction.BOTH);
Collection<EdgeEntity> edgesById1 = getGraphTemplate().getEdges(otavio, Direction.BOTH, "reads");
Collection<EdgeEntity> edgesById2 = getGraphTemplate().getEdges(otavio, Direction.BOTH, () -> "likes");
Collection<EdgeEntity> edgesById3 = getGraphTemplate().getEdges(otavio, Direction.OUT);
Collection<EdgeEntity> edgesById4 = getGraphTemplate().getEdges(cleanCode, Direction.IN);
assertEquals(edgesById, edgesById3);
assertThat(edgesById, Matchers.containsInAnyOrder(likes, reads));
assertThat(edgesById1, containsInAnyOrder(reads));
assertThat(edgesById2, containsInAnyOrder(likes));
assertThat(edgesById4, containsInAnyOrder(reads));
}
Aggregations