@Test public void urlBind_shouldProperlyBindPatientAndVisit() { UiUtils ui = Mockito.mock(UiUtils.class); Mockito.when(ui.urlBind(anyString(), any(Visit.class))).thenCallRealMethod(); Mockito.when(ui.urlBind(anyString(), any(Patient.class))).thenCallRealMethod(); Patient patient = new Patient(2); patient.setUuid("patient_uuid"); Visit visit = new Visit(3); visit.setUuid("visit_uuid"); visit.setPatient(patient); String url = "someUrl.page?patientId={{patientId}}&patientId={{patient.id}}&patient={{patient.uuid}}&patientUuid={{patientUuid}}&patientid={{patient.patientId}}&visitId={{visitId}}&visit.id={{visit.id}}&visit={{visit.uuid}}&visitUuid={{visitUuid}}&visit={{visit.visitId}}"; Assert.assertEquals("someUrl.page?patientId=2&patientId=2&patient=patient_uuid&patientUuid=patient_uuid&patientid=2&visitId=3&visit.id=3&visit=visit_uuid&visitUuid=visit_uuid&visit=3", ui.urlBind(url, visit)); }
public String urlBind(String url, Visit visit) { url = url.replace("{{visitId}}", visit.getId().toString()); url = url.replace("{{visit.id}}", visit.getId().toString()); url = url.replace("{{visit.visitId}}", visit.getId().toString()); url = url.replace("{{visit.uuid}}", visit.getUuid()); url = url.replace("{{visitUuid}}", visit.getUuid()); url = urlBind(url, visit.getPatient()); return url; }
UiUtils { public String urlBind(String url, Visit visit) { url = url.replace("{{visitId}}", visit.getId().toString()); url = url.replace("{{visit.id}}", visit.getId().toString()); url = url.replace("{{visit.visitId}}", visit.getId().toString()); url = url.replace("{{visit.uuid}}", visit.getUuid()); url = url.replace("{{visitUuid}}", visit.getUuid()); url = urlBind(url, visit.getPatient()); return url; } }
UiUtils { public String urlBind(String url, Visit visit) { url = url.replace("{{visitId}}", visit.getId().toString()); url = url.replace("{{visit.id}}", visit.getId().toString()); url = url.replace("{{visit.visitId}}", visit.getId().toString()); url = url.replace("{{visit.uuid}}", visit.getUuid()); url = url.replace("{{visitUuid}}", visit.getUuid()); url = urlBind(url, visit.getPatient()); return url; }  }
UiUtils { public String urlBind(String url, Visit visit) { url = url.replace("{{visitId}}", visit.getId().toString()); url = url.replace("{{visit.id}}", visit.getId().toString()); url = url.replace("{{visit.visitId}}", visit.getId().toString()); url = url.replace("{{visit.uuid}}", visit.getUuid()); url = url.replace("{{visitUuid}}", visit.getUuid()); url = urlBind(url, visit.getPatient()); return url; }  void includeCss(String file); void includeCss(String providerName, String file); void includeCss(String providerName, String file, Integer priority); void includeCss(String providerName, String file, Integer priority, boolean pathIsRelativeToStyles); void includeJavascript(String file); void includeJavascript(String providerName, String file); void includeJavascript(String providerName, String file, Integer priority); void includeJavascript(String providerName, String file, Integer priority, boolean pathIsRelativeToScripts); String resourceLinks(); String thisUrl(); String thisUrlWithContextPath(); String startForm(String providerName, String fragment, String action); String startForm(String providerName, String fragment, String action, Map<String, CharSequence> parameters); String endForm(); String message(String code, Object... args); String includeFragment(String providerName, String fragmentId); String includeFragment(String providerName, String fragmentId, Map<String, Object> config); void decorateWith(String providerName, String fragmentId); void decorateWith(String providerName, String fragmentId, Map<String, Object> config); String decorate(String providerName, String decoratorName, String contents); String decorate(String providerName, String decoratorName, Map<String, Object> decoratorConfig, String contents); String contextPath(); String resourceLink(String path); String resourceLink(String providerName, String path); String pageLink(String providerName, String pageName); String pageLinkWithoutContextPath(String providerName, String pageName, Map<String, Object> params); String pageLink(String providerName, String pageName, Map<String, Object> params); String actionLink(String providerName, String controllerName, String action); String actionLink(String providerName, String controllerName, String action, Map<String, ?> args); Object urlEncode(CharSequence string); String urlBind(String url, Visit visit); String urlBind(String url, Patient patient); String urlBind(String url, Map<String, Object> bindings); String dateToString(Date date); String dateToISOString(Date date); String formatDatePretty(Date date); String formatDatetimePretty(Date date); String format(Object o); String formatTimeAgo(Date date); @Deprecated String formatAsText(Object o); static String randomId(String prefix); String escapeJs(String input); String encodeForSafeURL(String input); String encodeJavaScriptAttribute(String input); String encodeJavaScript(String input); String encodeJavaScriptBlock(String input); String encodeJavaScriptSource(String input); String encodeHtmlContent(String input); String encodeHtmlAttribute(String input); String encodeHtml(String input); String escapeAttribute(String input); String escapeHtml(String input); ExtensionManager getExtensionManager(); T convert(Object fromValue, Class<T> clazz); SimpleObject simplifyObject(Object complex); SimpleObject[] simplifyCollection(Collection<?> complex); String toJson(Object object); void validate(Object target, Validator validator, String bindingPrefix); Locale getLocale(); void setLocale(Locale locale); }
UiUtils { public String urlBind(String url, Visit visit) { url = url.replace("{{visitId}}", visit.getId().toString()); url = url.replace("{{visit.id}}", visit.getId().toString()); url = url.replace("{{visit.visitId}}", visit.getId().toString()); url = url.replace("{{visit.uuid}}", visit.getUuid()); url = url.replace("{{visitUuid}}", visit.getUuid()); url = urlBind(url, visit.getPatient()); return url; }  void includeCss(String file); void includeCss(String providerName, String file); void includeCss(String providerName, String file, Integer priority); void includeCss(String providerName, String file, Integer priority, boolean pathIsRelativeToStyles); void includeJavascript(String file); void includeJavascript(String providerName, String file); void includeJavascript(String providerName, String file, Integer priority); void includeJavascript(String providerName, String file, Integer priority, boolean pathIsRelativeToScripts); String resourceLinks(); String thisUrl(); String thisUrlWithContextPath(); String startForm(String providerName, String fragment, String action); String startForm(String providerName, String fragment, String action, Map<String, CharSequence> parameters); String endForm(); String message(String code, Object... args); String includeFragment(String providerName, String fragmentId); String includeFragment(String providerName, String fragmentId, Map<String, Object> config); void decorateWith(String providerName, String fragmentId); void decorateWith(String providerName, String fragmentId, Map<String, Object> config); String decorate(String providerName, String decoratorName, String contents); String decorate(String providerName, String decoratorName, Map<String, Object> decoratorConfig, String contents); String contextPath(); String resourceLink(String path); String resourceLink(String providerName, String path); String pageLink(String providerName, String pageName); String pageLinkWithoutContextPath(String providerName, String pageName, Map<String, Object> params); String pageLink(String providerName, String pageName, Map<String, Object> params); String actionLink(String providerName, String controllerName, String action); String actionLink(String providerName, String controllerName, String action, Map<String, ?> args); Object urlEncode(CharSequence string); String urlBind(String url, Visit visit); String urlBind(String url, Patient patient); String urlBind(String url, Map<String, Object> bindings); String dateToString(Date date); String dateToISOString(Date date); String formatDatePretty(Date date); String formatDatetimePretty(Date date); String format(Object o); String formatTimeAgo(Date date); @Deprecated String formatAsText(Object o); static String randomId(String prefix); String escapeJs(String input); String encodeForSafeURL(String input); String encodeJavaScriptAttribute(String input); String encodeJavaScript(String input); String encodeJavaScriptBlock(String input); String encodeJavaScriptSource(String input); String encodeHtmlContent(String input); String encodeHtmlAttribute(String input); String encodeHtml(String input); String escapeAttribute(String input); String escapeHtml(String input); ExtensionManager getExtensionManager(); T convert(Object fromValue, Class<T> clazz); SimpleObject simplifyObject(Object complex); SimpleObject[] simplifyCollection(Collection<?> complex); String toJson(Object object); void validate(Object target, Validator validator, String bindingPrefix); Locale getLocale(); void setLocale(Locale locale);  }