本文整理匯總了Java中org.drools.core.process.instance.impl.WorkItemImpl類的典型用法代碼示例。如果您正苦於以下問題:Java WorkItemImpl類的具體用法?Java WorkItemImpl怎麽用?Java WorkItemImpl使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
WorkItemImpl類屬於org.drools.core.process.instance.impl包,在下文中一共展示了WorkItemImpl類的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: testSingleFileWithHeaders
import org.drools.core.process.instance.impl.WorkItemImpl; //導入依賴的package包/類
/**
* File to upload has been specified by Camel header.
*
* @throws java.io.IOException */
@Test
public void testSingleFileWithHeaders() throws IOException {
Set<String> headers = new HashSet<String>();
headers.add("CamelFileName");
CamelHandler handler = new CamelHandler(new FileURIMapper(), new RequestPayloadMapper("payload", headers));
final String testData = "test-data";
final WorkItem workItem = new WorkItemImpl();
workItem.setParameter("path", tempDir.getAbsolutePath());
workItem.setParameter("payload", testData);
workItem.setParameter("CamelFileName", testFile.getName());
WorkItemManager manager = new DefaultWorkItemManager(null);
handler.executeWorkItem(workItem, manager);
assertTrue(testFile.exists());
String resultText = FileUtils.readFileToString(testFile);
assertEquals(testData,resultText);
}
示例2: testFtp
import org.drools.core.process.instance.impl.WorkItemImpl; //導入依賴的package包/類
@Test
public void testFtp() throws IOException {
CamelHandler handler = CamelHandlerFactory.ftpHandler();
final String testData = "test-data";
final WorkItem workItem = new WorkItemImpl();
workItem.setParameter("username", USER);
workItem.setParameter("password", PASSWD);
workItem.setParameter("hostname", HOST);
workItem.setParameter("port", PORT.toString());
workItem.setParameter("directoryname", testFile.getParentFile().getName());
workItem.setParameter("CamelFileName", testFile.getName());
workItem.setParameter("payload", testData);
WorkItemManager manager = new DefaultWorkItemManager(null);
handler.executeWorkItem(workItem, manager);
Assert.assertTrue("Expected file does not exist.", testFile.exists());
String resultText = FileUtils.readFileToString(testFile);
Assert.assertEquals(resultText, testData);
}
示例3: testSingleFileWithHeaders
import org.drools.core.process.instance.impl.WorkItemImpl; //導入依賴的package包/類
/** File to upload has been specified by Camel header. */
@Test
public void testSingleFileWithHeaders() throws IOException {
Set<String> headers = new HashSet<String>();
headers.add("CamelFileName");
CamelHandler handler = new CamelHandler(new FileURIMapper(), new RequestPayloadMapper("payload", headers));
final String testData = "test-data";
final WorkItem workItem = new WorkItemImpl();
workItem.setParameter("path", tempDir.getAbsolutePath());
workItem.setParameter("payload", testData);
workItem.setParameter("CamelFileName", testFile.getName());
WorkItemManager manager = new DefaultWorkItemManager(null);
handler.executeWorkItem(workItem, manager);
Assert.assertTrue("Expected file does not exist.", testFile.exists());
String resultText = FileUtils.readFileToString(testFile);
Assert.assertEquals(resultText, testData);
}
示例4: executeWorkItem
import org.drools.core.process.instance.impl.WorkItemImpl; //導入依賴的package包/類
public void executeWorkItem(final WorkItem workItem, final WorkItemManager manager) {
String url = mUrl;
String appId = mAppId;
String secret = mSecret;
String masterVariantId = mMasterVariantId;
String variantId = String.valueOf(workItem.getParameter("variant_id"));
String alert = String.valueOf(workItem.getParameter("alert"));
String sound = String.valueOf(workItem.getParameter("sound"));
String testId = null;
final String deploymentId = ((WorkItemImpl) workItem).getDeploymentId();
EngineHolder engine = null;
try {
engine = new EngineHolder(deploymentId);
testId = Util.processId(engine.getEngine(), workItem);
} finally {
if (engine != null) {
engine.close();
}
}
PushNotification notification;
notification = new PushNotification(masterVariantId, variantId, alert, sound);
Jups jups;
jups = new Jups(url, appId, secret);
String result = jups.send(notification, testId);
Map<String, Object> results = new HashMap<String, Object>();
results.put("result", result);
manager.completeWorkItem(workItem.getId(), results);
}
示例5: get
import org.drools.core.process.instance.impl.WorkItemImpl; //導入依賴的package包/類
public CommandContext get() {
WorkItemImpl workItem = new WorkItemImpl();
workItem.setDeploymentId("deploymentId");
workItem.setProcessInstanceId(0);
CommandContext ctx = EJBWorkItemHelper.buildCommandContext(workItem, null);
params.forEach((key, value) -> workItem.setParameter(key, value));
return ctx;
}
示例6: testCustomExecuteFail
import org.drools.core.process.instance.impl.WorkItemImpl; //導入依賴的package包/類
@Test(expected = IllegalArgumentException.class)
public void testCustomExecuteFail() throws Exception {
CommandContext commandContext = new CommandContext();
WorkItem workItem = new WorkItemImpl();
commandContext.setData(Constants.WORKITEM, workItem);
updateDeployment.customExecute(commandContext);
}
示例7: testClass
import org.drools.core.process.instance.impl.WorkItemImpl; //導入依賴的package包/類
@Test
public void testClass() {
CamelHandler handler = CamelHandlerFactory.genericHandler("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);
}
示例8: testFtps
import org.drools.core.process.instance.impl.WorkItemImpl; //導入依賴的package包/類
@Test
public void testFtps() throws IOException {
CamelHandler handler = CamelHandlerFactory.ftpsHandler();
final String testData = "test-data";
final WorkItem workItem = new WorkItemImpl();
workItem.setParameter("username", USER);
workItem.setParameter("password", PASSWD);
workItem.setParameter("hostname", HOST);
workItem.setParameter("port", PORT.toString());
workItem.setParameter("directoryname", testFile.getParentFile().getName());
workItem.setParameter("CamelFileName", testFile.getName());
workItem.setParameter("payload", testData);
workItem.setParameter("isImplicit", "true");
workItem.setParameter("securityProtocol", "TLS");
// needed for SSL
workItem.setParameter("ftpClient.trustStore.file", CLIENT_SSL_KEY_TRUST_STORE.getAbsolutePath());
workItem.setParameter("ftpClient.trustStore.password", CLIENT_SSL_STORE_PASSWD);
workItem.setParameter("ftpClient.trustStore.keyPassword", CLIENT_SSL_KEY_PASSWD);
workItem.setParameter("ftpClient.keyStore.file", CLIENT_SSL_KEY_TRUST_STORE.getAbsolutePath());
workItem.setParameter("ftpClient.keyStore.password", CLIENT_SSL_STORE_PASSWD);
workItem.setParameter("ftpClient.keyStore.keyPassword", CLIENT_SSL_KEY_PASSWD);
WorkItemManager manager = new DefaultWorkItemManager(null);
handler.executeWorkItem(workItem, manager);
// assertions
Assert.assertTrue("Expected file does not exist.", testFile.exists());
String resultText = FileUtils.readFileToString(testFile);
Assert.assertEquals(resultText, testData);
}
示例9: testCustomExecuteSuccess
import org.drools.core.process.instance.impl.WorkItemImpl; //導入依賴的package包/類
@Test
public void testCustomExecuteSuccess() throws Exception {
Deployment deployment = ControllerTestUtils.createDeployment();
DeploymentMessage dm = TestUtil.generateDeployDm(deployment);
CommandContext commandContext = new CommandContext();
WorkItemImpl workItem = new WorkItemImpl();
RankCloudProvidersMessage rankCloudProvidersMessage = new RankCloudProvidersMessage();
rankCloudProvidersMessage.setDeploymentId(deployment.getId());
CloudProvider cp = new CloudProvider("provider-RECAS-BARI");
Map<String, CloudProvider> map = new HashMap<>();
map.put("name", cp);
rankCloudProvidersMessage.setCloudProviders(map);
RankedCloudProvider chosenCp = new RankedCloudProvider();
chosenCp.setName("name");
dm.setChosenCloudProvider(cp);
Mockito.when(cloudProviderEndpointServiceImpl.chooseCloudProvider(Mockito.any(Deployment.class),
Mockito.any(RankCloudProvidersMessage.class))).thenReturn(chosenCp);
Mockito.when(deploymentRepository.findOne(deployment.getId())).thenReturn(deployment);
Mockito.doNothing().when(deploymentStatusHelper).updateOnError(Mockito.anyString(),
Mockito.any(Exception.class));
Mockito
.when(cloudProviderEndpointServiceImpl.getCloudProviderEndpoint(cp,
rankCloudProvidersMessage.getPlacementPolicies(), false))
.thenReturn(dm.getChosenCloudProviderEndpoint());
workItem.setParameter(WorkflowConstants.WF_PARAM_RANK_CLOUD_PROVIDERS_MESSAGE,
rankCloudProvidersMessage);
workItem.setParameter(WorkflowConstants.WF_PARAM_DEPLOYMENT_MESSAGE, dm);
commandContext.setData(Constants.WORKITEM, workItem);
ExecutionResults expectedResult = new ExecutionResults();
expectedResult.setData(Constants.RESULT_STATUS, "OK");
expectedResult.setData(Constants.OK_RESULT, true);
expectedResult.setData(WorkflowConstants.WF_PARAM_DEPLOYMENT_MESSAGE, dm);
serviceSpaceProperties.setOneproviderUrl(URI.create("http://endpoint.com"));
updateDeployment.generateOneDataParameters(rankCloudProvidersMessage, dm);
Assert.assertEquals(expectedResult.toString(),
updateDeployment.customExecute(commandContext).toString());
}
示例10: testCustomExecuteSuccessWithInputData
import org.drools.core.process.instance.impl.WorkItemImpl; //導入依賴的package包/類
@Test
public void testCustomExecuteSuccessWithInputData() throws Exception {
Deployment deployment = ControllerTestUtils.createDeployment();
DeploymentMessage dm = TestUtil.generateDeployDm(deployment);
CommandContext commandContext = new CommandContext();
WorkItemImpl workItem = new WorkItemImpl();
RankCloudProvidersMessage rankCloudProvidersMessage = new RankCloudProvidersMessage();
rankCloudProvidersMessage.setDeploymentId(deployment.getId());
CloudProvider cp = new CloudProvider("provider-RECAS-BARI");
Map<String, CloudProvider> map = new HashMap<>();
map.put("name", cp);
rankCloudProvidersMessage.setCloudProviders(map);
RankedCloudProvider chosenCp = new RankedCloudProvider();
chosenCp.setName("name");
dm.setChosenCloudProvider(cp);
commandContext.setData(Constants.WORKITEM, workItem);
Map<String, OneData> oneDataRequirements = new HashMap<>();
OneData onedata =
OneData.builder().token("token").space("space").path("path").providers("providers").build();
onedata.setSmartScheduling(true);
oneDataRequirements.put("input", onedata);
dm.setOneDataRequirements(oneDataRequirements);
rankCloudProvidersMessage.setOneDataRequirements(oneDataRequirements);
workItem.setParameter(WorkflowConstants.WF_PARAM_RANK_CLOUD_PROVIDERS_MESSAGE,
rankCloudProvidersMessage);
workItem.setParameter(WorkflowConstants.WF_PARAM_DEPLOYMENT_MESSAGE, dm);
ExecutionResults expectedResult = new ExecutionResults();
expectedResult = new ExecutionResults();
expectedResult.setData(Constants.RESULT_STATUS, "OK");
expectedResult.setData(Constants.OK_RESULT, false);
expectedResult.setData(WorkflowConstants.WF_PARAM_DEPLOYMENT_MESSAGE, dm);
updateDeployment.generateOneDataParameters(rankCloudProvidersMessage, dm);
Assert.assertEquals(expectedResult.toString(),
updateDeployment.customExecute(commandContext).toString());
}
示例11: testCustomExecuteSuccessWithOutputData
import org.drools.core.process.instance.impl.WorkItemImpl; //導入依賴的package包/類
@Test
public void testCustomExecuteSuccessWithOutputData() throws Exception {
Deployment deployment = ControllerTestUtils.createDeployment();
DeploymentMessage dm = TestUtil.generateDeployDm(deployment);
CommandContext commandContext = new CommandContext();
WorkItemImpl workItem = new WorkItemImpl();
RankCloudProvidersMessage rankCloudProvidersMessage = new RankCloudProvidersMessage();
rankCloudProvidersMessage.setDeploymentId(deployment.getId());
CloudProvider cp = new CloudProvider("provider-RECAS-BARI");
Map<String, CloudProvider> map = new HashMap<>();
map.put("name", cp);
rankCloudProvidersMessage.setCloudProviders(map);
RankedCloudProvider chosenCp = new RankedCloudProvider();
chosenCp.setName("name");
dm.setChosenCloudProvider(cp);
commandContext.setData(Constants.WORKITEM, workItem);
Map<String, OneData> oneDataRequirements = new HashMap<>();
OneData onedata =
OneData.builder().token("token").space("space").path("path").providers("providers").build();
onedata.setSmartScheduling(true);
oneDataRequirements.put("output", onedata);
dm.setOneDataRequirements(oneDataRequirements);
rankCloudProvidersMessage.setOneDataRequirements(oneDataRequirements);
workItem.setParameter(WorkflowConstants.WF_PARAM_RANK_CLOUD_PROVIDERS_MESSAGE,
rankCloudProvidersMessage);
workItem.setParameter(WorkflowConstants.WF_PARAM_DEPLOYMENT_MESSAGE, dm);
ExecutionResults expectedResult = new ExecutionResults();
expectedResult = new ExecutionResults();
expectedResult.setData(Constants.RESULT_STATUS, "OK");
expectedResult.setData(Constants.OK_RESULT, false);
expectedResult.setData(WorkflowConstants.WF_PARAM_DEPLOYMENT_MESSAGE, dm);
updateDeployment.generateOneDataParameters(rankCloudProvidersMessage, dm);
Assert.assertEquals(expectedResult.toString(),
updateDeployment.customExecute(commandContext).toString());
}