HolidaysFactory { public static Holidays of(Locale locale) { switch (locale.getCountry()) { case "PL": return new PolishHolidays(); case "US": return new AmericanHolidays(); default: throw new IllegalArgumentException("Unsupported: " + locale.getCountry()); } }  static Holidays of(Locale locale);  }
@Test public void shouldReturnPolishHolidays() { final Locale poland = new Locale("pl", "PL"); final Holidays holidays = HolidaysFactory.of(poland); assertThat(holidays).isInstanceOf(PolishHolidays.class); }
@Test public void shouldReturnAmericanHolidays() { final Locale america = Locale.US; final Holidays holidays = HolidaysFactory.of(america); assertThat(holidays).isInstanceOf(AmericanHolidays.class); }