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