use of org.apache.wiki.auth.WikiPrincipal in project jspwiki by apache.
the class DecisionQueueTest method setUp.
@Before
public void setUp() throws Exception {
Properties props = TestEngine.getTestProperties();
m_engine = new TestEngine(props);
m_queue = m_engine.getWorkflowManager().getDecisionQueue();
adminSession = m_engine.adminSession();
janneSession = m_engine.janneSession();
w = new Workflow("workflow.key", new WikiPrincipal("Owner1"));
w.setWorkflowManager(m_engine.getWorkflowManager());
d1 = new SimpleDecision(w, "decision1.key", new GroupPrincipal("Admin"));
d2 = new SimpleDecision(w, "decision2.key", new WikiPrincipal("Owner2"));
d3 = new SimpleDecision(w, "decision3.key", janneSession.getUserPrincipal());
m_queue.add(d1);
m_queue.add(d2);
m_queue.add(d3);
}
use of org.apache.wiki.auth.WikiPrincipal in project jspwiki by apache.
the class DecisionQueueTest method testReassign.
@Test
public void testReassign() throws WikiException {
// Janne owns 1 decision (d3)
Assert.assertEquals(janneSession.getUserPrincipal(), d3.getActor());
Assert.assertEquals(1, m_queue.getActorDecisions(janneSession).size());
// Reassign the decision
m_queue.reassign(d3, new WikiPrincipal("NewOwner"));
// d3 should have a different owner now, and it won't show up in
// Janne's decision list
Assert.assertEquals(new WikiPrincipal("NewOwner"), d3.getActor());
Assert.assertEquals(0, m_queue.getActorDecisions(janneSession).size());
}
use of org.apache.wiki.auth.WikiPrincipal in project jspwiki by apache.
the class TaskTest method testGetActor.
@Test
public void testGetActor() {
Assert.assertNotSame(new WikiPrincipal("Actor1"), m_task.getActor());
Assert.assertEquals(SystemPrincipal.SYSTEM_USER, m_task.getActor());
}
use of org.apache.wiki.auth.WikiPrincipal in project jspwiki by apache.
the class TaskTest method testSuccessors.
@Test
public void testSuccessors() {
// If task finishes normally, branch to a decision (d1)
Step d1 = new SimpleDecision(m_workflow, "decision1.key", new WikiPrincipal("Actor1"));
m_task.addSuccessor(Outcome.STEP_COMPLETE, d1);
// If the task aborts, branch to an alternate decision (d2)
Step d2 = new SimpleDecision(m_workflow, "decision2.key", new WikiPrincipal("Actor2"));
m_task.addSuccessor(Outcome.STEP_ABORT, d2);
Assert.assertEquals(d1, m_task.getSuccessor(Outcome.STEP_COMPLETE));
Assert.assertEquals(d2, m_task.getSuccessor(Outcome.STEP_ABORT));
// The other Outcomes should return null when looked up
Assert.assertNull(m_task.getSuccessor(Outcome.DECISION_APPROVE));
Assert.assertNull(m_task.getSuccessor(Outcome.DECISION_DENY));
Assert.assertNull(m_task.getSuccessor(Outcome.DECISION_HOLD));
Assert.assertNull(m_task.getSuccessor(Outcome.DECISION_REASSIGN));
Assert.assertNull(m_task.getSuccessor(Outcome.STEP_CONTINUE));
}
use of org.apache.wiki.auth.WikiPrincipal in project jspwiki by apache.
the class WorkflowManagerTest method testGetApprover.
@Test
public void testGetApprover() throws WikiException {
// Test properties says workflow.saveWikiPage approver is GP Admin; workflow.foo is 'janne'
Assert.assertEquals(new WikiPrincipal("janne", WikiPrincipal.LOGIN_NAME), wm.getApprover("workflow.foo"));
Assert.assertEquals(new GroupPrincipal("Admin"), wm.getApprover("workflow.bar"));
// 'saveWikiPage' workflow doesn't require approval, so we will need to catch an Exception
try {
Assert.assertEquals(new GroupPrincipal("Admin"), wm.getApprover("workflow.saveWikiPage"));
} catch (WikiException e) {
// Swallow
return;
}
// We should never get here
Assert.fail("Workflow.bar doesn't need approval!");
}
Aggregations