use of org.eclipse.jnosql.mapping.graph.model.Person in project jnosql-diana by eclipse.
the class GraphPageTest method shouldRequestPageTwice.
@Test
public void shouldRequestPageTwice() {
Pagination pagination = Pagination.page(1).size(1);
Page<Person> page = template.getTraversalVertex().orderBy("name").desc().page(pagination);
List<Person> people = page.getContent().collect(Collectors.toList());
assertFalse(people.isEmpty());
assertNotNull(page.getContent(ArrayList::new));
assertNotNull(page.getContent(HashSet::new));
}
use of org.eclipse.jnosql.mapping.graph.model.Person in project jnosql-diana by eclipse.
the class GraphPageTest method shouldReturnCollectionFromCollectionFactory.
@Test
public void shouldReturnCollectionFromCollectionFactory() {
Pagination pagination = Pagination.page(1).size(1);
Page<Person> page = template.getTraversalVertex().orderBy("name").desc().page(pagination);
assertNotNull(page);
Set<Person> people = page.getContent(HashSet::new);
Person first = template.getTraversalVertex().orderBy("name").desc().<Person>getResult().findFirst().get();
assertEquals(pagination, page.getPagination());
assertEquals(1, people.size());
}
use of org.eclipse.jnosql.mapping.graph.model.Person in project jnosql-diana by eclipse.
the class GraphPageTest method shouldReturnErrorWhenCollectionFactoryIsNull.
@Test
public void shouldReturnErrorWhenCollectionFactoryIsNull() {
Pagination pagination = Pagination.page(1).size(1);
Page<Person> page = template.getTraversalVertex().orderBy("name").desc().page(pagination);
assertNotNull(page);
assertThrows(NullPointerException.class, () -> page.getContent(null));
}
use of org.eclipse.jnosql.mapping.graph.model.Person in project jnosql-diana by eclipse.
the class GraphPageTest method shouldNext.
@Test
public void shouldNext() {
Pagination pagination = Pagination.page(1).size(1);
Page<Person> page = template.getTraversalVertex().orderBy("name").asc().page(pagination);
assertNotNull(page);
Stream<Person> people = page.get();
assertEquals(pagination, page.getPagination());
assertEquals(otavio.getName(), people.map(Person::getName).collect(joining()));
pagination = pagination.next();
page = page.next();
people = page.get();
assertEquals(pagination, page.getPagination());
assertEquals(paulo.getName(), people.map(Person::getName).collect(joining()));
pagination = pagination.next();
page = page.next();
people = page.get();
assertEquals(pagination, page.getPagination());
assertEquals(poliana.getName(), people.map(Person::getName).collect(joining()));
}
use of org.eclipse.jnosql.mapping.graph.model.Person in project jnosql-diana by eclipse.
the class AbstractGraphConverterTest method shouldReturnToEntityInstance.
@Test
public void shouldReturnToEntityInstance() {
Vertex vertex = getGraph().addVertex(T.label, "Person", "age", 22, "name", "Ada");
Person person = Person.builder().build();
Person result = getConverter().toEntity(person, vertex);
assertSame(person, result);
assertNotNull(person.getId());
assertEquals("Ada", person.getName());
assertEquals(Integer.valueOf(22), Integer.valueOf(person.getAge()));
}
Aggregations