/** * This method doesn't support "SessionAttribute:", but is otherwise like the similarly-named method. * @see #getLocation(String, FormEntryContext) */ public static Location getLocation(String id) { return getLocation(id, null); }
Location l = HtmlFormEntryUtil.getLocation(initialValue, context); if (l == null) { throw new RuntimeException("Cannot find Location: " + initialValue);
Location loc = HtmlFormEntryUtil.getLocation(s, context); if (loc == null) { throw new RuntimeException("Cannot find location: " + loc); String defaultLocId = (String) parameters.get("default"); if (StringUtils.hasText(defaultLocId)) { defaultLocation = HtmlFormEntryUtil.getLocation(defaultLocId, context);
/** * * @param locationIdentifier * @return the location with the specified locationId, uuid or name. */ public Location location(String locationIdentifier) { return HtmlFormEntryUtil.getLocation(locationIdentifier); }
/** * @see {@link HtmlFormEntryUtil#getLocation(String)} */ @Test @Verifies(value = "should return null otherwise", method = "getLocation(String)") public void getLocation_shouldReturnNullOtherwise() throws Exception { String id = null; Assert.assertNull(HtmlFormEntryUtil.getLocation(id)); id = ""; Assert.assertNull(HtmlFormEntryUtil.getLocation(id)); id = "100000";//not exist in the standardTestData Assert.assertNull(HtmlFormEntryUtil.getLocation(id)); id = "ASDFASDFEAF";//random string Assert.assertNull(HtmlFormEntryUtil.getLocation(id)); id = "-";//uuid style Assert.assertNull(HtmlFormEntryUtil.getLocation(id)); }
String gpValue = Context.getAdministrationService().getGlobalProperty(gpName); if (StringUtils.isNotEmpty(gpValue)) { return getLocation(gpValue, context); String upValue = Context.getAuthenticatedUser().getUserProperty(upName); if (StringUtils.isNotEmpty(upValue)) { return getLocation(upValue, context); return (Location) saValue; } else if (saValue instanceof String) { return getLocation((String) saValue, context); } else { return getLocation(saValue.toString(), context);
/** * @see {@link HtmlFormEntryUtil#getLocation(String)} mapping test */ @Test @Verifies(value = "should find a location by its name", method = "getLocation(String)") public void getLocation_shouldFindALocationByItsName() throws Exception { Assert.assertEquals("2", HtmlFormEntryUtil.getLocation("Xanadu").getId().toString()); }
/** * @see {@link HtmlFormEntryUtil#getLocation(String)} this is the id|name test */ @Test @Verifies(value = "should find a location by in Id|Name format", method = "getLocation(String)") public void getLocation_shouldFindALocationInIdNameFormat() throws Exception { Assert.assertEquals("2", HtmlFormEntryUtil.getLocation("2 - Xanadu").getId().toString()); }
/** * @see {@link HtmlFormEntryUtil#getLocation(String, FormEntryContext)} * @verifies not fail if trying to find a location by session attribute and we have no session */ @Test public void getLocation_shouldNotFailIfTryingToFindALocationBySessionAttriubteAndWeHaveNoSession() { FormEntryContext formEntryContext = new FormEntryContext(FormEntryContext.Mode.ENTER); Assert.assertNull(HtmlFormEntryUtil.getLocation("SessionAttribute:someSessionAttribute", formEntryContext)); }
/** * @see {@link HtmlFormEntryUtil#getLocation(String)} id test */ @Test @Verifies(value = "should find a location by its id", method = "getLocation(String)") public void getLocation_shouldFindALocationByItsId() throws Exception { Assert.assertEquals("Xanadu", HtmlFormEntryUtil.getLocation("2").getName()); }
/** * @see {@link HtmlFormEntryUtil#getLocation(String)} this is the uuid test */ @Test @Verifies(value = "should find a location by its uuid", method = "getLocation(String)") public void getLocation_shouldFindALocationByItsUuid() throws Exception { Assert.assertEquals("Xanadu", HtmlFormEntryUtil.getLocation("9356400c-a5a2-4532-8f2b-2361b3446eb8").getName()); }
/** * @see {@link HtmlFormEntryUtil#getLocation(String, FormEntryContext)} */ @Test @Verifies(value = "should find a location by session attribute", method = "getLocation(String,FormEntrySession)") public void getLocation_shouldFindALocationBySessionAttribute() throws Exception { String attrName = "emr.sessionLocation"; MockHttpSession httpSession = new MockHttpSession(); httpSession.setAttribute(attrName, "2"); FormEntryContext formEntryContext = new FormEntryContext(FormEntryContext.Mode.ENTER); formEntryContext.setHttpSession(httpSession); Assert.assertEquals("2", HtmlFormEntryUtil.getLocation("SessionAttribute:" + attrName, formEntryContext).getId().toString()); }