use of org.apache.wiki.api.core.Command in project jspwiki by apache.
the class PageCommandTest method testStaticCommand.
@Test
public void testStaticCommand() {
Command a = PageCommand.VIEW;
Assertions.assertEquals("view", a.getRequestContext());
Assertions.assertEquals("Wiki.jsp", a.getJSP());
Assertions.assertEquals("%uWiki.jsp?page=%n", a.getURLPattern());
Assertions.assertEquals("PageContent.jsp", a.getContentTemplate());
Assertions.assertNull(a.getTarget());
Assertions.assertNull(a.requiredPermission());
Assertions.assertEquals(a, PageCommand.VIEW);
a = PageCommand.EDIT;
Assertions.assertEquals("edit", a.getRequestContext());
Assertions.assertEquals("Edit.jsp", a.getJSP());
Assertions.assertEquals("%uEdit.jsp?page=%n", a.getURLPattern());
Assertions.assertEquals("EditContent.jsp", a.getContentTemplate());
Assertions.assertNull(a.getTarget());
Assertions.assertNull(a.requiredPermission());
Assertions.assertEquals(a, PageCommand.EDIT);
a = PageCommand.PREVIEW;
Assertions.assertEquals("preview", a.getRequestContext());
Assertions.assertEquals("Preview.jsp", a.getJSP());
Assertions.assertEquals("%uPreview.jsp?page=%n", a.getURLPattern());
Assertions.assertEquals("PreviewContent.jsp", a.getContentTemplate());
Assertions.assertNull(a.getTarget());
Assertions.assertNull(a.requiredPermission());
Assertions.assertEquals(a, PageCommand.PREVIEW);
}
use of org.apache.wiki.api.core.Command in project jspwiki by apache.
the class PageCommandTest method testTargetedCommand.
@Test
public void testTargetedCommand() throws Exception {
final TestEngine testEngine = TestEngine.build();
testEngine.saveText("TestPage", "This is a test.");
final Page testPage = testEngine.getManager(PageManager.class).getPage("TestPage");
// Get view command
Command a = PageCommand.VIEW;
// Combine with wiki page; make sure it's not equal to old command
Command b = a.targetedCommand(testPage);
Assertions.assertNotSame(a, b);
Assertions.assertEquals(a.getRequestContext(), b.getRequestContext());
Assertions.assertEquals(a.getJSP(), b.getJSP());
Assertions.assertEquals(a.getURLPattern(), b.getURLPattern());
Assertions.assertEquals(a.getContentTemplate(), b.getContentTemplate());
Assertions.assertNotNull(b.getTarget());
Assertions.assertNotNull(b.requiredPermission());
Assertions.assertEquals(PermissionFactory.getPagePermission(testPage, "view"), b.requiredPermission());
Assertions.assertEquals(testPage, b.getTarget());
// Do the same with edit command
a = PageCommand.EDIT;
b = a.targetedCommand(testPage);
Assertions.assertNotSame(a, b);
Assertions.assertNotNull(b.getTarget());
Assertions.assertNotNull(b.requiredPermission());
Assertions.assertEquals(PermissionFactory.getPagePermission(testPage, "edit"), b.requiredPermission());
Assertions.assertEquals(testPage, b.getTarget());
// Do the same with delete command
a = PageCommand.DELETE;
b = a.targetedCommand(testPage);
Assertions.assertNotSame(a, b);
Assertions.assertNotNull(b.getTarget());
Assertions.assertNotNull(b.requiredPermission());
Assertions.assertEquals(PermissionFactory.getPagePermission(testPage, "delete"), b.requiredPermission());
Assertions.assertEquals(testPage, b.getTarget());
// Do the same with info command
a = PageCommand.INFO;
b = a.targetedCommand(testPage);
Assertions.assertNotSame(a, b);
Assertions.assertNotNull(b.getTarget());
Assertions.assertNotNull(b.requiredPermission());
Assertions.assertEquals(PermissionFactory.getPagePermission(testPage, "view"), b.requiredPermission());
Assertions.assertEquals(testPage, b.getTarget());
}
Aggregations