Query { public ArrayList<City> getLowestCrime(String state, int n) { lowestCrime.clear(); queryCrimeData = "SELECT * FROM Crime WHERE state=\'" + state.toUpperCase() + "\' ORDER BY Violent_crime LIMIT " + Integer.toString(n) + ";"; runQuery(dbc,queryCrimeData,"Crime", n); return lowestCrime; } Query(); City getCityData(String city); ArrayList<City> getLowestCrime(String state, int n); City getCityByCrime(City c); ArrayList<String> getStateNames(); ArrayList<String> getCityNames(String state);  }
@Test public void testGetLowestCrime() { ArrayList<City> lc = q.getLowestCrime("Arizona", 5); boolean isLow = false; for(City c : lc) { if(c.getName().equals("Thatcher") || c.getName().equals("Pima") || c.getName().equals("Fredonia") || c.getName().equals("Huachuca City") || c.getName().equals("Jerome")) isLow = true; else assertTrue(false); } assertTrue(isLow); lc = q.getLowestCrime("New York", 5); isLow = false; for(City c : lc) { if(c.getName().equals("Adams Village") || c.getName().equals("Black River") || c.getName().equals("Asharoken Village") || c.getName().equals("Brewster") || c.getName().equals("Arcade Village")) isLow = true; else assertTrue(false); } assertTrue(isLow); lc = q.getLowestCrime("Michigan", 5); isLow = false; for(City c : lc) { if(c.getName().equals("Eau Claire") || c.getName().equals("Frost Township") || c.getName().equals("Elkton") || c.getName().equals("Edmore") || c.getName().equals("Elsie")) isLow = true; else assertTrue(false); } assertTrue(isLow); lc = q.getLowestCrime("Idaho", 5); isLow = false; for(City c : lc) { if(c.getName().equals("Bellevue") || c.getName().equals("Cascade") || c.getName().equals("Challis") || c.getName().equals("Hagerman") || c.getName().equals("Parma")) isLow = true; else assertTrue(false); } assertTrue(isLow); }