org.drools.core.process.instance.impl.WorkItemImpl Java Examples
The following examples show how to use
org.drools.core.process.instance.impl.WorkItemImpl.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: JPAWorkItemHandlerTest.java From jbpm-work-items with Apache License 2.0 | 6 votes |
private Product getProduct(String id) throws Exception { WorkItemManager manager = new TestWorkItemManager(); WorkItemImpl workItem = new WorkItemImpl(); workItem.setParameter(JPAWorkItemHandler.P_ACTION, JPAWorkItemHandler.GET_ACTION); workItem.setParameter(JPAWorkItemHandler.P_TYPE, "org.jbpm.process.workitem.jpa.Product"); workItem.setParameter(JPAWorkItemHandler.P_ID, id); UserTransaction ut = getUserTransaction(); ut.begin(); handler.executeWorkItem(workItem, manager); ut.commit(); Map<String, Object> results = ((TestWorkItemManager) manager).getResults(workItem.getId()); Product product = (Product) results.get(JPAWorkItemHandler.P_RESULT); return product; }
Example #2
Source File: HandleMessageAction.java From kogito-runtimes with Apache License 2.0 | 6 votes |
public void execute(ProcessContext context) throws Exception { Object variable = VariableUtil.resolveVariable(variableName, context.getNodeInstance()); if (transformation != null) { variable = new EventTransformerImpl(transformation).transformEvent(variable); } WorkItemImpl workItem = new WorkItemImpl(); workItem.setName("Send Task"); workItem.setNodeInstanceId(context.getNodeInstance().getId()); workItem.setProcessInstanceId(context.getProcessInstance().getId()); workItem.setNodeId(context.getNodeInstance().getNodeId()); workItem.setParameter("MessageType", messageType); if (variable != null) { workItem.setParameter("Message", variable); } ((WorkItemManager) context.getKieRuntime().getWorkItemManager()).internalExecuteWorkItem(workItem); }
Example #3
Source File: GoogleDriveWorkitemHandlerTest.java From jbpm-work-items with Apache License 2.0 | 6 votes |
@Test(expected = WorkItemHandlerRuntimeException.class) public void testUploadInvalidParams() throws Exception { DocumentImpl testUploadDoc = new DocumentImpl(); testUploadDoc.setContent(new String("Test file to upload").getBytes()); testUploadDoc.setName("testFileToUpload.txt"); TestWorkItemManager manager = new TestWorkItemManager(); WorkItemImpl workItem = new WorkItemImpl(); MediaUploadWorkitemHandler handler = new MediaUploadWorkitemHandler("myAppName", "{}"); handler.setAuth(auth); handler.executeWorkItem(workItem, manager); assertNotNull(manager.getResults()); assertEquals(0, manager.getResults().size()); }
Example #4
Source File: VimeoWorkitemHandlerTest.java From jbpm-work-items with Apache License 2.0 | 6 votes |
@Test public void testUploadVideo() throws Exception { TestWorkItemManager manager = new TestWorkItemManager(); File tempFile = File.createTempFile("testfile", ".tmp"); tempFile.deleteOnExit(); WorkItemImpl workItem = new WorkItemImpl(); workItem.setParameter("VideoFile", tempFile); workItem.setParameter("Vimeo", vimeo); UploadVideoWorkitemHandler handler = new UploadVideoWorkitemHandler("testAccessToken"); handler.executeWorkItem(workItem, manager); assertNotNull(manager.getResults()); assertEquals(1, manager.getResults().size()); assertTrue(manager.getResults().containsKey(workItem.getId())); }
Example #5
Source File: ExecuteSqlWorkItemHandlerTest.java From jbpm-work-items with Apache License 2.0 | 6 votes |
@Test public void testFetchAllRows() throws Exception { TestWorkItemManager manager = new TestWorkItemManager(); WorkItemImpl workItem = new WorkItemImpl(); workItem.setParameter("SQLStatement", "select * from Person"); ExecuteSqlWorkItemHandler handler = new ExecuteSqlWorkItemHandler(DS_NAME); handler.executeWorkItem(workItem, manager); assertNotNull(manager.getResults()); assertEquals(1, manager.getResults().size()); assertTrue(manager.getResults().containsKey(workItem.getId())); assertTrue((manager.getResults().get(workItem.getId())).get("Result") instanceof List); List<String> resultLines = (List<String>) manager.getResults().get(workItem.getId()).get("Result"); assertNotNull(resultLines); assertEquals(3, resultLines.size()); }
Example #6
Source File: ExecuteSqlWorkItemHandlerTest.java From jbpm-work-items with Apache License 2.0 | 6 votes |
@Test public void testFetchSpecificRow() throws Exception { TestWorkItemManager manager = new TestWorkItemManager(); WorkItemImpl workItem = new WorkItemImpl(); workItem.setParameter("SQLStatement", "select * from Person where id = 1"); ExecuteSqlWorkItemHandler handler = new ExecuteSqlWorkItemHandler(DS_NAME); handler.executeWorkItem(workItem, manager); assertNotNull(manager.getResults()); assertEquals(1, manager.getResults().size()); assertTrue(manager.getResults().containsKey(workItem.getId())); List<String> resultLines = (List<String>) manager.getResults().get(workItem.getId()).get("Result"); assertNotNull(resultLines); assertEquals(1, resultLines.size()); assertEquals("1,Anthony,3", resultLines.get(0)); }
Example #7
Source File: ExecuteSqlWorkItemHandlerTest.java From jbpm-work-items with Apache License 2.0 | 6 votes |
@Test public void testUpdate() throws Exception { TestWorkItemManager manager = new TestWorkItemManager(); WorkItemImpl workItem = new WorkItemImpl(); workItem.setParameter("SQLStatement", "update Person set age=4 where id = 3"); ExecuteSqlWorkItemHandler handler = new ExecuteSqlWorkItemHandler(DS_NAME); handler.executeWorkItem(workItem,manager); assertNotNull(manager.getResults()); assertEquals(1,manager.getResults().size()); assertTrue(manager.getResults().containsKey(workItem.getId())); int changes = (int) manager.getResults().get(workItem.getId()).get("Result"); assertEquals(1,changes); }
Example #8
Source File: CamelGenericTest.java From jbpm-work-items with Apache License 2.0 | 6 votes |
@Test public void testClass() { GenericCamelWorkitemHandler handler = new GenericCamelWorkitemHandler("class", "FQCN"); final WorkItem workItem = new WorkItemImpl(); workItem.setParameter("FQCN", getClass().getCanonicalName()); workItem.setParameter("method", "testMethod"); WorkItemManager manager = new DefaultWorkItemManager(null); handler.executeWorkItem(workItem, manager); Assert.assertTrue(called); }
Example #9
Source File: JiraWorkitemHandlerTest.java From jbpm-work-items with Apache License 2.0 | 6 votes |
@Test(expected = WorkItemHandlerRuntimeException.class) public void testJqlSearchInvalidParams() throws Exception { TestWorkItemManager manager = new TestWorkItemManager(); WorkItemImpl workItem = new WorkItemImpl(); JqlSearchWorkitemHandler handler = new JqlSearchWorkitemHandler("testusername", "testpassword", "testjiraurl"); handler.setAuth(auth); handler.executeWorkItem(workItem, manager); assertNotNull(manager.getResults()); assertEquals(0, manager.getResults().size()); }
Example #10
Source File: RSSWorkItemHandlerTest.java From jbpm-work-items with Apache License 2.0 | 6 votes |
@Test public void testAddFeed() throws Exception { when(input.build(any(XmlReader.class))).thenReturn(feed); TestWorkItemManager manager = new TestWorkItemManager(); WorkItemImpl workItem = new WorkItemImpl(); workItem.setParameter("URL", "http://someurl.org"); RSSWorkItemHandler handler = new RSSWorkItemHandler(); handler.setInput(input); handler.executeWorkItem(workItem, manager); assertNotNull(manager.getResults()); assertEquals(1, manager.getResults().size()); assertTrue(manager.getResults().containsKey(workItem.getId())); }
Example #11
Source File: GithubWorkitemHandlerTest.java From jbpm-work-items with Apache License 2.0 | 6 votes |
@Test(expected = WorkItemHandlerRuntimeException.class) public void testCreateGistInvalidParams() throws Exception { DocumentImpl testGistDoc = new org.jbpm.document.service.impl.DocumentImpl(); testGistDoc.setContent(new String("Test gist file content").getBytes()); testGistDoc.setName("testGistFile.txt"); TestWorkItemManager manager = new TestWorkItemManager(); WorkItemImpl workItem = new WorkItemImpl(); CreateGistWorkitemHandler handler = new CreateGistWorkitemHandler("testusername", "testpassword"); handler.setAuth(auth); handler.executeWorkItem(workItem, manager); assertNotNull(manager.getResults()); assertEquals(0, manager.getResults().size()); }
Example #12
Source File: SlackWorkitemHandlerTest.java From jbpm-work-items with Apache License 2.0 | 6 votes |
@Test public void testAddReminder() throws Exception { TestWorkItemManager manager = new TestWorkItemManager(); WorkItemImpl workItem = new WorkItemImpl(); workItem.setParameter("ReminderText", "this is a test reminder"); workItem.setParameter("ReminderTime", "in 10 minutes"); AddReminderWorkitemHandler handler = new AddReminderWorkitemHandler("testAccessToken"); SlackAuth auth = new SlackAuth(); auth.setSlack(slack); handler.setAuth(auth); handler.executeWorkItem(workItem, manager); assertNotNull(manager.getResults()); assertEquals(1, manager.getResults().size()); assertTrue(manager.getResults().containsKey(workItem.getId())); }
Example #13
Source File: JiraWorkitemHandlerTest.java From jbpm-work-items with Apache License 2.0 | 6 votes |
@Test(expected = WorkItemHandlerRuntimeException.class) public void testAddCommentInvalidParams() throws Exception { TestWorkItemManager manager = new TestWorkItemManager(); WorkItemImpl workItem = new WorkItemImpl(); AddCommentOnIssueWorkitemHandler handler = new AddCommentOnIssueWorkitemHandler("testusername", "testpassword", "testjiraurl"); handler.setAuth(auth); handler.executeWorkItem(workItem, manager); assertNotNull(manager.getResults()); assertEquals(0, manager.getResults().size()); }
Example #14
Source File: GoogleMapsWorkitemHandlerTest.java From jbpm-work-items with Apache License 2.0 | 6 votes |
@Test public void testStaticMap() throws Exception { TestWorkItemManager manager = new TestWorkItemManager(); WorkItemImpl workItem = new WorkItemImpl(); workItem.setParameter("Width", "100"); workItem.setParameter("Height", "100"); workItem.setParameter("CenterLocation", "Atlanta"); StaticMapsWorkitemHandler handler = new StaticMapsWorkitemHandler(context); handler.setLogThrownException(true); handler.executeWorkItem(workItem, manager); assertNotNull(manager.getResults()); }
Example #15
Source File: JPAWorkItemHandlerTest.java From jbpm-work-items with Apache License 2.0 | 6 votes |
private List<Product> getAllProducts() throws Exception { WorkItemManager manager = new TestWorkItemManager(); WorkItemImpl workItem = new WorkItemImpl(); workItem.setParameter(JPAWorkItemHandler.P_ACTION, JPAWorkItemHandler.QUERY_ACTION); workItem.setParameter(JPAWorkItemHandler.P_QUERY, "SELECT p FROM Product p"); UserTransaction ut = getUserTransaction(); ut.begin(); handler.executeWorkItem(workItem, manager); ut.commit(); Map<String, Object> results = ((TestWorkItemManager) manager).getResults(workItem.getId()); @SuppressWarnings("unchecked") List<Product> products = (List<Product>) results.get(JPAWorkItemHandler.P_QUERY_RESULTS); return products; }
Example #16
Source File: GithubWorkitemHandlerTest.java From jbpm-work-items with Apache License 2.0 | 6 votes |
@Test public void testForkRepository() throws Exception { TestWorkItemManager manager = new TestWorkItemManager(); WorkItemImpl workItem = new WorkItemImpl(); workItem.setParameter("RepoOwner", "testRepoOwner"); workItem.setParameter("RepoName", "testRepoName"); workItem.setParameter("Organization", "testOrganization"); ForkRepositoryWorkitemHandler handler = new ForkRepositoryWorkitemHandler("testusername", "testpassword"); handler.setAuth(auth); handler.executeWorkItem(workItem, manager); assertNotNull(manager.getResults()); assertEquals(1, manager.getResults().size()); assertTrue(manager.getResults().containsKey(workItem.getId())); assertTrue((manager.getResults().get(workItem.getId())).get("ForkedRepoInfo") instanceof RepositoryInfo); }
Example #17
Source File: WatsonWorkitemHandlerTest.java From jbpm-work-items with Apache License 2.0 | 6 votes |
@Test(expected = WorkItemHandlerRuntimeException.class) public void testClassifyImageInvalidParams() throws Exception { when(auth.getService(anyString())).thenReturn(associationService); TestWorkItemManager manager = new TestWorkItemManager(); DocumentImpl imageToClassify = new DocumentImpl(); imageToClassify.setName("testImageToClassify.png"); imageToClassify.setContent(new String("testImageContent").getBytes()); WorkItemImpl workItem = new WorkItemImpl(); ClassifyImageWorkitemHandler handler = new ClassifyImageWorkitemHandler("{testApiKey}"); handler.setAuth(auth); handler.executeWorkItem(workItem, manager); assertNotNull(manager.getResults()); assertEquals(0, manager.getResults().size()); }
Example #18
Source File: WatsonWorkitemHandlerTest.java From jbpm-work-items with Apache License 2.0 | 6 votes |
@Test(expected = WorkItemHandlerRuntimeException.class) public void testDetectFacesInvalidParams() throws Exception { when(auth.getService(anyString())).thenReturn(recognitionService); TestWorkItemManager manager = new TestWorkItemManager(); DocumentImpl imagetoDetect = new DocumentImpl(); imagetoDetect.setName("testImageToDetect.png"); imagetoDetect.setContent(new String("testImageContent").getBytes()); WorkItemImpl workItem = new WorkItemImpl(); DetectFacesWorkitemHandler handler = new DetectFacesWorkitemHandler("{testApiKey}"); handler.setAuth(auth); handler.executeWorkItem(workItem, manager); assertNotNull(manager.getResults()); assertEquals(0, manager.getResults().size()); }
Example #19
Source File: JiraWorkitemHandlerTest.java From jbpm-work-items with Apache License 2.0 | 6 votes |
@Test public void testResolveIssue() throws Exception { TestWorkItemManager manager = new TestWorkItemManager(); WorkItemImpl workItem = new WorkItemImpl(); workItem.setParameter("IssueKey", "testIssueKey"); workItem.setParameter("Resolution", "testResolved"); workItem.setParameter("ResolutionComment", "testResolutionComment"); ResolveIssueWorkitemHandler handler = new ResolveIssueWorkitemHandler("testusername", "testpassword", "testjiraurl"); handler.setAuth(auth); handler.executeWorkItem(workItem, manager); assertNotNull(manager.getResults()); assertEquals(1, manager.getResults().size()); assertTrue(manager.getResults().containsKey(workItem.getId())); }
Example #20
Source File: DockerWorkitemHandlerTest.java From jbpm-work-items with Apache License 2.0 | 6 votes |
@Test public void testDockerKillContainer() throws Exception { TestWorkItemManager manager = new TestWorkItemManager(); WorkItemImpl workItem = new WorkItemImpl(); workItem.setParameter("ContainerId", "testContainerId"); KillContainerWorkitemHandler handler = new KillContainerWorkitemHandler(); handler.setDockerClient(dockerClient); handler.executeWorkItem(workItem, manager); assertNotNull(manager.getResults()); assertEquals(1, manager.getResults().size()); assertTrue(manager.getResults().containsKey(workItem.getId())); }
Example #21
Source File: DockerWorkitemHandlerTest.java From jbpm-work-items with Apache License 2.0 | 6 votes |
@Test public void testDockerListContainers() throws Exception { TestWorkItemManager manager = new TestWorkItemManager(); WorkItemImpl workItem = new WorkItemImpl(); ListContainersWorkitemHandler handler = new ListContainersWorkitemHandler(); handler.setDockerClient(dockerClient); handler.executeWorkItem(workItem, manager); assertNotNull(manager.getResults()); assertEquals(1, manager.getResults().size()); assertTrue(manager.getResults().containsKey(workItem.getId())); assertTrue((manager.getResults().get(workItem.getId())).get("Containers") instanceof List); }
Example #22
Source File: DockerWorkitemHandlerTest.java From jbpm-work-items with Apache License 2.0 | 6 votes |
@Test public void testDockerListImages() throws Exception { TestWorkItemManager manager = new TestWorkItemManager(); WorkItemImpl workItem = new WorkItemImpl(); ListImagesWorkitemHandler handler = new ListImagesWorkitemHandler(); handler.setDockerClient(dockerClient); handler.executeWorkItem(workItem, manager); assertNotNull(manager.getResults()); assertEquals(1, manager.getResults().size()); assertTrue(manager.getResults().containsKey(workItem.getId())); assertTrue((manager.getResults().get(workItem.getId())).get("Images") instanceof List); }
Example #23
Source File: DockerWorkitemHandlerTest.java From jbpm-work-items with Apache License 2.0 | 6 votes |
@Test public void testDockerStartContainer() throws Exception { TestWorkItemManager manager = new TestWorkItemManager(); WorkItemImpl workItem = new WorkItemImpl(); workItem.setParameter("ContainerId", "testContainerId"); StartContainerWorkitemHandler handler = new StartContainerWorkitemHandler(); handler.setDockerClient(dockerClient); handler.executeWorkItem(workItem, manager); assertNotNull(manager.getResults()); assertEquals(1, manager.getResults().size()); assertTrue(manager.getResults().containsKey(workItem.getId())); }
Example #24
Source File: GoogleCalendarWorkitemHandlerTest.java From jbpm-work-items with Apache License 2.0 | 6 votes |
@Test(expected = WorkItemHandlerRuntimeException.class) public void testAddCalendarHandlerInvalidParams() throws Exception { TestWorkItemManager manager = new TestWorkItemManager(); WorkItemImpl workItem = new WorkItemImpl(); AddCalendarWorkitemHandler handler = new AddCalendarWorkitemHandler("myAppName", "{}"); handler.setAuth(auth); handler.executeWorkItem(workItem, manager); assertNotNull(manager.getResults()); assertEquals(0, manager.getResults().size()); }
Example #25
Source File: GoogleCalendarWorkitemHandlerTest.java From jbpm-work-items with Apache License 2.0 | 6 votes |
@Test public void testGetCalendarsHandler() throws Exception { TestWorkItemManager manager = new TestWorkItemManager(); WorkItemImpl workItem = new WorkItemImpl(); GetCalendarsWorkitemHandler handler = new GetCalendarsWorkitemHandler("myAppName", "{}"); handler.setAuth(auth); handler.executeWorkItem(workItem, manager); assertNotNull(manager.getResults()); assertEquals(1, manager.getResults().size()); assertTrue(manager.getResults().containsKey(workItem.getId())); assertTrue((manager.getResults().get(workItem.getId())).get("AllCalendars") instanceof com.google.api.services.calendar.model.CalendarList); }
Example #26
Source File: GoogleCalendarWorkitemHandlerTest.java From jbpm-work-items with Apache License 2.0 | 6 votes |
@Test public void testGetEventsHandler() throws Exception { TestWorkItemManager manager = new TestWorkItemManager(); WorkItemImpl workItem = new WorkItemImpl(); workItem.setParameter("CalendarSummary", "mycalendarsummary"); GetEventsWorkitemHandler handler = new GetEventsWorkitemHandler("myAppName", "{}"); handler.setAuth(auth); handler.executeWorkItem(workItem, manager); assertNotNull(manager.getResults()); assertEquals(1, manager.getResults().size()); assertTrue(manager.getResults().containsKey(workItem.getId())); assertTrue((manager.getResults().get(workItem.getId())).get("AllEvents") instanceof com.google.api.services.calendar.model.Events); }
Example #27
Source File: KafkaWorkItemHandlerTest.java From jbpm-work-items with Apache License 2.0 | 6 votes |
@Test public void testSendMessage() throws Exception { TestWorkItemManager manager = new TestWorkItemManager(); WorkItemImpl workItem = new WorkItemImpl(); workItem.setParameter("Topic", "myTopic"); workItem.setParameter("Key", "1"); workItem.setParameter("Value", "Sample"); Producer<Long, String> mockProducer = new MockProducer(); KafkaWorkItemHandler handler = new KafkaWorkItemHandler(mockProducer); handler.executeWorkItem(workItem, manager); assertNotNull(manager.getResults()); }
Example #28
Source File: TwitterWorkitemHandlerTest.java From jbpm-work-items with Apache License 2.0 | 6 votes |
@Test public void testUpdateStatus() throws Exception { TestWorkItemManager manager = new TestWorkItemManager(); WorkItemImpl workItem = new WorkItemImpl(); workItem.setParameter("StatusUpdate", "testUpdateStatus"); UpdateStatusWorkitemHandler handler = new UpdateStatusWorkitemHandler("testConsumerKey", "testConsumerSecret", "testAccessKey", "testAccessSecret"); handler.setAuth(auth); handler.executeWorkItem(workItem, manager); assertNotNull(manager.getResults()); assertEquals(1, manager.getResults().size()); assertTrue(manager.getResults().containsKey(workItem.getId())); StatusUpdate handlerStatusUpdate = handler.getStatusUpdate(); assertNotNull(handlerStatusUpdate); assertEquals("testUpdateStatus", handlerStatusUpdate.getStatus()); }
Example #29
Source File: TwitterWorkitemHandlerTest.java From jbpm-work-items with Apache License 2.0 | 6 votes |
@Test(expected = WorkItemHandlerRuntimeException.class) public void testUpdateStatusInvalidParams() throws Exception { TestWorkItemManager manager = new TestWorkItemManager(); WorkItemImpl workItem = new WorkItemImpl(); UpdateStatusWorkitemHandler handler = new UpdateStatusWorkitemHandler("testConsumerKey", "testConsumerSecret", "testAccessKey", "testAccessSecret"); handler.setAuth(auth); handler.executeWorkItem(workItem, manager); assertNotNull(manager.getResults()); assertEquals(0, manager.getResults().size()); }
Example #30
Source File: EthereumWorkitemHandlerTest.java From jbpm-work-items with Apache License 2.0 | 6 votes |
@Test public void testQueryExistingContract() throws Exception { TestWorkItemManager manager = new TestWorkItemManager(); WorkItemImpl workItem = new WorkItemImpl(); workItem.setParameter("ServiceURL", "http://localhost:8545/"); workItem.setParameter("ContractAddress", "0x00211e7e"); workItem.setParameter("ContractMethodName", "testQuery"); workItem.setParameter("MethodOutputType", null); QueryExistingContractWorkitemHandler handler = new QueryExistingContractWorkitemHandler(TEST_WALLET_PASSWORD, "wallet/testwallet.json"); handler.setWeb3j(web3j); handler.executeWorkItem(workItem, manager); assertNotNull(manager.getResults()); assertEquals(1, manager.getResults().size()); assertTrue(manager.getResults().containsKey(workItem.getId())); }