Boroughs { public static final Borough fromName(String name) { return findFirst((Borough b) -> b.isAlsoKnownAs(name)); } private  Boroughs(); static final Borough fromCode(String code); static final Borough fromName(String name); static int parseInt(String boroughCodeOrName); static final Borough findFirst(Predicate<? super Borough> predicate); static final Borough MANHATTAN; static final Borough BRONX; static final Borough BROOKLYN; static final Borough QUEENS; static final Borough STATEN_ISLAND; static final int UNPARSABLE_BOROUGH_CODE_SENTINEL_VALUE; static final List<Borough> THE_FIVE_BOROUGHS; }
@Test void testManhattanFromName() { List<String> manhattanAKA = Boroughs.MANHATTAN.getAliases(); for (String name : manhattanAKA) { assertSame(Boroughs.MANHATTAN, Boroughs.fromName(name)); assertSame(Boroughs.MANHATTAN, Boroughs.fromName(name.toLowerCase())); assertSame(Boroughs.MANHATTAN, Boroughs.fromName(name.toUpperCase())); } assertNull(Boroughs.fromName("New Yawk")); }
@Test void testBronxFromName() { List<String> bronxAKA = Boroughs.BRONX.getAliases(); for (String name : bronxAKA) { assertSame(Boroughs.BRONX, Boroughs.fromName(name)); assertSame(Boroughs.BRONX, Boroughs.fromName(name.toLowerCase())); assertSame(Boroughs.BRONX, Boroughs.fromName(name.toUpperCase())); } assertNull(Boroughs.fromName("Boogie Down")); }
@Test void testBrooklynFromName() { List<String> brooklynAKA = Boroughs.BROOKLYN.getAliases(); for (String name : brooklynAKA) { assertSame(Boroughs.BROOKLYN, Boroughs.fromName(name)); assertSame(Boroughs.BROOKLYN, Boroughs.fromName(name.toLowerCase())); assertSame(Boroughs.BROOKLYN, Boroughs.fromName(name.toUpperCase())); } assertNull(Boroughs.fromName("Brooklyn Zoo")); }
@Test void testQueensFromName() { List<String> queensAKA = Boroughs.QUEENS.getAliases(); for (String name : queensAKA) { assertSame(Boroughs.QUEENS, Boroughs.fromName(name)); assertSame(Boroughs.QUEENS, Boroughs.fromName(name.toLowerCase())); assertSame(Boroughs.QUEENS, Boroughs.fromName(name.toUpperCase())); } assertNull(Boroughs.fromName("Queensland")); }
@Test void testStatenIslandFromName() { List<String> statenIslandAKA = Boroughs.STATEN_ISLAND.getAliases(); for (String name : statenIslandAKA) { assertSame(Boroughs.STATEN_ISLAND, Boroughs.fromName(name)); assertSame(Boroughs.STATEN_ISLAND, Boroughs.fromName(name.toLowerCase())); assertSame(Boroughs.STATEN_ISLAND, Boroughs.fromName(name.toUpperCase())); } assertNull(Boroughs.fromName("Shaolin")); }