Search in sources :

Example 11 with MockNode

use of info.magnolia.test.mock.jcr.MockNode in project magnolia-vanity-url by aperto.

the class DefaultPublicUrlServiceTest method testInternalTarget.

@Test
public void testInternalTarget() throws Exception {
    MockNode mockNode = new MockNode("node");
    mockNode.setProperty(PN_VANITY_URL, "/aperto");
    mockNode.setProperty(PN_LINK, "123-456-789");
    assertThat(_service.createTargetUrl(mockNode), equalTo("http://www.aperto.de/context/page.html"));
    assertThat(_service.createVanityUrl(mockNode), equalTo("http://www.aperto.de/aperto"));
}
Also used : MockNode(info.magnolia.test.mock.jcr.MockNode) Test(org.junit.Test)

Example 12 with MockNode

use of info.magnolia.test.mock.jcr.MockNode in project magnolia-vanity-url by aperto.

the class DefaultPublicUrlServiceTest method testInternalTargetWithConfiguredTargetContextPath.

@Test
public void testInternalTargetWithConfiguredTargetContextPath() throws Exception {
    MockNode mockNode = new MockNode("node");
    mockNode.setProperty(PN_VANITY_URL, "/aperto");
    mockNode.setProperty(PN_LINK, "123-456-789");
    _service.setTargetContextPath("/public");
    assertThat(_service.createTargetUrl(mockNode), equalTo("http://www.aperto.de/context/page.html"));
    assertThat(_service.createVanityUrl(mockNode), equalTo("http://www.aperto.de/public/aperto"));
}
Also used : MockNode(info.magnolia.test.mock.jcr.MockNode) Test(org.junit.Test)

Example 13 with MockNode

use of info.magnolia.test.mock.jcr.MockNode in project magnolia-vanity-url by aperto.

the class VanityUrlServiceTest method testTargetUrlInternalWithAnchor.

@Test
public void testTargetUrlInternalWithAnchor() throws Exception {
    MockNode mockNode = new MockNode("node");
    mockNode.setProperty("link", TEST_UUID);
    mockNode.setProperty("linkSuffix", "#anchor1");
    assertThat(_service.createRedirectUrl(mockNode), equalTo("redirect:/internal/page.html#anchor1"));
    assertThat(_service.createPreviewUrl(mockNode), equalTo("/internal/page.html#anchor1"));
}
Also used : MockNode(info.magnolia.test.mock.jcr.MockNode) Test(org.junit.Test)

Example 14 with MockNode

use of info.magnolia.test.mock.jcr.MockNode in project magnolia-vanity-url by aperto.

the class VanityUrlServiceTest method testForwardWithAnchor.

@Test
public void testForwardWithAnchor() throws Exception {
    MockNode mockNode = new MockNode("node");
    mockNode.setProperty("link", TEST_UUID_FORWARD);
    mockNode.setProperty("type", "forward");
    mockNode.setProperty("linkSuffix", "#anchor1");
    assertThat(_service.createRedirectUrl(mockNode), equalTo("forward:/internal/forward/page.html#anchor1"));
}
Also used : MockNode(info.magnolia.test.mock.jcr.MockNode) Test(org.junit.Test)

Example 15 with MockNode

use of info.magnolia.test.mock.jcr.MockNode in project magnolia-vanity-url by aperto.

the class VanityUrlServiceTest method testForwardWithInvalidUrl.

@Test
public void testForwardWithInvalidUrl() throws Exception {
    MockNode mockNode = new MockNode("node");
    mockNode.setProperty("link", "http://www.aperto.de");
    mockNode.setProperty("type", "forward");
    assertThat(_service.createRedirectUrl(mockNode), equalTo(""));
}
Also used : MockNode(info.magnolia.test.mock.jcr.MockNode) Test(org.junit.Test)

Aggregations

MockNode (info.magnolia.test.mock.jcr.MockNode)18 Test (org.junit.Test)16 ModuleRegistry (info.magnolia.module.ModuleRegistry)1 HashMap (java.util.HashMap)1 Provider (javax.inject.Provider)1 Before (org.junit.Before)1