GeneratorDepositONCounterpart extends GeneratorInstrument<GeneratorAttributeIR> { @Override public DepositCounterpartDefinition generateInstrument(final ZonedDateTime date, final double rate, final double notional, final GeneratorAttributeIR attribute) { ArgumentChecker.notNull(date, "Reference date"); final ZonedDateTime startDate = ScheduleCalculator.getAdjustedDate(date, attribute.getStartPeriod(), _calendar); final ZonedDateTime endDate = ScheduleCalculator.getAdjustedDate(startDate, 1, _calendar); final double accrualFactor = _dayCount.getDayCountFraction(startDate, endDate, _calendar); return new DepositCounterpartDefinition(_currency, startDate, endDate, notional, rate, accrualFactor, _nameCounterpart); } GeneratorDepositONCounterpart(final String nameGenerator, final Currency currency, final Calendar calendar, final DayCount dayCount, final String nameCounterpart); Currency getCurrency(); Calendar getCalendar(); DayCount getDayCount(); String getNameCounterpart(); @Override DepositCounterpartDefinition generateInstrument(final ZonedDateTime date, final double rate, final double notional, final GeneratorAttributeIR attribute); @Override int hashCode(); @Override boolean equals(final Object obj);  }
@Test public void generateInstrument() { final ZonedDateTime referenceDate = DateUtils.getUTCDate(2012, 7, 17); final Period tenor = Period.ofDays(2); final double rate = 0.01; final double notional = 12345; final GeneratorAttributeIR attribute = new GeneratorAttributeIR(tenor, tenor); final DepositCounterpartDefinition insGenerated = GENERATOR_DEPOSIT_ON_USD.generateInstrument(referenceDate, rate, notional, attribute); final ZonedDateTime startDate = ScheduleCalculator.getAdjustedDate(referenceDate, tenor, CALENDAR); final ZonedDateTime endDate = ScheduleCalculator.getAdjustedDate(startDate, 1, CALENDAR); final double accrualFactor = DAY_COUNT.getDayCountFraction(startDate, endDate); final DepositCounterpartDefinition insExpected = new DepositCounterpartDefinition(CUR, startDate, endDate, notional, rate, accrualFactor, NAME_COUNTERPART); assertEquals("Generator Deposit Counterpart: generate instrument", insExpected, insGenerated); }