Package org.intalio.tempo.workflow.task

Examples of org.intalio.tempo.workflow.task.PATask


        "Expecting zero task left for the current user");
  }

  @Test
  public void updateMetadata() throws Exception {
    PATask task = getSampleTask(TaskState.READY);
    task.getUserOwners().add("niko");
    String id = task.getID();
    task.setPriority(1);
    connection.createTask(task);
    connection.commit();
    PATask loaded = (PATask)connection.fetchTaskIfExists(id);
    Assert.assertEquals(1, (int)task.getPriority());
    loaded.setPriority(5);
    connection.createTask(loaded);
    connection.commit();
    PATask loaded2 = (PATask)connection.fetchTaskIfExists(id);
    Assert.assertEquals(id, (String)loaded2.getID());
    Assert.assertEquals(5, (int)loaded2.getPriority());
    Assert.assertTrue(loaded2.getUserOwners().contains("niko"));
  }
View Full Code Here


  }

  private PATask getSampleTask(TaskState state) throws URISyntaxException,
      Exception {
    String id = String.valueOf(new Object().hashCode());
    PATask task1 = new PATask(id, new URI("http://hellonico.net"),
        "processId", "soap", getXmlSampleDocument());
    task1.authorizeActionForUser("save", "examples\\manager");
    task1.setPriority(2);
    task1.setState(state);
    task1.getRoleOwners().add("role1");
    task1.getUserOwners().add("user1");
    return task1;
  }
View Full Code Here

    case NOTIFICATION:
      return new Notification(id, uri, xml.parseXML("<hello/>"));
    case PIPA:
      return new PIPATask(id, uri, uri, uri, "initOperationSOAPAction");
    case PA:
      return new PATask(id, new URI("http://hellonico.net"), "processId",
          "soap", xml.parseXML("<hello/>"));
    default:
      int rand = random.nextInt(3);
      switch (rand) {
      case 0:
        return new PATask(id, new URI("http://hellonico.net"),
            "processId", "soap", xml.parseXML("<hello/>"));
      case 1:
        return new PIPATask(id, uri, uri, uri,
            "initOperationSOAPAction");
      default:
View Full Code Here

    }

    public void testPATaskLifecycle() throws Exception {
        ITMSServer server = Utils.createTMSServer();

        PATask paTask = new PATask("taskID", new URI("http://localhost/1"), "processID", "urn:completeSOAPAction", Utils.createXMLDocument());
        paTask.getUserOwners().add("test/user1");
        paTask.getRoleOwners().add("test/role3");
       
        paTask.getUserOwners().add("test/user1");
        paTask.getRoleOwners().add("test/role3");
        ITaskDAOConnectionFactory daoFactory=new SimpleTaskDAOConnectionFactory();
        ITaskDAOConnection dao=daoFactory.openConnection();
        server.create(dao,paTask, "token1");

        TaskEquality.areTasksEquals(paTask, server.getTask(dao,"taskID", "token1"));
        TaskEquality.areTasksEquals(paTask, server.getTask(dao,"taskID", "token2"));
        TaskEquality.areTasksEquals(paTask, server.getTaskList(dao,"token1")[0]);
        TaskEquality.areTasksEquals(paTask, server.getTaskList(dao,"token2")[0]);
        try {
            server.getTask(dao,"taskID", "token3");
            Assert.fail("AccessDeniedException expected");
        } catch (AccessDeniedException e) {

        }
        Assert.assertEquals(0, server.getTaskList(dao,"token3").length);
       
        Document newOutput1 = Utils.createXMLDocument();
        server.setOutput(dao,"taskID", newOutput1, "token1");
        PATask taskWithSetOutput = (PATask) server.getTask(dao,"taskID", "token2");
        Assert.assertTrue(XmlTooling.equals(newOutput1, taskWithSetOutput.getOutput()));
        Assert.assertEquals(TaskState.READY, taskWithSetOutput.getState());
       
        // test reassign
        org.intalio.tempo.workflow.auth.AuthIdentifierSet newUsers = new org.intalio.tempo.workflow.auth.AuthIdentifierSet(new String[]{"test/user1", "test/user2"});
        org.intalio.tempo.workflow.auth.AuthIdentifierSet newRoles = new org.intalio.tempo.workflow.auth.AuthIdentifierSet(new String[]{"test/role2", "test/role3"});
        server.reassign(dao,"taskID", newUsers, newRoles, TaskState.READY, "token1");

        Document newOutput2 = Utils.createXMLDocument();
        server.setOutputAndComplete(dao,"taskID", newOutput2, "token2");
        PATask completedTask = (PATask) server.getTask(dao,"taskID", "token1");
        Assert.assertTrue(XmlTooling.equals(newOutput2, completedTask.getOutput()));
        Assert.assertEquals(TaskState.COMPLETED, completedTask.getState());

        String failureCode = "failure-code";
        String failureReason = "failure reason";
        server.fail(dao,"taskID", failureCode, failureReason, "token1");
        PATask failedTask = (PATask) server.getTask(dao,"taskID", "token2");
        Assert.assertEquals(TaskState.FAILED, failedTask.getState());
        Assert.assertEquals(failureCode, failedTask.getFailureCode());
        Assert.assertEquals(failureReason, failedTask.getFailureReason());

        try {
            server.delete(dao,new String[] { "taskID" }, "token1");
            Assert.fail("AuthException expected");
        } catch (UnavailableTaskException e) {
View Full Code Here

        }

    }

    private PATask getPATask(String id) throws URISyntaxException, Exception {
        PATask pa = new PATask(id, new URI("http://localhost/1"), "processID", "urn:completeSOAPAction", Utils.createXMLDocument());
        pa.getUserOwners().add("test/user1");
        pa.getRoleOwners().add("test/role3");
        return pa;
    }
