コード例 #1
0
 @Test
 public void testEquals() {
   List<AmountFormatContext> contexts = new ArrayList<AmountFormatContext>();
   contexts.add(AmountFormatContextBuilder.of(Locale.ENGLISH).build());
   contexts.add(AmountFormatContextBuilder.of(Locale.GERMAN).build());
   Set<AmountFormatContext> checkContexts = new HashSet<AmountFormatContext>();
   for (AmountFormatContext amountFormatContext : contexts) {
     checkContexts.add(amountFormatContext);
   }
   // Check we have 5 distinct hash codes...
   assertTrue(checkContexts.size() == 2);
 }
コード例 #2
0
 @Test
 public void testToBuilder() throws Exception {
   AmountFormatContext ctx = AmountFormatContextBuilder.of(Locale.CANADA).build();
   AmountFormatContextBuilder b = ctx.toBuilder();
   assertNotNull(b);
   assertEquals(b.build(), ctx);
 }
コード例 #3
0
 @Test
 public void testGetParseFactory() throws Exception {
   MonetaryAmountFactory f = new DummyAmountBuilder();
   AmountFormatContext ctx =
       AmountFormatContextBuilder.of("blbl2").setMonetaryAmountFactory(f).build();
   assertEquals(ctx.getParseFactory(), f);
 }
コード例 #4
0
 @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"));
 }
コード例 #5
0
 @Test
 public void testGetLocale() throws Exception {
   AmountFormatContext ctx = AmountFormatContextBuilder.of(Locale.CANADA).build();
   assertEquals(ctx.getLocale(), Locale.CANADA);
 }
コード例 #6
0
 @Test
 public void testGetFormatName() throws Exception {
   AmountFormatContext ctx = AmountFormatContextBuilder.of("testest").build();
   assertEquals(ctx.getFormatName(), "testest");
 }