VeryShortQualifiedNamesExtractor implements NamesExtractor { public ImmutableList<String> extractNames(ImmutableList<NamePart> nameParts) { if(nameParts.size() < 2) { throw new IllegalArgumentException("There should be at least 2 NameParts : a Country and a name"); } return ImmutableList.of( countryName(nameParts), featureName(nameParts)); }  ImmutableList<String> extractNames(ImmutableList<NamePart> nameParts);  }
@Test(expected=IllegalArgumentException.class) public void shouldNotAllowExtractingNamesWithLessThanThreeParts() { new ShortQualifiedNamesExtractor().extractNames( onePartNameProvider().getFullyQualifiedNameParts()).toString(); }
@Test public void shouldExtractCountryAndCity() { Assert.assertEquals("[United States, Los Angeles]", new VeryShortQualifiedNamesExtractor().extractNames( losAngelesNameProvider().getFullyQualifiedNameParts()).toString()); }