Boroughs { public static int parseInt(String boroughCodeOrName) { if (NumberUtils.isParsable(boroughCodeOrName)) { return Integer.valueOf(boroughCodeOrName); } Borough borough = fromName(boroughCodeOrName); if(borough != null) { return Integer.valueOf(borough.getCode()); } return UNPARSABLE_BOROUGH_CODE_SENTINEL_VALUE; } 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 public void testParseInt() { assertThat(Boroughs.parseInt("1")).isEqualTo(1); assertThat(Boroughs.parseInt("2")).isEqualTo(2); assertThat(Boroughs.parseInt("3")).isEqualTo(3); assertThat(Boroughs.parseInt("4")).isEqualTo(4); assertThat(Boroughs.parseInt("5")).isEqualTo(5); assertThat(Boroughs.parseInt("12")).isEqualTo(12); assertThat(Boroughs.parseInt("-78")).isEqualTo(-78); assertThat(Boroughs.parseInt("Manhattan")).isEqualTo(1); assertThat(Boroughs.parseInt("MN")).isEqualTo(1); assertThat(Boroughs.parseInt("BRONX")).isEqualTo(2); assertThat(Boroughs.parseInt("bx")).isEqualTo(2); assertThat(Boroughs.parseInt("brooklyn")).isEqualTo(3); assertThat(Boroughs.parseInt("bk")).isEqualTo(3); assertThat(Boroughs.parseInt("qUeeNs")).isEqualTo(4); assertThat(Boroughs.parseInt("qN")).isEqualTo(4); assertThat(Boroughs.parseInt("staten island")).isEqualTo(5); assertThat(Boroughs.parseInt("STATEN IS")).isEqualTo(5); assertThat(Boroughs.parseInt("si")).isEqualTo(5); assertThat(Boroughs.parseInt("man")).isEqualTo(Boroughs.UNPARSABLE_BOROUGH_CODE_SENTINEL_VALUE); }