use of org.jbpm.process.workitem.core.TestWorkItemManager in project jbpm-work-items by kiegroup.
the class EthereumWorkitemHandlerTest method testDeployContract.
@Test
public void testDeployContract() throws Exception {
TestWorkItemManager manager = new TestWorkItemManager();
WorkItemImpl workItem = new WorkItemImpl();
workItem.setParameter("ServiceURL", "http://localhost:8545/");
workItem.setParameter("ContractPath", "contract/Storage.bin");
workItem.setParameter("DepositAmount", "10");
workItem.setParameter("WaitForReceipt", "false");
DeployContractWorkitemHandler handler = new DeployContractWorkitemHandler(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()));
}
use of org.jbpm.process.workitem.core.TestWorkItemManager in project jbpm-work-items by kiegroup.
the class ExecWorkItemHandlerTest method testExecCommand.
@Test
public void testExecCommand() throws Exception {
TestWorkItemManager manager = new TestWorkItemManager();
WorkItemImpl workItem = new WorkItemImpl();
workItem.setParameter("Command", "java -version");
ExecWorkItemHandler handler = new ExecWorkItemHandler();
handler.setLogThrownException(true);
handler.executeWorkItem(workItem, manager);
assertNotNull(manager.getResults());
assertEquals(1, manager.getResults().size());
assertTrue(manager.getResults().containsKey(workItem.getId()));
}
use of org.jbpm.process.workitem.core.TestWorkItemManager in project jbpm-work-items by kiegroup.
the class GithubWorkitemHandlerTest method testForkRepository.
@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);
}
use of org.jbpm.process.workitem.core.TestWorkItemManager in project jbpm-work-items by kiegroup.
the class GithubWorkitemHandlerTest method testCreateGist.
@Test
public void testCreateGist() 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();
workItem.setParameter("Content", testGistDoc);
workItem.setParameter("Description", "test gist");
workItem.setParameter("IsPublic", "true");
CreateGistWorkitemHandler handler = new CreateGistWorkitemHandler("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("GistURL") instanceof String);
String createdGistURL = (String) manager.getResults().get(workItem.getId()).get("GistURL");
assertNotNull(createdGistURL);
assertEquals("testGistURL", createdGistURL);
}
use of org.jbpm.process.workitem.core.TestWorkItemManager in project jbpm-work-items by kiegroup.
the class WatsonWorkitemHandlerTest method testClassifyImage.
@Test
public void testClassifyImage() 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();
workItem.setParameter("ImageToClassify", imageToClassify);
ClassifyImageWorkitemHandler handler = new ClassifyImageWorkitemHandler("{testApiKey}");
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("Classification") instanceof List);
List<ImageClassificationResult> returnValues = (List<ImageClassificationResult>) (manager.getResults().get(workItem.getId())).get("Classification");
assertNotNull(returnValues);
assertEquals(1, returnValues.size());
ImageClassificationResult result = returnValues.get(0);
assertTrue(result.getClassScore() == 1);
assertEquals("testClassName", result.getClassName());
assertEquals("testTypeHierarchy", result.getClassTypeHierarchy());
}
Aggregations