SecurityAttributeMapper { public Object valueFor(SecurityAttribute column, Object security) { if (security == null) { return ""; } return getValue(column, security, security.getClass()); } SecurityAttributeMapper(); Object valueFor(SecurityAttribute column, Object security);  }
@Test public void fra() { ExternalId regionId = ExternalId.of("Reg", "123"); ExternalId underlyingId = ExternalId.of("Und", "321"); ZonedDateTime startDate = zdt(2012, 12, 21, 11, 0, 0, 0, ZoneOffset.UTC); ZonedDateTime endDate = zdt(2013, 12, 21, 11, 0, 0, 0, ZoneOffset.UTC); ZonedDateTime fixingDate = zdt(2013, 12, 20, 11, 0, 0, 0, ZoneOffset.UTC); FRASecurity security = new FRASecurity(Currency.AUD, regionId, startDate, endDate, 0.1, 1000, underlyingId, fixingDate); assertEquals("FRA", s_defaultMappings.valueFor(TYPE, security)); assertEquals(Currency.AUD, s_defaultMappings.valueFor(PRODUCT, security)); assertEquals(1000d, s_defaultMappings.valueFor(QUANTITY, security)); }
@Test public void fxForward() { ZonedDateTime forwardDate = zdt(2012, 12, 21, 11, 0, 0, 0, ZoneOffset.UTC); ExternalId regionId = ExternalId.of("Reg", "123"); FXForwardSecurity security = new FXForwardSecurity(Currency.USD, 150, Currency.GBP, 100, forwardDate, regionId); assertEquals("FX Forward", s_defaultMappings.valueFor(TYPE, security)); assertEquals("GBP/USD", s_defaultMappings.valueFor(PRODUCT, security)); assertEquals(forwardDate, s_defaultMappings.valueFor(MATURITY, security)); FXAmounts expected = FXAmounts.forForward(security.getPayCurrency(), security.getReceiveCurrency(), security.getPayAmount(), security.getReceiveAmount(), s_currencyPairs); assertEquals(expected, s_defaultMappings.valueFor(QUANTITY, security)); assertEquals(1.5d, s_defaultMappings.valueFor(RATE, security)); }