Package com.ecyrd.jspwiki.auth

Examples of com.ecyrd.jspwiki.auth.WikiPrincipal


    Decision m_decision;

    protected void setUp() throws Exception
    {
        super.setUp();
        m_workflow = new Workflow("workflow.key", new WikiPrincipal("Owner1"));
        m_decision = new SimpleDecision(m_workflow, "decision.key", new WikiPrincipal("Actor1"));
    }
View Full Code Here


        assertEquals(f3, facts.get(2));
    }

    public void testGetActor()
    {
       assertEquals(new WikiPrincipal("Actor1"), m_decision.getActor());
    }
View Full Code Here

        assertTrue(m_decision.isReassignable());
    }

    public void testReassign()
    {
        m_decision.reassign(new WikiPrincipal("Actor2"));
        assertEquals(new WikiPrincipal("Actor2"), m_decision.getActor());
    }
View Full Code Here

    }

    public void testSuccessors()
    {
        // If the decision is approved, branch to another decision (d2)
        Step d2 = new SimpleDecision(m_workflow, "decision2.key", new WikiPrincipal("Actor1"));
        m_decision.addSuccessor(Outcome.DECISION_APPROVE, d2);

        // If the decision is denied, branch to another decision (d3)
        Step d3 = new SimpleDecision(m_workflow, "decision3.key", new WikiPrincipal("Actor1"));
        m_decision.addSuccessor(Outcome.DECISION_DENY, d3);

        assertEquals(d2, m_decision.getSuccessor(Outcome.DECISION_APPROVE));
        assertEquals(d3, m_decision.getSuccessor(Outcome.DECISION_DENY));
View Full Code Here

        Properties props = new Properties();
        props.load(TestEngine.findTestProperties());
        m_engine = new TestEngine(props);
        wm = m_engine.getWorkflowManager();
        // Create a workflow with 3 steps, with a Decision in the middle
        w = new Workflow("workflow.key", new WikiPrincipal("Owner1"));
        w.setWorkflowManager(m_engine.getWorkflowManager());
        Step startTask = new TaskTest.NormalTask(w);
        Step endTask = new TaskTest.NormalTask(w);
        Decision decision = new SimpleDecision(w, "decision.editWikiApproval", new WikiPrincipal("Actor1"));
        startTask.addSuccessor(Outcome.STEP_COMPLETE, decision);
        decision.addSuccessor(Outcome.DECISION_APPROVE, endTask);
        w.setFirstStep(startTask);
       
        // Add a message argument to the workflow with the page name
View Full Code Here

    }

    public void testGetApprover() throws WikiException
    {
        // Test properties says workflow.saveWikiPage approver is GP Admin; workflow.foo is 'janne'
        assertEquals(new WikiPrincipal("janne", WikiPrincipal.LOGIN_NAME), wm.getApprover("workflow.foo"));
        assertEquals(new GroupPrincipal("Admin"), wm.getApprover("workflow.bar"));
       
        // 'saveWikiPage' workflow doesn't require approval, so we will need to catch an Exception
        try
        {
View Full Code Here


    public void testBuildApprovalWorkflow() throws WikiException
    {

        Principal submitter = new WikiPrincipal( "Submitter" );
        String workflowApproverKey = "workflow.approvalWorkflow";
        Task prepTask = new TestPrepTask( "task.preSaveWikiPage" );
        String decisionKey = "decision.saveWikiPage";
        Fact[] facts = new Fact[3];
        facts[0] = new Fact("fact1",new Integer(1));
        facts[1] = new Fact("fact2","A factual String");
        facts[2] = new Fact("fact3",Outcome.DECISION_ACKNOWLEDGE);
        Task completionTask = new TestPrepTask( "task.saveWikiPage" );
        String rejectedMessageKey = "notification.saveWikiPage.reject";

        Workflow w = m_builder.buildApprovalWorkflow(submitter, workflowApproverKey,
                                                   prepTask, decisionKey, facts,
                                                   completionTask, rejectedMessageKey);
        w.setWorkflowManager( m_engine.getWorkflowManager() );

        // Check to see if the workflow built correctly
        assertFalse( w.isStarted() || w.isCompleted() || w.isAborted() );
        assertNull( w.getCurrentStep() );
        assertEquals( "workflow.approvalWorkflow", w.getMessageKey() );
        assertEquals( Workflow.CREATED, w.getCurrentState() );
        assertEquals( new WikiPrincipal("Submitter"), w.getOwner() );
        assertEquals( m_engine.getWorkflowManager(), w.getWorkflowManager() );
        assertEquals( 0, w.getHistory().size() );

        // Our dummy "task complete" attributes should still be null
        assertNull( w.getAttribute( "task.preSaveWikiPage") );
        assertNull( w.getAttribute( "task.saveWikiPage") );

        // Start the workflow
        w.start();

        // Presave complete attribute should be set now, and current step should be Decision
        Step decision = w.getCurrentStep();
        assertTrue( decision instanceof Decision );
        assertEquals( 2, w.getHistory().size() );
        assertEquals( prepTask, w.getHistory().get( 0 ) );
        assertTrue( w.getHistory().get( 1 ) instanceof Decision );
        assertNotNull( w.getAttribute( "task.preSaveWikiPage") );
        assertEquals( new WikiPrincipal( Users.JANNE ), decision.getActor() );
        assertEquals( decisionKey, decision.getMessageKey() );
        List decisionFacts = ((Decision)decision).getFacts();
        assertEquals( 3, decisionFacts.size() );
        assertEquals( facts[0], decisionFacts.get(0) );
        assertEquals( facts[1], decisionFacts.get(1) );
View Full Code Here

        assertEquals( Outcome.STEP_COMPLETE, completionTask.getOutcome() );
    }

    public void testBuildApprovalWorkflowDeny() throws WikiException
    {
        Principal submitter = new WikiPrincipal( "Submitter" );
        String workflowApproverKey = "workflow.approvalWorkflow";
        Task prepTask = new TestPrepTask( "task.preSaveWikiPage" );
        String decisionKey = "decision.saveWikiPage";
        Fact[] facts = new Fact[3];
        facts[0] = new Fact("fact1",new Integer(1));
View Full Code Here

      int oldUserCount = m_db.groups().length;

      // Create a new group with random name
      String name = "TestGroup" + String.valueOf( System.currentTimeMillis() );
      Group group = new Group( name, m_wiki );
      Principal al = new WikiPrincipal( "Al" );
      Principal bob = new WikiPrincipal( "Bob" );
      group.add( al );
      group.add( bob );
      m_db.save(group, new WikiPrincipal( "Tester") );

      // Make sure the profile saved successfully
      group = backendGroup( name );
      assertEquals( name, group.getName() );
      assertEquals( oldUserCount+1, m_db.groups().length );
View Full Code Here

  public void testSave() throws Exception
  {
      // Create a new group with random name
      String name = "TestGroup" + String.valueOf( System.currentTimeMillis() );
      Group group = new Group( name, m_wiki );
      Principal al = new WikiPrincipal( "Al" );
      Principal bob = new WikiPrincipal( "Bob" );
      Principal cookie = new WikiPrincipal( "Cookie" );
      group.add( al );
      group.add( bob );
      group.add( cookie );
      m_db.save(group, new WikiPrincipal( "Tester" ) );

      // Make sure the profile saved successfully
      group = backendGroup( name );
      assertEquals( name, group.getName() );
      assertEquals( 3, group.members().length );
      assertTrue( group.isMember( new WikiPrincipal( "Al" ) ) );
      assertTrue( group.isMember( new WikiPrincipal( "Bob" ) ) );
      assertTrue( group.isMember( new WikiPrincipal( "Cookie" ) ) );

      // The back-end should have timestamped the create/modify fields
      assertNotNull( group.getCreator() );
      assertEquals( "Tester", group.getCreator() );
      assertNotNull( group.getCreated() );
View Full Code Here

TOP

Related Classes of com.ecyrd.jspwiki.auth.WikiPrincipal

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.