@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); }