package org.mitre.synthea.world.geography;

import org.junit.Assert;
import org.junit.Test;

public class LocationTest {

  @Test
  public void testAbbreviations() {
    Assert.assertTrue(Location.getAbbreviation("Massachusetts").equals("MA"));
  }

  @Test
  public void testAbbreviationsReverse() {
    Assert.assertTrue(Location.getStateName("MA").equals("Massachusetts"));
  }

  @Test
  public void testLocation() {
    Location location = new Location("Massachusetts", null);
    Assert.assertTrue(location.getPopulation("Bedford") > 0);
    Assert.assertTrue(location.getZipCode("Bedford").equals("01730"));
  }
}

@@ -48,47 +48,330 @@
 ort 
-org.junit.Assert;%0Aimport org.junit.Test
+java.util.ArrayList;%0Aimport java.util.HashSet;%0Aimport java.util.LinkedHashMap;%0Aimport java.util.List;%0Aimport java.util.Map;%0Aimport java.util.Set;%0A%0Aimport org.junit.Assert;%0Aimport org.junit.Test;%0Aimport org.mitre.synthea.helpers.Config;%0Aimport org.mitre.synthea.helpers.SimpleCSV;%0Aimport org.mitre.synthea.helpers.Utilities
 ;%0A%0Ap
@@ -894,11 +894,1458 @@
 %22));%0A  %7D
+%0A%0A  @Test%0A  public void testAllDemographicsHaveLocations() throws Exception %7B%0A    String demoFileContents =%0A        Utilities.readResource(Config.get(%22generate.demographics.default_file%22));%0A    List%3CLinkedHashMap%3CString, String%3E%3E demographics = SimpleCSV.parse(demoFileContents);%0A    %0A    String zipFileContents =%0A        Utilities.readResource(Config.get(%22generate.geography.zipcodes.default_file%22));%0A    List%3CLinkedHashMap%3CString, String%3E%3E zips = SimpleCSV.parse(zipFileContents);%0A    %0A    // parse all the locations from the zip codes and put them in a a set.%0A    Set%3CString%3E availableLocations = new HashSet%3C%3E();%0A    for (Map%3CString,String%3E line : zips) %7B%0A      String city = line.get(%22NAME%22);%0A      String state = line.get(%22USPS%22);%0A      String key = (city + %22, %22 + state).toUpperCase();%0A      availableLocations.add(key);%0A    %7D%0A%0A    // iterate over all the locations in the demographics file, %0A    // and check them all against the locations set from above%0A    List%3CString%3E mismatches = new ArrayList%3C%3E();%0A    for (LinkedHashMap%3CString,String%3E line : demographics) %7B%0A      String city = line.get(%22NAME%22);%0A      String state = line.get(%22STNAME%22);%0A      %0A      String original = (city + %22, %22 + state);%0A      String key = original.toUpperCase();%0A      if (!availableLocations.contains(key)) %7B%0A        mismatches.add(original);%0A      %7D%0A    %7D%0A    String message = mismatches.toString();%0A    Assert.assertEquals(message, 0, mismatches.size());%0A  %7D
 %0A%7D%0A

add unit test confirming every demographic line has a corresponding zipcode line