use of jakarta.nosql.document.DocumentCollectionManager in project jnosql-diana by eclipse.
the class DefaultDocumentTemplateProducerTest method shouldReturn.
@Test
public void shouldReturn() {
DocumentCollectionManager manager = Mockito.mock(DocumentCollectionManager.class);
DocumentTemplate documentTemplate = producer.get(manager);
assertNotNull(documentTemplate);
}
use of jakarta.nosql.document.DocumentCollectionManager in project jnosql-diana by eclipse.
the class DefaultDocumentRepositoryProducerTest method shouldCreateFromManager.
@Test
public void shouldCreateFromManager() {
DocumentCollectionManager manager = Mockito.mock(DocumentCollectionManager.class);
PersonRepository personRepository = producer.get(PersonRepository.class, manager);
assertNotNull(personRepository);
}
use of jakarta.nosql.document.DocumentCollectionManager in project jnosql-diana by eclipse.
the class ManagerProducerProducer method getDocumentCollectionManager.
@Produces
public DocumentCollectionManager getDocumentCollectionManager() {
DocumentCollectionManager collectionManager = Mockito.mock(DocumentCollectionManager.class);
DocumentEntity entity = DocumentEntity.of("person");
entity.add(Document.of("name", "Ada"));
entity.add(Document.of("age", 10));
entity.add(Document.of("salary", BigDecimal.TEN));
entity.add(Document.of("phones", singletonList("22342342")));
when(collectionManager.insert(Mockito.any(DocumentEntity.class))).thenReturn(entity);
when(collectionManager.update(Mockito.any(DocumentEntity.class))).thenReturn(entity);
return collectionManager;
}
use of jakarta.nosql.document.DocumentCollectionManager in project jnosql-diana by eclipse.
the class DefaultDeleteQueryBuilderTest method shouldExecuteDelete.
@Test
public void shouldExecuteDelete() {
String collection = "collection";
DocumentCollectionManager manager = mock(DocumentCollectionManager.class);
ArgumentCaptor<DocumentDeleteQuery> queryCaptor = ArgumentCaptor.forClass(DocumentDeleteQuery.class);
delete().from(collection).delete(manager);
verify(manager).delete(queryCaptor.capture());
DocumentDeleteQuery query = queryCaptor.getValue();
assertTrue(query.getDocuments().isEmpty());
assertFalse(query.getCondition().isPresent());
assertEquals(collection, query.getDocumentCollection());
}
use of jakarta.nosql.document.DocumentCollectionManager in project jnosql-diana by eclipse.
the class DocumentPageTest method setUp.
@BeforeEach
public void setUp() {
managerMock = Mockito.mock(DocumentCollectionManager.class);
columnEventPersistManager = Mockito.mock(DocumentEventPersistManager.class);
captor = ArgumentCaptor.forClass(DocumentEntity.class);
Instance<DocumentCollectionManager> instance = Mockito.mock(Instance.class);
when(instance.get()).thenReturn(managerMock);
this.subject = new DefaultDocumentTemplate(converter, instance, new DefaultDocumentWorkflow(columnEventPersistManager, converter), columnEventPersistManager, classMappings, converters);
Pagination pagination = Pagination.page(1).size(1);
DocumentQueryPagination query = DocumentQueryPagination.of(select().from("person").build(), pagination);
for (int index = 0; index <= 10; index++) {
Document[] columns = new Document[] { Document.of("age", index), Document.of("name", "Ada " + index), Document.of("_id", (long) index) };
DocumentEntity columnEntity = DocumentEntity.of("Person");
columnEntity.addAll(Stream.of(columns).collect(Collectors.toList()));
when(managerMock.select(query)).thenReturn(Stream.of(columnEntity));
query = query.next();
}
}
Aggregations