GeneratorForexSwap extends GeneratorInstrument<GeneratorAttributeFX> { @Override public ForexSwapDefinition generateInstrument(final ZonedDateTime date, final double forwardPoints, final double notional, final GeneratorAttributeFX attribute) { ArgumentChecker.notNull(attribute, "Attribute"); final double fx = attribute.getFXMatrix().getFxRate(_currency1, _currency2); final ZonedDateTime spot = ScheduleCalculator.getAdjustedDate(date, _spotLag, _calendar); final ZonedDateTime startDate = ScheduleCalculator.getAdjustedDate(spot, attribute.getStartPeriod(), _businessDayConvention, _calendar, _endOfMonth); final ZonedDateTime endDate = ScheduleCalculator.getAdjustedDate(spot, attribute.getEndPeriod(), _businessDayConvention, _calendar, _endOfMonth); return new ForexSwapDefinition(_currency1, _currency2, startDate, endDate, notional, fx, forwardPoints); } GeneratorForexSwap(final String name, final Currency currency1, final Currency currency2, final Calendar calendar, final int spotLag,
      final BusinessDayConvention businessDayConvention, final boolean endOfMonth); Currency getCurrency1(); Currency getCurrency2(); Calendar getCalendar(); int getSpotLag(); BusinessDayConvention getBusinessDayConvention(); boolean isEndOfMonth(); @Override ForexSwapDefinition generateInstrument(final ZonedDateTime date, final double forwardPoints, final double notional, final GeneratorAttributeFX 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.ofMonths(6); final double pts = 0.01; final double eurUsd = 1.25; final double notional = 123000000; final FXMatrix fxMatrix = new FXMatrix(EUR, USD, eurUsd); final GeneratorAttributeFX attribute = new GeneratorAttributeFX(tenor, fxMatrix); final ForexSwapDefinition insGenerated = GENERATOR_FX_EURUSD.generateInstrument(referenceDate, pts, notional, attribute); final ZonedDateTime startDate = ScheduleCalculator.getAdjustedDate(referenceDate, SETTLEMENT_DAYS, CALENDAR); final ZonedDateTime endDate = ScheduleCalculator.getAdjustedDate(startDate, tenor, BUSINESS_DAY, CALENDAR, IS_EOM); final ForexSwapDefinition insExpected = new ForexSwapDefinition(EUR, USD, startDate, endDate, notional, eurUsd, pts); assertEquals("Generator Deposit: generate instrument", insExpected, insGenerated); }