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