Search in sources :

Example 1 with Money

use of org.eclipse.jnosql.communication.mongodb.document.type.Money in project jnosql-diana-driver by eclipse.

the class MongoDBDocumentCollectionManagerTest method shouldCustomTypeWork.

@Test
public void shouldCustomTypeWork() {
    DocumentEntity entity = getEntity();
    Currency currency = Currency.getInstance("USD");
    Money money = Money.of(currency, BigDecimal.valueOf(10D));
    entity.add("money", money);
    DocumentEntity documentEntity = entityManager.insert(entity);
    Document id = documentEntity.find("_id").get();
    DocumentQuery query = DocumentQuery.select().from(documentEntity.getName()).where(id.getName()).eq(id.get()).build();
    DocumentEntity result = entityManager.singleResult(query).get();
    assertEquals(money, result.find("money").get().get(Money.class));
}
Also used : Money(org.eclipse.jnosql.communication.mongodb.document.type.Money) DocumentQuery(jakarta.nosql.document.DocumentQuery) DocumentEntity(jakarta.nosql.document.DocumentEntity) Document(jakarta.nosql.document.Document) Test(org.junit.jupiter.api.Test)

Aggregations

Document (jakarta.nosql.document.Document)1 DocumentEntity (jakarta.nosql.document.DocumentEntity)1 DocumentQuery (jakarta.nosql.document.DocumentQuery)1 Money (org.eclipse.jnosql.communication.mongodb.document.type.Money)1 Test (org.junit.jupiter.api.Test)1