Package org.drools.task.service.responsehandlers

Examples of org.drools.task.service.responsehandlers.BlockingGetTaskResponseHandler


        BlockingAddAttachmentResponseHandler addAttachmentResponseHandler = new BlockingAddAttachmentResponseHandler();
        client.addAttachment( taskId, attachment, content, addAttachmentResponseHandler);
        assertTrue( addAttachmentResponseHandler.getAttachmentId() != attachment.getId() );
        assertTrue( addAttachmentResponseHandler.getContentId() != attachment.getAttachmentContentId() );
       
        BlockingGetTaskResponseHandler getTaskResponseHandler = new BlockingGetTaskResponseHandler();
        client.getTask( taskId, getTaskResponseHandler );
        Task task1 = getTaskResponseHandler.getTask();
        assertNotSame(task, task1);
        assertFalsetask.equals( task1) );
      
        List<Attachment> attachments1 = task1.getTaskData().getAttachments();
        assertEquals(1, attachments1.size() );
        Attachment returnedAttachment = attachments1.get( 0 );       
        assertEquals( attachedAt, returnedAttachment.getAttachedAt() );
        assertEquals( users.get( "luke" ), returnedAttachment.getAttachedBy() );
        assertEquals( AccessType.Inline, returnedAttachment.getAccessType() );
        assertEquals( "txt", returnedAttachment.getContentType() );
        assertEquals( "file1.txt", returnedAttachment.getName() );       
        assertEquals( bytes.length, returnedAttachment.getSize() );
       
        assertEquals( (long) addAttachmentResponseHandler.getAttachmentId(), (long) returnedAttachment.getId() );
        assertEquals( (long) addAttachmentResponseHandler.getContentId()(long) returnedAttachment.getAttachmentContentId() );       
       
        // Make the same as the returned tasks, so we can test equals
        task.getTaskData().setAttachments( attachments1 );
        task.getTaskData().setStatus( Status.Created );
        assertEquals(task, task1);           
       
        BlockingGetContentResponseHandler  getResponseHandler = new BlockingGetContentResponseHandler();
        client.getContent( returnedAttachment.getAttachmentContentId(), getResponseHandler );
        content = getResponseHandler.getContent();
        assertEquals( "Ths is my attachment text1", new String( content.getContent() ) );
       
        // test we can have multiple attachments
       
        attachment = new Attachment();
        attachedAt = new Date( System.currentTimeMillis() );
        attachment.setAttachedAt( attachedAt);
        attachment.setAttachedBy( users.get( "tony" ) );
        attachment.setName( "file2.txt" );
        attachment.setAccessType( AccessType.Inline );
        attachment.setContentType( "txt" );
       
        bytes = "Ths is my attachment text2".getBytes();
        content = new Content();
        content.setContent( bytes );
       
        addAttachmentResponseHandler = new BlockingAddAttachmentResponseHandler();
        client.addAttachment( taskId, attachment, content, addAttachmentResponseHandler);  
       
        getTaskResponseHandler = new BlockingGetTaskResponseHandler();
        client.getTask( taskId, getTaskResponseHandler );
        task1 = getTaskResponseHandler.getTask();
        assertNotSame(task, task1);
        assertFalsetask.equals( task1) );
      
        List<Attachment> attachments2 = task1.getTaskData().getAttachments();
        assertEquals(2, attachments2.size() );
       
        getResponseHandler = new BlockingGetContentResponseHandler();
        client.getContent( addAttachmentResponseHandler.getContentId(), getResponseHandler );
        content = getResponseHandler.getContent();
        assertEquals( "Ths is my attachment text2", new String( content.getContent() ) );       
       
        // make two collections the same and compare
        attachment.setSize( 26 );
        attachment.setAttachmentContentId( addAttachmentResponseHandler.getContentId() );
        attachments1.add( attachment );
        assertTrue( CollectionUtils.equals( attachments2, attachments1 ) );     
       
        BlockingDeleteAttachmentResponseHandler deleteCommentResponseHandler = new BlockingDeleteAttachmentResponseHandler();
        client.deleteAttachment( taskId, addAttachmentResponseHandler.getAttachmentId(), addAttachmentResponseHandler.getContentId(), deleteCommentResponseHandler );
        deleteCommentResponseHandler.waitTillDone( 3000 );
       
        Thread.sleep( 3000 );
       
        getTaskResponseHandler = new BlockingGetTaskResponseHandler();
        client.getTask( taskId, getTaskResponseHandler );
        task1 = getTaskResponseHandler.getTask();
        attachments2 = task1.getTaskData().getAttachments();
        assertEquals(1, attachments2.size() );       
       
        assertEquals( "file1.txt", attachments2.get( 0 ).getName());
    }
