コード例 #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 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"));
 }