use of org.jnosql.diana.api.document.DocumentEntity in project jnosql-artemis by eclipse.
the class DefaultDocumentEntityConverterTest method shouldConvertDocumentEntityFromEntity.
@Test
public void shouldConvertDocumentEntityFromEntity() {
Person person = Person.builder().withAge().withId(12).withName("Otavio").withPhones(Arrays.asList("234", "2342")).build();
DocumentEntity entity = converter.toDocument(person);
assertEquals("Person", entity.getName());
assertEquals(4, entity.size());
assertThat(entity.getDocuments(), containsInAnyOrder(Document.of("_id", 12L), Document.of("age", 10), Document.of("name", "Otavio"), Document.of("phones", Arrays.asList("234", "2342"))));
}
use of org.jnosql.diana.api.document.DocumentEntity in project jnosql-artemis by eclipse.
the class DefaultDocumentEventPersistManagerTest method shouldFirePreDocument.
@Test
public void shouldFirePreDocument() {
DocumentEntity entity = DocumentEntity.of("collection");
subject.firePreDocument(entity);
ArgumentCaptor<DocumentEntityPrePersist> captor = ArgumentCaptor.forClass(DocumentEntityPrePersist.class);
verify(documentEntityPrePersistEvent).fire(captor.capture());
DocumentEntityPrePersist captorValue = captor.getValue();
assertEquals(entity, captorValue.getEntity());
}
use of org.jnosql.diana.api.document.DocumentEntity in project jnosql-artemis by eclipse.
the class DefaultDocumentTemplateAsyncTest method shouldInsertTTL.
@Test
public void shouldInsertTTL() {
Duration twoHours = Duration.ofHours(2L);
DocumentEntity entity = DocumentEntity.of("Person");
entity.addAll(Stream.of(documents).collect(Collectors.toList()));
subject.insert(this.person, twoHours);
verify(managerMock).insert(captor.capture(), Mockito.eq(twoHours), Mockito.any(Consumer.class));
DocumentEntity value = captor.getValue();
assertEquals("Person", value.getName());
assertEquals(4, value.getDocuments().size());
}
use of org.jnosql.diana.api.document.DocumentEntity in project jnosql-artemis by eclipse.
the class DefaultDocumentTemplateAsyncTest method shouldUpdate.
@Test
public void shouldUpdate() {
DocumentEntity entity = DocumentEntity.of("Person");
entity.addAll(Stream.of(documents).collect(Collectors.toList()));
subject.update(this.person);
verify(managerMock).update(captor.capture(), Mockito.any(Consumer.class));
DocumentEntity value = captor.getValue();
assertEquals("Person", value.getName());
assertEquals(4, value.getDocuments().size());
}
use of org.jnosql.diana.api.document.DocumentEntity in project jnosql-artemis by eclipse.
the class DefaultDocumentTemplateAsyncTest method shouldUpdateIterable.
@Test
public void shouldUpdateIterable() {
DocumentEntity entity = DocumentEntity.of("Person");
entity.addAll(Stream.of(documents).collect(Collectors.toList()));
subject.update(singletonList(this.person));
verify(managerMock).update(captor.capture(), Mockito.any(Consumer.class));
DocumentEntity value = captor.getValue();
assertEquals(entity.getName(), value.getName());
}
Aggregations