Search in sources :

Example 1 with Person

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));
}
Also used : Pagination(jakarta.nosql.mapping.Pagination) Person(org.eclipse.jnosql.mapping.graph.model.Person) Test(org.junit.jupiter.api.Test)

Example 2 with Person

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());
}
Also used : Pagination(jakarta.nosql.mapping.Pagination) Person(org.eclipse.jnosql.mapping.graph.model.Person) HashSet(java.util.HashSet) Test(org.junit.jupiter.api.Test)

Example 3 with Person

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));
}
Also used : Pagination(jakarta.nosql.mapping.Pagination) Person(org.eclipse.jnosql.mapping.graph.model.Person) Test(org.junit.jupiter.api.Test)

Example 4 with Person

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()));
}
Also used : Pagination(jakarta.nosql.mapping.Pagination) Person(org.eclipse.jnosql.mapping.graph.model.Person) Test(org.junit.jupiter.api.Test)

Example 5 with Person

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()));
}
Also used : Vertex(org.apache.tinkerpop.gremlin.structure.Vertex) Person(org.eclipse.jnosql.mapping.graph.model.Person) Test(org.junit.jupiter.api.Test)

Aggregations

Person (org.eclipse.jnosql.mapping.graph.model.Person)74 Test (org.junit.jupiter.api.Test)71 Book (org.eclipse.jnosql.mapping.graph.model.Book)27 Vertex (org.apache.tinkerpop.gremlin.structure.Vertex)10 Pagination (jakarta.nosql.mapping.Pagination)7 Edge (org.apache.tinkerpop.gremlin.structure.Edge)5 Animal (org.eclipse.jnosql.mapping.graph.model.Animal)5 PreparedStatement (jakarta.nosql.mapping.PreparedStatement)4 Arrays (java.util.Arrays)4 List (java.util.List)4 Collectors (java.util.stream.Collectors)4 Graph (org.apache.tinkerpop.gremlin.structure.Graph)4 MatcherAssert (org.hamcrest.MatcherAssert)4 Matchers (org.hamcrest.Matchers)4 Assertions.assertEquals (org.junit.jupiter.api.Assertions.assertEquals)4 Converters (jakarta.nosql.mapping.Converters)3 Repository (jakarta.nosql.mapping.Repository)3 CDIExtension (jakarta.nosql.tck.test.CDIExtension)3 Method (java.lang.reflect.Method)3 Stream (java.util.stream.Stream)3