View Full Code Here


        client.addTask( task, null, addTaskResponseHandler );
       
        long taskId = addTaskResponseHandler.getTaskId();
       
        // A Task with multiple potential owners moves to "Ready" state until someone claims it.
        BlockingGetTaskResponseHandler getTaskResponseHandler = new BlockingGetTaskResponseHandler();
        client.getTask( taskId, getTaskResponseHandler );
        Task task1 = getTaskResponseHandler.getTask();
        assertEquals( Status.Ready , task1.getTaskData().getStatus() );        
       
        EventKey key = new TaskEventKey(TaskClaimedEvent.class, taskId );          
        BlockingEventResponseHandler handler = new BlockingEventResponseHandler();
        client.registerForEvent( key, true, handler );
View Full Code Here

    client.claim(taskSummary.getId(), "Darth Vader", operationResponseHandler);
    operationResponseHandler.waitTillDone(5000);
    System.out.println("Claimed task " + taskSummary.getId());

        //Check if the parent task is InProgress
        BlockingGetTaskResponseHandler getTaskResponseHandler = new BlockingGetTaskResponseHandler();
        client.getTask( taskSummary.getId(), getTaskResponseHandler );
        Task task = getTaskResponseHandler.getTask();
        assertEqualsStatus.Ready, task.getTaskData().getStatus() );
       


  }
View Full Code Here

    assertEquals(10, taskSummary.getPriority());
    assertEquals("Comment", taskSummary.getDescription());
    assertEquals(Status.Reserved, taskSummary.getStatus());
    assertEquals("Darth Vader", taskSummary.getActualOwner().getId());
   
    BlockingGetTaskResponseHandler getTaskResponseHandler = new BlockingGetTaskResponseHandler();
    client.getTask(taskSummary.getId(), getTaskResponseHandler);
    Task task = getTaskResponseHandler.getTask();
    assertEquals(AccessType.Inline, task.getTaskData().getDocumentAccessType());
    long contentId = task.getTaskData().getDocumentContentId();
    assertTrue(contentId != -1);
    BlockingGetContentResponseHandler getContentResponseHandler = new BlockingGetContentResponseHandler();
    client.getContent(contentId, getContentResponseHandler);
View Full Code Here

    client.start(task.getId(), "Darth Vader", operationResponseHandler);
    operationResponseHandler.waitTillDone(5000);
    System.out.println("Started task " + task.getId());

        //Check if the parent task is InProgress
        BlockingGetTaskResponseHandler getTaskResponseHandler = new BlockingGetTaskResponseHandler();
        client.getTask( task.getId(), getTaskResponseHandler );
        Task parentTask = getTaskResponseHandler.getTask();
        assertEqualsStatus.InProgress, parentTask.getTaskData().getStatus() );
        assertEquals( users.get( "darth" ), parentTask.getTaskData().getActualOwner() );

        //Get all the subtask created for the parent task based on the potential owner
        responseHandler = new BlockingTaskSummaryResponseHandler();
        client.getSubTasksAssignedAsPotentialOwner(parentTask.getId(),"Darth Vader", "en-UK", responseHandler);
        List<TaskSummary> subTasks = responseHandler.getResults();
        assertEquals(2, subTasks.size());
        TaskSummary subTaskSummary1 = subTasks.get(0);
        TaskSummary subTaskSummary2 = subTasks.get(1);
        assertNotNull(subTaskSummary1);
        assertNotNull(subTaskSummary2);

        //Starting the sub task 1
        System.out.println("Starting sub task " + subTaskSummary1.getId());
    operationResponseHandler = new BlockingTaskOperationResponseHandler();
    client.start(subTaskSummary1.getId(), "Darth Vader", operationResponseHandler);
    operationResponseHandler.waitTillDone(5000);
    System.out.println("Started sub task " + subTaskSummary1.getId());

        //Starting the sub task 2
        System.out.println("Starting sub task " + subTaskSummary2.getId());
    operationResponseHandler = new BlockingTaskOperationResponseHandler();
    client.start(subTaskSummary2.getId(), "Darth Vader", operationResponseHandler);
    operationResponseHandler.waitTillDone(5000);
    System.out.println("Started sub task " + subTaskSummary2.getId());



        //Check if the child task 1 is InProgress
        getTaskResponseHandler = new BlockingGetTaskResponseHandler();
        client.getTask( subTaskSummary1.getId(), getTaskResponseHandler );
        Task subTask1 = getTaskResponseHandler.getTask();
        assertEqualsStatus.InProgress, subTask1.getTaskData().getStatus() );
        assertEquals( users.get( "darth" ), subTask1.getTaskData().getActualOwner() );


         //Check if the child task 2 is InProgress
        getTaskResponseHandler = new BlockingGetTaskResponseHandler();
        client.getTask( subTaskSummary2.getId(), getTaskResponseHandler );
        Task subTask2 = getTaskResponseHandler.getTask();
        assertEqualsStatus.InProgress, subTask2.getTaskData().getStatus() );
        assertEquals( users.get( "darth" ), subTask2.getTaskData().getActualOwner() );

        // Complete the child task 1
        System.out.println("Completing sub task " + subTask1.getId());
        operationResponseHandler = new BlockingTaskOperationResponseHandler();
        client.complete( subTask1.getId(),"Darth Vader" , null, operationResponseHandler );
        operationResponseHandler.waitTillDone( 5000 );
        System.out.println("Completed sub task " + subTask1.getId());

         // Complete the child task 2
        System.out.println("Completing sub task " + subTask2.getId());
        operationResponseHandler = new BlockingTaskOperationResponseHandler();
        client.complete( subTask2.getId(),"Darth Vader" , null, operationResponseHandler );
        operationResponseHandler.waitTillDone( 5000 );
        System.out.println("Completed sub task " + subTask2.getId());



         //Check if the child task 1 is Completed

        getTaskResponseHandler = new BlockingGetTaskResponseHandler();
        client.getTask( subTask1.getId(), getTaskResponseHandler );
        subTask1 = getTaskResponseHandler.getTask();
        assertEqualsStatus.Completed, subTask1.getTaskData().getStatus() );
        assertEquals( users.get( "darth" ), subTask1.getTaskData().getActualOwner() );

          //Check if the child task 2 is Completed

        getTaskResponseHandler = new BlockingGetTaskResponseHandler();
        client.getTask( subTask2.getId(), getTaskResponseHandler );
        subTask2 = getTaskResponseHandler.getTask();
        assertEqualsStatus.Completed, subTask2.getTaskData().getStatus() );
        assertEquals( users.get( "darth" ), subTask2.getTaskData().getActualOwner() );



        // Check is the parent task is Complete
        getTaskResponseHandler = new BlockingGetTaskResponseHandler();
        client.getTask( parentTask.getId(), getTaskResponseHandler );
        parentTask = getTaskResponseHandler.getTask();
        assertEqualsStatus.Completed, parentTask.getTaskData().getStatus() );
        assertEquals( users.get( "darth" ), parentTask.getTaskData().getActualOwner() );


