@Test public void testConvertCNY() throws Exception { final MoneyWriteConverter converter = new MoneyWriteConverter(); final DBObject btc = converter.convert(BigMoney.of(CurrencyUnit.of(Currencies.CNY), 100)); assertThat((Long) btc.get("amount"), equalTo(1000 * 100l)); assertThat((String) btc.get("currency"), equalTo(Currencies.CNY)); }
@Override public DBObject convert(BigMoney source) { if (source == null) { return null; } BasicDBObject result = new BasicDBObject(); final long moneyLong = MoneyUtils.convertToLong(source); result.put("amount", moneyLong); result.put("currency", source.getCurrencyUnit().getCurrencyCode()); return result; }
MoneyWriteConverter implements Converter<BigMoney, DBObject> { @Override public DBObject convert(BigMoney source) { if (source == null) { return null; } BasicDBObject result = new BasicDBObject(); final long moneyLong = MoneyUtils.convertToLong(source); result.put("amount", moneyLong); result.put("currency", source.getCurrencyUnit().getCurrencyCode()); return result; } }
MoneyWriteConverter implements Converter<BigMoney, DBObject> { @Override public DBObject convert(BigMoney source) { if (source == null) { return null; } BasicDBObject result = new BasicDBObject(); final long moneyLong = MoneyUtils.convertToLong(source); result.put("amount", moneyLong); result.put("currency", source.getCurrencyUnit().getCurrencyCode()); return result; }  }
MoneyWriteConverter implements Converter<BigMoney, DBObject> { @Override public DBObject convert(BigMoney source) { if (source == null) { return null; } BasicDBObject result = new BasicDBObject(); final long moneyLong = MoneyUtils.convertToLong(source); result.put("amount", moneyLong); result.put("currency", source.getCurrencyUnit().getCurrencyCode()); return result; }  @Override DBObject convert(BigMoney source); }
MoneyWriteConverter implements Converter<BigMoney, DBObject> { @Override public DBObject convert(BigMoney source) { if (source == null) { return null; } BasicDBObject result = new BasicDBObject(); final long moneyLong = MoneyUtils.convertToLong(source); result.put("amount", moneyLong); result.put("currency", source.getCurrencyUnit().getCurrencyCode()); return result; }  @Override DBObject convert(BigMoney source);  }