use of org.jnosql.diana.api.document.DocumentEntity in project jnosql-artemis by eclipse.
the class DefaultDocumentTemplateTest method shouldInsertEntitiesTTL.
@Test
public void shouldInsertEntitiesTTL() {
DocumentEntity documentEntity = DocumentEntity.of("Person");
documentEntity.addAll(Stream.of(documents).collect(Collectors.toList()));
Duration duration = Duration.ofHours(2);
Mockito.when(managerMock.insert(any(DocumentEntity.class), Mockito.eq(duration))).thenReturn(documentEntity);
subject.insert(Arrays.asList(person, person), duration);
verify(managerMock, times(2)).insert(any(DocumentEntity.class), any(Duration.class));
}
use of org.jnosql.diana.api.document.DocumentEntity in project jnosql-artemis by eclipse.
the class DefaultDocumentEntityConverterTest method shouldConvertToEntityWhenHasConverter.
@Test
public void shouldConvertToEntityWhenHasConverter() {
Worker worker = new Worker();
Job job = new Job();
job.setCity("Sao Paulo");
job.setDescription("Java Developer");
worker.setName("Bob");
worker.setSalary(new Money("BRL", BigDecimal.TEN));
worker.setJob(job);
DocumentEntity entity = converter.toDocument(worker);
Worker worker1 = converter.toEntity(entity);
assertEquals(worker.getSalary(), worker1.getSalary());
assertEquals(job.getCity(), worker1.getJob().getCity());
assertEquals(job.getDescription(), worker1.getJob().getDescription());
}
use of org.jnosql.diana.api.document.DocumentEntity in project jnosql-diana-driver by eclipse.
the class OrientDBDocumentCollectionManagerAsyncTest method shouldFindAsyncWithNativeQueryMapParam.
@Test
public void shouldFindAsyncWithNativeQueryMapParam() {
DocumentEntity entity = entityManager.insert(getEntity());
Optional<Document> id = entity.find(OrientDBConverter.RID_FIELD);
Optional<Document> name = entity.find("name");
AtomicReference<List<DocumentEntity>> reference = new AtomicReference<>();
Map<String, Object> params = new HashMap<>();
params.put("id", id.get().get());
params.put("name", name.get().get());
entityManagerAsync.sql("select * from person where @rid = :id and name = :name", reference::set, params);
await().until(reference::get, notNullValue(List.class));
assertFalse(reference.get().isEmpty());
assertEquals(reference.get().get(0), entity);
}
use of org.jnosql.diana.api.document.DocumentEntity in project jnosql-diana-driver by eclipse.
the class OrientDBDocumentCollectionManagerAsyncTest method shouldFindAsyncWithNativeQuery.
@Test
public void shouldFindAsyncWithNativeQuery() {
DocumentEntity entity = entityManager.insert(getEntity());
AtomicReference<List<DocumentEntity>> reference = new AtomicReference<>();
StringBuilder query = new StringBuilder().append("SELECT FROM ").append(COLLECTION_NAME).append(" WHERE name = ?");
entityManagerAsync.sql(query.toString(), reference::set, "Poliana");
await().until(reference::get, notNullValue(List.class));
assertFalse(reference.get().isEmpty());
assertEquals(reference.get().get(0), entity);
}
use of org.jnosql.diana.api.document.DocumentEntity in project jnosql-diana-driver by eclipse.
the class OrientDBDocumentCollectionManagerTest method getEntities.
private List<DocumentEntity> getEntities() {
DocumentEntity otavio = DocumentEntity.of(COLLECTION_NAME);
otavio.add(Document.of("name", "Otavio"));
otavio.add(Document.of("city", "Sao Paulo"));
DocumentEntity lucas = DocumentEntity.of(COLLECTION_NAME);
lucas.add(Document.of("name", "Lucas"));
lucas.add(Document.of("city", "Assis"));
return asList(getEntity(), otavio, lucas);
}
Aggregations