View Full Code Here

    client.start(task.getId(), "Darth Vader", operationResponseHandler);
    operationResponseHandler.waitTillDone(5000);
    System.out.println("Started task " + task.getId());

        //Check if the parent task is InProgress
        BlockingGetTaskResponseHandler getTaskResponseHandler = new BlockingGetTaskResponseHandler();
        client.getTask( task.getId(), getTaskResponseHandler );
        Task parentTask = getTaskResponseHandler.getTask();
        assertEqualsStatus.InProgress, parentTask.getTaskData().getStatus() );
        assertEquals( users.get( "darth" ), parentTask.getTaskData().getActualOwner() );

        //Get all the subtask created for the parent task based on the potential owner
        responseHandler = new BlockingTaskSummaryResponseHandler();
        client.getSubTasksAssignedAsPotentialOwner(parentTask.getId(),"Darth Vader", "en-UK", responseHandler);
        List<TaskSummary> subTasks = responseHandler.getResults();
        assertEquals(2, subTasks.size());
        TaskSummary subTaskSummary1 = subTasks.get(0);
        TaskSummary subTaskSummary2 = subTasks.get(1);
        assertNotNull(subTaskSummary1);
        assertNotNull(subTaskSummary2);

        //Starting the sub task 1
        System.out.println("Starting sub task " + subTaskSummary1.getId());
    operationResponseHandler = new BlockingTaskOperationResponseHandler();
    client.start(subTaskSummary1.getId(), "Darth Vader", operationResponseHandler);
    operationResponseHandler.waitTillDone(5000);
    System.out.println("Started sub task " + subTaskSummary1.getId());

        //Starting the sub task 2
        System.out.println("Starting sub task " + subTaskSummary2.getId());
    operationResponseHandler = new BlockingTaskOperationResponseHandler();
    client.start(subTaskSummary2.getId(), "Darth Vader", operationResponseHandler);
    operationResponseHandler.waitTillDone(5000);
    System.out.println("Started sub task " + subTaskSummary2.getId());



        //Check if the child task 1 is InProgress
        getTaskResponseHandler = new BlockingGetTaskResponseHandler();
        client.getTask( subTaskSummary1.getId(), getTaskResponseHandler );
        Task subTask1 = getTaskResponseHandler.getTask();
        assertEqualsStatus.InProgress, subTask1.getTaskData().getStatus() );
        assertEquals( users.get( "darth" ), subTask1.getTaskData().getActualOwner() );


         //Check if the child task 2 is InProgress
        getTaskResponseHandler = new BlockingGetTaskResponseHandler();
        client.getTask( subTaskSummary2.getId(), getTaskResponseHandler );
        Task subTask2 = getTaskResponseHandler.getTask();
        assertEqualsStatus.InProgress, subTask2.getTaskData().getStatus() );
        assertEquals( users.get( "darth" ), subTask2.getTaskData().getActualOwner() );

        // Complete the parent task
        System.out.println("Completing parent task " + parentTask.getId());
        operationResponseHandler = new BlockingTaskOperationResponseHandler();
        client.skip( parentTask.getId(), "Darth Vader", operationResponseHandler );
        operationResponseHandler.waitTillDone( 5000 );
        System.out.println("Completed parent task " + parentTask.getId());




        //Check if the child task 1 is Completed
        getTaskResponseHandler = new BlockingGetTaskResponseHandler();
        client.getTask( subTaskSummary1.getId(), getTaskResponseHandler );
        subTask1 = getTaskResponseHandler.getTask();
        assertEqualsStatus.Completed, subTask1.getTaskData().getStatus() );
        assertEquals( users.get( "darth" ), subTask1.getTaskData().getActualOwner() );


         //Check if the child task 2 is Completed
        getTaskResponseHandler = new BlockingGetTaskResponseHandler();
        client.getTask( subTaskSummary2.getId(), getTaskResponseHandler );
        subTask2 = getTaskResponseHandler.getTask();
        assertEqualsStatus.Completed, subTask2.getTaskData().getStatus() );
        assertEquals( users.get( "darth" ), subTask2.getTaskData().getActualOwner() );


