florianMo commented on code in PR #547:
URL: https://github.com/apache/ofbiz-framework/pull/547#discussion_r988848815
##########
framework/widget/src/test/java/org/apache/ofbiz/widget/renderer/macro/MacroFormRendererTest.java:
##########
@@ -887,6 +887,55 @@ public void renderSortFieldUsesQueryString(@Mocked
ModelForm modelForm) throws I
"linkUrl", new FreemarkerRawString(linkFromQbeString)));
}
+ @Test
+ public void hyperlinkFieldMacroRenderedTitleNotTruncated(@Mocked
ModelFormField.HyperlinkField hyperlinkField) throws IOException {
+ final String description = "DESCRIPTION";
+ final String title = "TITLE";
+
+ new Expectations() {
+ {
+ hyperlinkField.getDescription(withNotNull()); result =
description;
+ hyperlinkField.getTarget(withNotNull()); result = "#";
+ request.getAttribute("title"); result = title;
+ }
+ };
+
+ macroFormRenderer.renderHyperlinkField(appendable, new HashMap<>(),
hyperlinkField);
+ assertAndGetMacroString("makeHyperlinkString",
ImmutableMap.of("description", description, "title", title));
+ }
+
+ @Test
+ public void hyperlinkFieldMacroRenderedTruncatedNoTitle(@Mocked
ModelFormField.HyperlinkField hyperlinkField) throws IOException {
+ final String description = "DESCRIPTION";
+
+ new Expectations() {
+ {
+ hyperlinkField.getDescription(withNotNull()); result =
description;
+ hyperlinkField.getTarget(withNotNull()); result = "#";
+ request.getAttribute("descriptionSize"); result = 5;
+ }
+ };
+
+ macroFormRenderer.renderHyperlinkField(appendable, new HashMap<>(),
hyperlinkField);
+ assertAndGetMacroString("makeHyperlinkString",
ImmutableMap.of("description", "DESCR…", "title", description));
+ }
+
+ @Test
+ public void hyperlinkFieldMacroRenderedTruncatedWithTitle(@Mocked
ModelFormField.HyperlinkField hyperlinkField) throws IOException {
+ final String description = "DESCRIPTION";
+
+ new Expectations() {
+ {
+ hyperlinkField.getDescription(withNotNull()); result =
description;
+ hyperlinkField.getTarget(withNotNull()); result = "#";
+ request.getAttribute("descriptionSize"); result = 5;
+ }
+ };
+
+ macroFormRenderer.renderHyperlinkField(appendable, new HashMap<>(),
hyperlinkField);
+ assertAndGetMacroString("makeHyperlinkString",
ImmutableMap.of("description", "DESCR…", "title", description));
Review Comment:
The `#` is provided for `target` attribute, to avoid a NPE in the rendering
process (`buildHyperlinkUri` calls `Parser.unescapeEntities` on `target`).
But indeed something is unclear here. If description is truncated, then
request.getAttribute("title") is not even called. I'll add
`hyperlinkField.getTitle(); result = title;` to make clear that we provide a
`title`, which is overriden by `description` because we have an ellipsis.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]