### Question:
Collators { public static Collator newCollator(Optional<Locale> localeOptional) { if (localeOptional.isPresent()) { return Collator.getInstance(localeOptional.get()); } else { return Collator.getInstance(); } }  static Collator newCollator(Optional<Locale> localeOptional);  }### Answer:
@Test public void testNoLocale() { Collator collatorNoLocale = Collators.newCollator(Optional.<Locale>absent()); Collections.sort(toSortAlpha, collatorNoLocale); checkEnglishOrder(toSortAlpha); Collections.sort(toSortBeta, collatorNoLocale); checkEnglishOrder(toSortBeta); }
@Test public void testEnglishLocale() { Collator collatorEnglishLocale = Collators.newCollator(Optional.of(Locale.ENGLISH)); Collections.sort(toSortAlpha, collatorEnglishLocale); checkEnglishOrder(toSortAlpha); Collections.sort(toSortBeta, collatorEnglishLocale); checkEnglishOrder(toSortBeta); }
@Test public void testFrenchLocale() { Collator collatorFrenchLocale = Collators.newCollator(Optional.of(Locale.FRENCH)); Collections.sort(toSortAlpha, collatorFrenchLocale); checkFrenchOrder(toSortAlpha); Collections.sort(toSortBeta, collatorFrenchLocale); checkFrenchOrder(toSortBeta); }