View Full Code Here

        client.addTask( task, null, addTaskResponseHandler );
       
        long taskId = addTaskResponseHandler.getTaskId();
       
        // Task should remain in Created state with no actual owner
        BlockingGetTaskResponseHandler getTaskResponseHandler = new BlockingGetTaskResponseHandler();
        client.getTask( taskId, getTaskResponseHandler );
        Task task1 = getTaskResponseHandler.getTask();
        assertEquals( task1.getTaskData().getStatus(), Status.Created );    
        assertNull( task1.getTaskData().getActualOwner() );       
    }
View Full Code Here

        client.addTask( task, null, addTaskResponseHandler );
       
        long taskId = addTaskResponseHandler.getTaskId();
       
        // Task should be assigned to the single potential owner and state set to Reserved
        BlockingGetTaskResponseHandler getTaskResponseHandler = new BlockingGetTaskResponseHandler();
        client.getTask( taskId, getTaskResponseHandler );
        Task task1 = getTaskResponseHandler.getTask();
        assertEquals( Status.Reserved, task1.getTaskData().getStatus() );    
        assertEquals( users.get( "bobba" ), task1.getTaskData().getActualOwner() );
    }
View Full Code Here

        client.addTask( task, data, addTaskResponseHandler );
       
        long taskId = addTaskResponseHandler.getTaskId();
       
        // Task should be assigned to the single potential owner and state set to Reserved
        BlockingGetTaskResponseHandler getTaskResponseHandler = new BlockingGetTaskResponseHandler();
        client.getTask( taskId, getTaskResponseHandler );
        Task task1 = getTaskResponseHandler.getTask();
        assertEquals( AccessType.Inline, task1.getTaskData().getDocumentAccessType() );
        assertEquals( "type", task1.getTaskData().getDocumentType() );
        long contentId = task1.getTaskData().getDocumentContentId();
        assertTrue( contentId != -1 );
View Full Code Here

        client.addTask( task, null, addTaskResponseHandler );
       
        long taskId = addTaskResponseHandler.getTaskId();
       
        // A Task with multiple potential owners moves to "Ready" state until someone claims it.
        BlockingGetTaskResponseHandler getTaskResponseHandler = new BlockingGetTaskResponseHandler();
        client.getTask( taskId, getTaskResponseHandler );
        Task task1 = getTaskResponseHandler.getTask();
        assertEquals( Status.Ready , task1.getTaskData().getStatus() );    
       
        BlockingTaskOperationResponseHandler responseHandler = new BlockingTaskOperationResponseHandler();
        client.claim( taskId, users.get( "darth" ).getId(), responseHandler );       
        responseHandler.waitTillDone( 3000 );
       
        getTaskResponseHandler = new BlockingGetTaskResponseHandler();
        client.getTask( taskId, getTaskResponseHandler );
        Task task2 = getTaskResponseHandler.getTask();
        assertEqualsStatus.Reserved, task2.getTaskData().getStatus() );
        assertEquals( users.get( "darth" ), task2.getTaskData().getActualOwner() );
    }
View Full Code Here

TOP

Related Classes of org.drools.task.service.responsehandlers.BlockingGetTaskResponseHandler

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.