Search in sources :

Example 96 with Person

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

the class DefaultDocumentMapperSelectBuilderTest method shouldConvertField.

@Test
public void shouldConvertField() {
    DocumentQuery query = mapperBuilder.selectFrom(Person.class).where("id").eq("20").build();
    DocumentQuery queryExpected = select().from("Person").where("_id").eq(20L).build();
    assertEquals(queryExpected, query);
}
Also used : DocumentQuery(jakarta.nosql.document.DocumentQuery) Person(jakarta.nosql.tck.entities.Person) Test(org.junit.jupiter.api.Test)

Example 97 with Person

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

the class MockProducer method getBucketManager.

@Produces
public BucketManager getBucketManager() {
    BucketManager bucketManager = Mockito.mock(BucketManager.class);
    Person person = Person.builder().withName("Default").build();
    when(bucketManager.get("key")).thenReturn(Optional.ofNullable(Value.of(person)));
    when(bucketManager.get(10L)).thenReturn(Optional.ofNullable(Value.of(person)));
    when(bucketManager.get("user")).thenReturn(Optional.of(Value.of(new User("Default", "Default", 10))));
    return bucketManager;
}
Also used : User(jakarta.nosql.tck.entities.User) BucketManager(jakarta.nosql.keyvalue.BucketManager) Person(jakarta.nosql.tck.entities.Person) Produces(javax.enterprise.inject.Produces)

Example 98 with Person

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

the class MockProducer method getBucketManagerMock.

@Produces
@Database(value = DatabaseType.KEY_VALUE, provider = "keyvalueMock")
public BucketManager getBucketManagerMock() {
    BucketManager bucketManager = Mockito.mock(BucketManager.class);
    Person person = Person.builder().withName("keyvalueMock").build();
    when(bucketManager.get("key")).thenReturn(Optional.ofNullable(Value.of(person)));
    when(bucketManager.get(10L)).thenReturn(Optional.ofNullable(Value.of(person)));
    when(bucketManager.get("user")).thenReturn(Optional.of(Value.of(new User("keyvalueMock", "keyvalueMock", 10))));
    return bucketManager;
}
Also used : User(jakarta.nosql.tck.entities.User) BucketManager(jakarta.nosql.keyvalue.BucketManager) Person(jakarta.nosql.tck.entities.Person) Produces(javax.enterprise.inject.Produces) Database(jakarta.nosql.mapping.Database)

Example 99 with Person

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

the class DocumentReactiveRepositoryProxyTest method shouldFindByNameANDAge.

@Test
public void shouldFindByNameANDAge() {
    Person ada = Person.builder().withAge(20).withName("Ada").build();
    when(template.select(Mockito.any(DocumentQuery.class))).thenReturn(Stream.of(ada));
    Publisher<Person> publisher = personRepository.findByNameAndAge("name", 20);
    final CompletionSubscriber<Person, List<Person>> subscriber = ReactiveStreams.<Person>builder().toList().build();
    publisher.subscribe(subscriber);
    AtomicReference<List<Person>> reference = new AtomicReference<>();
    final CompletionStage<List<Person>> completion = subscriber.getCompletion();
    completion.thenAccept(reference::set);
    final List<Person> people = reference.get();
    Assertions.assertNotNull(people);
    ArgumentCaptor<DocumentQuery> captor = ArgumentCaptor.forClass(DocumentQuery.class);
    verify(template).select(captor.capture());
    assertThat(people, Matchers.contains(ada));
}
Also used : DocumentQuery(jakarta.nosql.document.DocumentQuery) Collections.singletonList(java.util.Collections.singletonList) Arrays.asList(java.util.Arrays.asList) List(java.util.List) AtomicReference(java.util.concurrent.atomic.AtomicReference) Person(jakarta.nosql.tck.entities.Person) Test(org.junit.jupiter.api.Test)

Example 100 with Person

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

the class DefaultReactiveKeyValueTemplateTest method shouldPutIterable.

@Test
public void shouldPutIterable() {
    List<Person> people = new ArrayList<>();
    Person ada = Person.builder().withId(1L).withAge(30).withName("Ada").build();
    List<Person> adas = Arrays.asList(ada, ada);
    Mockito.when(template.put(adas)).thenReturn(adas);
    final Observable<Person> observable = manager.put(adas);
    CompletionSubscriber<Person, Void> subscriber = ReactiveStreams.<Person>builder().forEach(people::add).build();
    Mockito.verify(template, Mockito.never()).put(adas);
    observable.subscribe(subscriber);
    MatcherAssert.assertThat(people, Matchers.containsInAnyOrder(ada, ada));
    Mockito.verify(template).put(adas);
}
Also used : ArrayList(java.util.ArrayList) 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