Search in sources :

Example 61 with Person

use of jakarta.nosql.tck.entities.Person in project jnosql-diana by eclipse.

the class ColumnPageTest method shouldExecutePagination.

@Test
public void shouldExecutePagination() {
    Pagination pagination = Pagination.page(1).size(1);
    ColumnQueryPagination query = ColumnQueryPagination.of(select().from("person").build(), pagination);
    Page<Person> page = subject.select(query);
    verify(managerMock).select(query);
    assertNotNull(page);
    assertEquals(pagination, page.getPagination());
}
Also used : Pagination(jakarta.nosql.mapping.Pagination) ColumnQueryPagination(jakarta.nosql.mapping.column.ColumnQueryPagination) ColumnQueryPagination(jakarta.nosql.mapping.column.ColumnQueryPagination) Person(jakarta.nosql.tck.entities.Person) Test(org.junit.jupiter.api.Test)

Example 62 with Person

use of jakarta.nosql.tck.entities.Person in project jnosql-diana by eclipse.

the class ColumnPageTest method shouldReturnNPEWhenCollectionFactoryIsNull.

@Test
public void shouldReturnNPEWhenCollectionFactoryIsNull() {
    Pagination pagination = Pagination.page(1).size(1);
    Page<Person> page = createPage(pagination);
    assertThrows(NullPointerException.class, () -> page.getContent(null));
}
Also used : Pagination(jakarta.nosql.mapping.Pagination) ColumnQueryPagination(jakarta.nosql.mapping.column.ColumnQueryPagination) Person(jakarta.nosql.tck.entities.Person) Test(org.junit.jupiter.api.Test)

Example 63 with Person

use of jakarta.nosql.tck.entities.Person in project jnosql-diana by eclipse.

the class DocumentRepositoryProxyTest method shouldSaveIterable.

@Test
public void shouldSaveIterable() {
    when(personRepository.findById(10L)).thenReturn(Optional.empty());
    when(template.singleResult(Mockito.any(DocumentQuery.class))).thenReturn(Optional.empty());
    ArgumentCaptor<Person> captor = ArgumentCaptor.forClass(Person.class);
    Person person = Person.builder().withName("Ada").withId(10L).withPhones(singletonList("123123")).build();
    personRepository.save(singletonList(person));
    verify(template).insert(captor.capture());
    verify(template).insert(captor.capture());
    Person personCapture = captor.getValue();
    assertEquals(person, personCapture);
}
Also used : DocumentQuery(jakarta.nosql.document.DocumentQuery) Person(jakarta.nosql.tck.entities.Person) Test(org.junit.jupiter.api.Test)

Example 64 with Person

use of jakarta.nosql.tck.entities.Person in project jnosql-diana by eclipse.

the class DocumentRepositoryProxyTest method shouldSaveUsingUpdateWhenDataExists.

@Test
public void shouldSaveUsingUpdateWhenDataExists() {
    when(template.find(Mockito.eq(Person.class), Mockito.eq(10L))).thenReturn(Optional.of(Person.builder().build()));
    ArgumentCaptor<Person> captor = ArgumentCaptor.forClass(Person.class);
    Person person = Person.builder().withName("Ada").withId(10L).withPhones(singletonList("123123")).build();
    assertNotNull(personRepository.save(person));
    verify(template).update(captor.capture());
    Person value = captor.getValue();
    assertEquals(person, value);
}
Also used : Person(jakarta.nosql.tck.entities.Person) Test(org.junit.jupiter.api.Test)

Example 65 with Person

use of jakarta.nosql.tck.entities.Person in project jnosql-diana by eclipse.

the class DocumentRepositoryProxyTest method shouldFindByAgeANDName.

@Test
public void shouldFindByAgeANDName() {
    Person ada = Person.builder().withAge(20).withName("Ada").build();
    when(template.select(Mockito.any(DocumentQuery.class))).thenReturn(Stream.of(ada));
    Set<Person> persons = personRepository.findByAgeAndName(20, "name");
    ArgumentCaptor<DocumentQuery> captor = ArgumentCaptor.forClass(DocumentQuery.class);
    verify(template).select(captor.capture());
    assertThat(persons, Matchers.contains(ada));
}
Also used : DocumentQuery(jakarta.nosql.document.DocumentQuery) Person(jakarta.nosql.tck.entities.Person) Test(org.junit.jupiter.api.Test)

Aggregations

Person (jakarta.nosql.tck.entities.Person)201 Test (org.junit.jupiter.api.Test)197 DocumentQuery (jakarta.nosql.document.DocumentQuery)50 ColumnQuery (jakarta.nosql.column.ColumnQuery)49 Pagination (jakarta.nosql.mapping.Pagination)42 List (java.util.List)32 AtomicReference (java.util.concurrent.atomic.AtomicReference)29 ColumnCondition (jakarta.nosql.column.ColumnCondition)17 DocumentCondition (jakarta.nosql.document.DocumentCondition)17 Collections.singletonList (java.util.Collections.singletonList)14 Optional (java.util.Optional)13 Arrays.asList (java.util.Arrays.asList)12 ColumnDeleteQuery (jakarta.nosql.column.ColumnDeleteQuery)11 DocumentDeleteQuery (jakarta.nosql.document.DocumentDeleteQuery)11 ColumnQueryPagination (jakarta.nosql.mapping.column.ColumnQueryPagination)9 DocumentQueryPagination (jakarta.nosql.mapping.document.DocumentQueryPagination)9 Duration (java.time.Duration)8 ColumnEntity (jakarta.nosql.column.ColumnEntity)7 DocumentEntity (jakarta.nosql.document.DocumentEntity)7 ArrayList (java.util.ArrayList)7