View Full Code Here

    }
   
    public void testCanUpdatePriority() throws Exception {
        ITMSServer server = Utils.createTMSServerJPA();
        String id = ""+System.currentTimeMillis();
        PATask pa = getPATask(id);
        ITaskDAOConnectionFactory daoFactory=new SimpleTaskDAOConnectionFactory();
        ITaskDAOConnection dao=daoFactory.openConnection();
        server.create(dao,pa, "token1");
        TaskMetadata metadata = TaskMetadata.Factory.newInstance()
        metadata.setTaskId(id);
       
        metadata.setPriority(5);
        metadata.setDescription("desc2");
        //Date date = new Date();
        //tu.setDeadline(date);
       
        server.update(dao,metadata, "token1");
        PATask pa2 = (PATask) server.getTask(dao,pa.getID(), "token1");
        Assert.assertNotNull(pa2);
       
        Assert.assertEquals(5, (int)pa2.getPriority());
        Assert.assertEquals("desc2", pa2.getDescription());
        //Assert.assertEquals(date, pa2.getDeadline());
    }
View Full Code Here

        String id = paList[0].getID();
        _log.info("We're about to start using PATask with id:" + id);

        _log.info("We cannot get input and output of a task on a get task list call (see WSDL)");
        _log.info("Let's call TMS again to get the full input and output data of this PATask");
        PATask task = (PATask) tempoClient.getTask(id);
        _log.info("" + "\nChecking the task metadata..." + "\nThe task has been created on:" + task.getCreationDate() + "\nIt has the following description:"
                        + task.getDescription() + "\nIt is attached to the process with id:" + task.getProcessID() + "\nIt is attached to the following form:"
                        + task.getFormURLAsString() + "\nIt is in the following state:" + task.getState() + "\nIt has the following input:\n"
                        + task.getInputAsXmlString() + "\nIt can be assigned to the following roles:" + task.getRoleOwners()
                        + "\nIt can be assigned to the following users:" + task.getUserOwners());

        _log.info("Let's claim the task: no one else can access this task apart from user:" + user);
        tempoClient.claim(id, user);
        _log.info("Let's revoke the task:every one can access this task again");
        tempoClient.revoke(id);
View Full Code Here

    public void testInput() throws Exception {
        ITaskManagementService tms = new RemoteTMSFactory(TMS_REMOTE_URL, TOKEN).getService();
        Document input1 = Utils.createXMLDocument("/absr.xml");
        String task1ID = nextRandom();
        PATask task1 = new PATask(task1ID, new URI("http://localhost/1"), "processID", "urn:completeSOAPAction", input1);
        task1.getUserOwners().add("intalio\\admin");
        tms.create(task1);
        testRoundTrip(task1, input1);

        PATask task2 = (PATask) tms.getTask(task1ID);
        TaskEquality.areTasksEquals(task1, task2);
    }
View Full Code Here

    public void testUpdate() throws Exception {
        ITaskManagementService tms = new RemoteTMSFactory(TMS_REMOTE_URL, TOKEN).getService();
        Document input1 = Utils.createXMLDocument("/absr.xml");
        String id = "583c10bfdbd326ba:69a8b3cd:124dd681279:-7ef6127.0.1.1163844" + System.currentTimeMillis();
        PATask task1 = new PATask(id, new URI("http://localhost/1"), "processID", "urn:completeSOAPAction", input1);
        String description = "new two:" + System.currentTimeMillis();
        task1.getUserOwners().add("intalio\\admin");
        tms.create(task1);

        task1.setDescription(description);
        tms.update(task1);

        Task updated = tms.getTask(id);
        Assert.assertEquals(description, updated.getDescription());

        task1.setDescription("new one");
        tms.update(task1);
        Task updated2 = tms.getTask(id);
        Assert.assertNotSame(description, updated2.getDescription());

        tms.delete(new String[] { id });
View Full Code Here

    private void testRoundTrip(PATask task1, Document input) throws Exception {
        TaskMarshaller marshaller = new TaskMarshaller();
        OMElement marshalledTask = marshaller.marshalFullTask(task1, null);
        TaskUnmarshaller unmarshaller = new TaskUnmarshaller();
        PATask task2 = (PATask) unmarshaller.unmarshalFullTask(marshalledTask);
        Assert.assertEquals(task1.getInput().toString(), task2.getInput().toString());
    }
View Full Code Here

TOP

Related Classes of org.intalio.tempo.workflow.task.PATask

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.