@Test public void testToBuilder() throws Exception { AmountFormatContext ctx = AmountFormatContextBuilder.of(Locale.CANADA).build(); AmountFormatContextBuilder b = ctx.toBuilder(); assertNotNull(b); assertEquals(b.build(), ctx); }
@Test public void testGetParseFactory() throws Exception { MonetaryAmountFactory f = new DummyAmountBuilder(); AmountFormatContext ctx = AmountFormatContextBuilder.of("blbl2").setMonetaryAmountFactory(f).build(); assertEquals(ctx.getParseFactory(), f); }
@Test public void testHashCode() { List<AmountFormatContext> contexts = new ArrayList<AmountFormatContext>(); contexts.add(AmountFormatContextBuilder.of(Locale.GERMAN).build()); contexts.add(AmountFormatContextBuilder.of(Locale.ENGLISH).build()); Set<Integer> hashCodes = new HashSet<Integer>(); for (AmountFormatContext amountFormatContext : contexts) { hashCodes.add(amountFormatContext.hashCode()); } // Check we have 5 distinct hash codes... assertTrue(hashCodes.size() == 2); }
@Test public void testToString() throws Exception { AmountFormatContext style = AmountFormatContextBuilder.of(Locale.GERMAN) .set("groupSizes", new int[] {1, 2, 3, 4}) .set("currencyStyle", "NUMERIC_CODE") .set("pattern", "###") .build(); String toString = style.toString(); assertNotNull(toString); assertTrue(toString.contains("DE")); assertTrue(toString.contains("java.util.Locale")); assertTrue(toString.contains("groupSizes")); assertTrue(toString.contains("###")); assertTrue(toString.contains("NUMERIC_CODE")); assertTrue(toString.contains("currencyStyle")); assertTrue(toString.contains("AmountFormatContext")); }
@Test public void testGetLocale() throws Exception { AmountFormatContext ctx = AmountFormatContextBuilder.of(Locale.CANADA).build(); assertEquals(ctx.getLocale(), Locale.CANADA); }
@Test public void testGetFormatName() throws Exception { AmountFormatContext ctx = AmountFormatContextBuilder.of("testest").build(); assertEquals(ctx.getFormatName(), "testest"); }