コード例 #1
0
  protected static void verifyZipcodes() throws IOException {
    // alien id, native id
    Map<String, String> federalStateMap = new HashMap<String, String>();
    federalStateMap.put("08", "2631"); // Baden-Württemberg
    federalStateMap.put("09", "2632"); // Bayern
    federalStateMap.put("11", "2633"); // Berlin
    federalStateMap.put("12", "2634"); // Brandenburg
    federalStateMap.put("04", "2635"); // Bremen
    federalStateMap.put("02", "2636"); // Hamburg
    federalStateMap.put("06", "2637"); // Hessen
    federalStateMap.put("13", "2638"); // Mecklenburg-Vorpommern
    federalStateMap.put("03", "2639"); // Niedersachsen
    federalStateMap.put("05", "2640"); // Nordrhein-Westfalen
    federalStateMap.put("07", "2641"); // Rheinland-Pfalz
    federalStateMap.put("10", "2642"); // Saarland
    federalStateMap.put("14", "2643"); // Sachsen
    federalStateMap.put("15", "2644"); // Sachsen-Anhalt
    federalStateMap.put("01", "2645"); // Schleswig-Holstein
    federalStateMap.put("16", "2646"); // Thüringen

    List<GermanZipcodeBean> list = getGermanZipcodeBeanList();
    Countries germany = countriesService.find("DE");

    for (GermanZipcodeBean bean : list) {
      String zipcode = bean.getZipcode();
      String federalStateKey = bean.getFederalStateKey();
      Addresses address = addressesService.findFirst(germany, zipcode);
      if (address != null) {
        Federalstates federalstate =
            federalstatesService.get(Integer.valueOf(federalStateMap.get(federalStateKey)));
        address.setFederalstate(federalstate);
        addressesService.merge(address);
      }
    }
  }
コード例 #2
0
 @Test
 public void testFindFederalstatesFromCountryCountriesString() {
   Countries germany = countriesService.find("DE");
   List<Federalstates> federalstates =
       federalstatesService.findFederalstatesFromCountry(germany, "Hamburg");
   AssertJUnit.assertEquals(1, federalstates.size());
   Federalstates federalstate = federalstatesService.findFederalstate(germany, "Hamburg");
   AssertJUnit.assertNotNull(federalstate);
   AssertJUnit.assertEquals("Hamburg", federalstate.getName());
 }