|
21 | 21 |
|
22 | 22 | import static io.wcm.handler.link.LinkNameConstants.PN_COMPONENT_LINK_TARGET_URL_FALLBACK_PROPERTY; |
23 | 23 | import static io.wcm.handler.link.LinkNameConstants.PN_COMPONENT_LINK_TARGET_WINDOW_TARGET_FALLBACK_PROPERTY; |
| 24 | +import static io.wcm.handler.link.LinkNameConstants.PN_LINK_EXTERNAL_REF; |
| 25 | +import static io.wcm.handler.link.LinkNameConstants.PN_LINK_TITLE; |
24 | 26 | import static io.wcm.handler.link.LinkNameConstants.PN_LINK_TYPE; |
25 | 27 | import static org.junit.jupiter.api.Assertions.assertEquals; |
26 | 28 | import static org.junit.jupiter.api.Assertions.assertFalse; |
27 | 29 | import static org.junit.jupiter.api.Assertions.assertNotNull; |
| 30 | +import static org.junit.jupiter.api.Assertions.assertNull; |
28 | 31 |
|
29 | 32 | import java.util.List; |
30 | 33 | import java.util.Map; |
|
48 | 51 | import io.wcm.handler.link.spi.LinkProcessor; |
49 | 52 | import io.wcm.handler.link.spi.LinkType; |
50 | 53 | import io.wcm.handler.link.testcontext.AppAemContext; |
| 54 | +import io.wcm.handler.link.type.ExternalLinkType; |
51 | 55 | import io.wcm.handler.url.UrlModes; |
52 | 56 | import io.wcm.sling.commons.adapter.AdaptTo; |
53 | 57 | import io.wcm.sling.commons.resource.ImmutableValueMap; |
@@ -189,6 +193,26 @@ void testLinkHandlerCustomProperty() { |
189 | 193 | assertEquals("value1", link.getLinkRequest().getLinkArgs().getProperties().get("prop1")); |
190 | 194 | } |
191 | 195 |
|
| 196 | + @Test |
| 197 | + void testLinkGetTitle() { |
| 198 | + LinkHandler linkHandler = AdaptTo.notNull(adaptable(), LinkHandler.class); |
| 199 | + |
| 200 | + Resource linkResource = context.create().resource("/content/dummy-path", |
| 201 | + PN_LINK_TYPE, ExternalLinkType.ID, |
| 202 | + PN_LINK_EXTERNAL_REF, "http://dummy", |
| 203 | + PN_LINK_TITLE, "My Link Title"); |
| 204 | + |
| 205 | + Link link = linkHandler.get(linkResource).build(); |
| 206 | + assertEquals("My Link Title", link.getTitle()); |
| 207 | + } |
| 208 | + |
| 209 | + @Test |
| 210 | + void testLinkGetTitleWithoutResourceProperties() { |
| 211 | + LinkHandler linkHandler = AdaptTo.notNull(adaptable(), LinkHandler.class); |
| 212 | + |
| 213 | + Link link = linkHandler.get("http://dummy").build(); |
| 214 | + assertNull(link.getTitle()); |
| 215 | + } |
192 | 216 |
|
193 | 217 | public static class TestLinkHandlerConfig extends LinkHandlerConfig { |
194 | 218 |
|
|
0 commit comments