public void documentTenor() { XmlElement tradeDateEl = XmlElement.ofContent("tradeDate", "2000-06-30"); XmlElement tradeHeaderEl = XmlElement.ofChildren("tradeHeader", ImmutableList.of(tradeDateEl)); XmlElement tradeEl = XmlElement.ofChildren("trade", ImmutableMap.of("href", "foo"), ImmutableList.of(tradeHeaderEl)); XmlElement rootEl = XmlElement.ofChildren("dataDocument", ImmutableList.of(tradeEl)); FpmlDocument test = new FpmlDocument(rootEl, ImmutableMap.of(), FpmlPartySelector.any(), FpmlTradeInfoParserPlugin.standard(), REF_DATA); assertEquals(test.convertIndexTenor("1", "M"), Tenor.TENOR_1M); assertEquals(test.convertIndexTenor("12", "M"), Tenor.TENOR_12M); assertEquals(test.convertIndexTenor("1", "Y"), Tenor.TENOR_12M); assertEquals(test.convertIndexTenor("13", "Y"), Tenor.of(Period.ofYears(13))); }
/** * Converts an FpML 'FloatingRateIndex' tenor to a {@code Tenor}. * * @param baseEl the FpML floating rate index element to parse * @return the period * @throws RuntimeException if unable to parse */ public Tenor parseIndexTenor(XmlElement baseEl) { // FpML content: ('periodMultiplier', 'period') String multiplier = baseEl.getChild("periodMultiplier").getContent(); String unit = baseEl.getChild("period").getContent(); return convertIndexTenor(multiplier, unit); }