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());
}
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));
}
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);
}
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);
}
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));
}
Aggregations