ShortUsStyleNamesExtractor implements NamesExtractor { public ImmutableList<String> extractNames(ImmutableList<NamePart> nameParts) { if(nameParts.size() < 3) { throw new IllegalArgumentException("There should be at least 3 NameParts : a Country, a first-order administrative division, and a name"); } return ImmutableList.of( adm1Code(nameParts), featureName(nameParts)); }  ImmutableList<String> extractNames(ImmutableList<NamePart> nameParts);  }
@Test(expected=IllegalArgumentException.class) public void shouldNotAllowExtractingNamesWithLessThanThreeParts() { new ShortQualifiedNamesExtractor().extractNames( twoPartsNameProvider().getFullyQualifiedNameParts()).toString(); }
@Test public void shouldExtractAdm1CodeAndCity() { Assert.assertEquals("[CA, Los Angeles]", new ShortUsStyleNamesExtractor().extractNames( losAngelesNameProvider().getFullyQualifiedNameParts()).toString()); }