Search in sources :

Example 6 with Person

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);
}
Also used : Person(jakarta.nosql.tck.entities.Person) ColumnDeleteQuery(jakarta.nosql.column.ColumnDeleteQuery) Test(org.junit.jupiter.api.Test)

Example 7 with Person

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());
}
Also used : Field(java.lang.reflect.Field) Person(jakarta.nosql.tck.entities.Person) Test(org.junit.jupiter.api.Test)

Example 8 with Person

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);
}
Also used : Field(java.lang.reflect.Field) Person(jakarta.nosql.tck.entities.Person) Test(org.junit.jupiter.api.Test)

Example 9 with Person

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);
}
Also used : Person(jakarta.nosql.tck.entities.Person) Test(org.junit.jupiter.api.Test)

Example 10 with Person

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());
}
Also used : ColumnQuery(jakarta.nosql.column.ColumnQuery) Column(jakarta.nosql.column.Column) Person(jakarta.nosql.tck.entities.Person) ColumnCondition(jakarta.nosql.column.ColumnCondition) 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