YieldConventionFactory extends AbstractNamedInstanceFactory<YieldConvention> { public YieldConvention getYieldConvention(final String name) { try { return instance(name); } catch (final IllegalArgumentException ex) { ArgumentChecker.notNull(name, "name"); final YieldConvention yc = new SimpleYieldConvention(name.toUpperCase(Locale.ENGLISH)); return addInstance(yc); } } private  YieldConventionFactory(); @FromString static YieldConvention of(final String name); YieldConvention getYieldConvention(final String name); static final YieldConventionFactory INSTANCE; }
@Test(expectedExceptions = IllegalArgumentException.class) public void testNullName() { FACTORY.getYieldConvention(null); }
@Test public void testContainsAllInSimpleConvention() { assertEquals(FACTORY.getYieldConvention("UK STRIP METHOD"), SimpleYieldConvention.UK_STRIP_METHOD); assertEquals(FACTORY.getYieldConvention("UK:BUMP/DMO METHOD"), SimpleYieldConvention.UK_BUMP_DMO_METHOD); assertEquals(FACTORY.getYieldConvention("US I/L real"), SimpleYieldConvention.US_IL_REAL); assertEquals(FACTORY.getYieldConvention("US street"), SimpleYieldConvention.US_STREET); assertEquals(FACTORY.getYieldConvention("US Treasury equivalent"), SimpleYieldConvention.US_TREASURY_EQUIVALENT); assertEquals(FACTORY.getYieldConvention("Money Market"), SimpleYieldConvention.MONEY_MARKET); assertEquals(FACTORY.getYieldConvention("JGB simple"), SimpleYieldConvention.JGB_SIMPLE); assertEquals(FACTORY.getYieldConvention("True"), SimpleYieldConvention.TRUE); assertEquals(FACTORY.getYieldConvention("US Treasury"), SimpleYieldConvention.US_BOND); }