public static List<Location> getLocationsByTags(String attributeName, Map<String, String> parameters){ List<Location> locations = null; String locationTags = parameters.get(attributeName); if ( locationTags != null) { List<LocationTag> tags = new ArrayList<LocationTag>(); String[] temp = locationTags.split(","); for (String s : temp) { if (s != null && !s.isEmpty()) { LocationTag tag = getLocationTag(s); if (tag == null) { throw new RuntimeException("Cannot find tag: " + tag); } tags.add(tag); } } locations = new ArrayList<Location>(); locations.addAll(Context.getLocationService().getLocationsHavingAnyTag(tags)); } return locations; } /**
for (String s : temp) { LocationTag tag = HtmlFormEntryUtil.getLocationTag(s); if (tag == null) { throw new RuntimeException("Cannot find tag: " + tag);
@Test @Verifies(value="shouldFetchLocationTagByName", method="getLocationTag(String identifier)") public void shouldFetchLocationTagByName() throws Exception { // this tag is in the regression test dataset executeDataSet(XML_DATASET_PATH + new TestUtil().getTestDatasetFilename(XML_REGRESSION_TEST_DATASET)); LocationTag tag = HtmlFormEntryUtil.getLocationTag("Some Tag"); Assert.assertNotNull(tag); Assert.assertEquals("Some Tag", tag.getTag()); }
@Test @Verifies(value="shouldFetchLocationTagById", method="getLocationTag(String identifier)") public void shouldFetchLocationTagById() throws Exception { // this tag is in the regression test dataset executeDataSet(XML_DATASET_PATH + new TestUtil().getTestDatasetFilename(XML_REGRESSION_TEST_DATASET)); LocationTag tag = HtmlFormEntryUtil.getLocationTag("1001"); Assert.assertNotNull(tag); Assert.assertEquals("Some Tag", tag.getTag()); }