use of jakarta.nosql.tck.entities.Person in project jnosql-diana by eclipse.
the class DefaultColumnMapperDeleteBuilderTest method shouldSelectWhereNameLike.
@Test
public void shouldSelectWhereNameLike() {
ColumnDeleteQuery query = mapperBuilder.deleteFrom(Person.class).where("name").like("Ada").build();
ColumnDeleteQuery queryExpected = delete().from("Person").where("name").like("Ada").build();
assertEquals(queryExpected, query);
}
use of jakarta.nosql.tck.entities.Person in project jnosql-diana by eclipse.
the class ReflectionFieldWriterFactoryTest method shouldRead.
@Test
public void shouldRead() {
Person person = Person.builder().build();
Field[] fields = Person.class.getDeclaredFields();
Stream.of(fields).forEach(f -> f.setAccessible(true));
Field id = Stream.of(fields).filter(f -> f.getName().equals("id")).findFirst().get();
Field name = Stream.of(fields).filter(f -> f.getName().equals("name")).findFirst().get();
Field age = Stream.of(fields).filter(f -> f.getName().equals("age")).findFirst().get();
Field phones = Stream.of(fields).filter(f -> f.getName().equals("phones")).findFirst().get();
writerFactory.apply(id).write(person, 10L);
writerFactory.apply(name).write(person, "Ada");
writerFactory.apply(age).write(person, 10);
writerFactory.apply(phones).write(person, singletonList("234234324"));
Assertions.assertEquals(10L, person.getId());
Assertions.assertEquals("Ada", person.getName());
Assertions.assertEquals(10, person.getAge());
Assertions.assertEquals(singletonList("234234324"), person.getPhones());
}
use of jakarta.nosql.tck.entities.Person in project jnosql-diana by eclipse.
the class ReflectionFieldWriterFactoryTest method shouldReturnFieldReader.
@Test
public void shouldReturnFieldReader() {
Person person = Person.builder().withId(10L).withAge(10).withName("Ada").withPhones(singletonList("234234324")).build();
Field[] fields = Person.class.getDeclaredFields();
Field id = Stream.of(fields).filter(f -> f.getName().equals("id")).findFirst().get();
FieldWriter writer = writerFactory.apply(id);
Assertions.assertNotNull(writer);
}
use of jakarta.nosql.tck.entities.Person in project jnosql-diana by eclipse.
the class ColumnRepositoryProxyTest method shouldSaveIterable.
@Test
public void shouldSaveIterable() {
when(personRepository.findById(10L)).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());
Person personCapture = captor.getValue();
assertEquals(person, personCapture);
}
use of jakarta.nosql.tck.entities.Person in project jnosql-diana by eclipse.
the class ColumnRepositoryProxyTest method shouldFindBySalary_Currency.
@Test
public void shouldFindBySalary_Currency() {
Person ada = Person.builder().withAge(20).withName("Ada").build();
when(template.select(any(ColumnQuery.class))).thenReturn(Stream.of(ada));
personRepository.findBySalary_Currency("USD");
ArgumentCaptor<ColumnQuery> captor = ArgumentCaptor.forClass(ColumnQuery.class);
verify(template).select(captor.capture());
ColumnQuery query = captor.getValue();
ColumnCondition condition = query.getCondition().get();
final Column column = condition.getColumn();
assertEquals("Person", query.getColumnFamily());
assertEquals("salary.currency", column.getName());
}
Aggregations