當前位置: 首頁>>代碼示例>>Java>>正文


Java WorkItemImpl類代碼示例

本文整理匯總了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);
}
 
開發者ID:jboss-integration,項目名稱:fuse-bxms-integ,代碼行數:25,代碼來源:CamelFileTest.java

示例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);
}
 
開發者ID:jboss-integration,項目名稱:fuse-bxms-integ,代碼行數:24,代碼來源:CamelFtpTest.java

示例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);
}
 
開發者ID:jboss-integration,項目名稱:fuse-bxms-integ,代碼行數:22,代碼來源:CamelFileTest.java

示例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);
    }
 
開發者ID:SLAMon,項目名稱:SLAMon,代碼行數:38,代碼來源:SLAMonJupsHandler.java

示例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;
}
 
開發者ID:indigo-dc,項目名稱:orchestrator,代碼行數:11,代碼來源:TestCommandHelper.java

示例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);
}
 
開發者ID:indigo-dc,項目名稱:orchestrator,代碼行數:8,代碼來源:UpdateDeploymentTest.java

示例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);
}
 
開發者ID:jboss-integration,項目名稱:fuse-bxms-integ,代碼行數:14,代碼來源:CamelGenericTest.java

示例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);
}
 
開發者ID:jboss-integration,項目名稱:fuse-bxms-integ,代碼行數:36,代碼來源:CamelFtpsTest.java

示例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());

}
 
開發者ID:indigo-dc,項目名稱:orchestrator,代碼行數:48,代碼來源:UpdateDeploymentTest.java

示例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());

}
 
開發者ID:indigo-dc,項目名稱:orchestrator,代碼行數:45,代碼來源:UpdateDeploymentTest.java

示例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());

}
 
開發者ID:indigo-dc,項目名稱:orchestrator,代碼行數:45,代碼來源:UpdateDeploymentTest.java


注:本文中的org.drools.core.process.instance.impl.WorkItemImpl類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。