final ExternalId marketDataId = ExternalId.of(SCHEME, "US1d");
final double rate = 0.0012345;
final SnapshotDataBundle marketValues = new SnapshotDataBundle();
marketValues.setDataPoint(marketDataId, rate);
ZonedDateTime now = DateUtils.getUTCDate(2013, 2, 4);
CurveNode cashNode = new CashNode(Tenor.of(Period.ZERO), Tenor.ONE_MONTH, DEPOSIT_1M_ID, "Mapper");
CurveNodeVisitor<InstrumentDefinition<?>> converter = new CashNodeConverter(CONVENTION_SOURCE, HOLIDAY_SOURCE, REGION_SOURCE, marketValues, marketDataId, now);
InstrumentDefinition<?> definition = cashNode.accept(converter);
assertTrue(definition instanceof CashDefinition);
CashDefinition cash = (CashDefinition) definition;
CashDefinition expectedCash = new CashDefinition(Currency.USD, DateUtils.getUTCDate(2013, 2, 6), DateUtils.getUTCDate(2013, 3, 6), 1, rate, 28. / 360);
assertEquals(expectedCash, cash);
now = DateUtils.getUTCDate(2013, 5, 2);
converter = new CashNodeConverter(CONVENTION_SOURCE, HOLIDAY_SOURCE, REGION_SOURCE, marketValues, marketDataId, now);
cashNode = new CashNode(Tenor.of(Period.ZERO), Tenor.ONE_MONTH, DEPOSIT_1M_ID, "Mapper");
definition = cashNode.accept(converter);
assertTrue(definition instanceof CashDefinition);
cash = (CashDefinition) definition;
expectedCash = new CashDefinition(Currency.USD, DateUtils.getUTCDate(2013, 5, 6), DateUtils.getUTCDate(2013, 6, 6), 1, rate, 31. / 360);
assertEquals(expectedCash, cash);
now = DateUtils.getUTCDate(2013, 5, 7);
converter = new CashNodeConverter(CONVENTION_SOURCE, HOLIDAY_SOURCE, REGION_SOURCE, marketValues, marketDataId, now);
cashNode = new CashNode(Tenor.ONE_MONTH, Tenor.THREE_MONTHS, DEPOSIT_1M_ID, "Mapper");
definition = cashNode.accept(converter);
assertTrue(definition instanceof CashDefinition);
cash = (CashDefinition) definition;
expectedCash = new CashDefinition(Currency.USD, DateUtils.getUTCDate(2013, 6, 10), DateUtils.getUTCDate(2013, 9, 10), 1, rate, 92. / 360);
assertEquals(expectedCash, cash);
}