### Question:
MoneyReadConverter implements Converter<DBObject, BigMoney> { @Override public BigMoney convert(DBObject source) { if (source == null) { return null; } final String ccy = (String) source.get("currency"); final Object amount = source.get("amount"); if (amount == null) { throw new UnsupportedOperationException("not support for nullable amount of " + source); } return MoneyUtils.convertToBigMoney(ccy, (Long) amount); }  @Override BigMoney convert(DBObject source);  }### Answer:
@Test public void testConvert() throws Exception { final MoneyReadConverter converter = new MoneyReadConverter(); final DBObject dbObject = BasicDBObjectBuilder.start("amount", 123456789L) .append("currency", Currencies.BTC) .get(); final BigMoney money = converter.convert(dbObject); assertThat(money, notNullValue()); assertThat(money.getAmount(), notNullValue()); assertThat(money.getAmount(), is(closeTo(BigDecimal.valueOf(1.23456789), BigDecimal.valueOf(0.00000000001d)))); assertThat(money.getCurrencyUnit(), equalTo(CurrencyUnit.of(Currencies.BTC))); }
@Test public void testConvertCNY() throws Exception { final MoneyReadConverter converter = new MoneyReadConverter(); final DBObject dbObject = BasicDBObjectBuilder.start("amount", 123456789L) .append("currency", Currencies.CNY) .get(); final BigMoney money = converter.convert(dbObject); assertThat(money, notNullValue()); assertThat(money.getAmount(), notNullValue()); assertThat(money.getAmount(), is(closeTo(BigDecimal.valueOf(123456.789), BigDecimal.valueOf(0.00000000001d)))); assertThat(money.getCurrencyUnit(), equalTo(CurrencyUnit.of(Currencies.CNY))); }