Search in sources :

Example 21 with ExecutionResults

use of org.kie.api.executor.ExecutionResults in project jbpm by kiegroup.

the class CheckCallCommand method execute.

@Override
public ExecutionResults execute(CommandContext ctx) throws Exception {
    logger.debug("Command executed on executor with data {}", ctx.getData());
    // wait for all parties to wait on barrier
    barrier.await();
    ExecutionResults executionResults = new ExecutionResults();
    executionResults.setData("commandExecuted", true);
    return executionResults;
}
Also used : ExecutionResults(org.kie.api.executor.ExecutionResults)

Example 22 with ExecutionResults

use of org.kie.api.executor.ExecutionResults in project jbpm by kiegroup.

the class UserCommand method execute.

public ExecutionResults execute(CommandContext ctx) {
    System.out.println("[INFO] Command executed on executor with " + ctx.getData());
    WorkItem workItem = (WorkItem) ctx.getData("workItem");
    User user = (User) workItem.getParameter("UserIn");
    user.setName(user.getName() + " after command execution");
    ExecutionResults executionResults = new ExecutionResults();
    executionResults.setData("UserOut", user);
    double item = 0;
    for (int i = 0; i < 99; i++) {
        System.out.println("[INFO] User item:" + item);
        item++;
    }
    return executionResults;
}
Also used : ExecutionResults(org.kie.api.executor.ExecutionResults) WorkItem(org.kie.api.runtime.process.WorkItem)

Example 23 with ExecutionResults

use of org.kie.api.executor.ExecutionResults in project jbpm by kiegroup.

the class WebServiceCommandTest method testExecuteCommandWithBasicAuth.

@Test
public void testExecuteCommandWithBasicAuth() throws Exception {
    Object[] clientObject = Arrays.asList("testResults").toArray();
    when(clients.containsKey(anyObject())).thenReturn(true);
    when(clients.get(anyObject())).thenReturn(client);
    when(client.invoke(anyString(), any(Object[].class))).thenReturn(clientObject);
    WorkItemImpl workItem = new WorkItemImpl();
    workItem.setParameter("Interface", "someInterface");
    workItem.setParameter("Operation", "someOperation");
    workItem.setParameter("Username", "testUserName");
    workItem.setParameter("Password", "testPassword");
    when(commandContext.getData(anyString())).thenReturn(workItem);
    HTTPConduit http = Mockito.mock(HTTPConduit.class, Mockito.CALLS_REAL_METHODS);
    when(client.getConduit()).thenReturn(http);
    WebServiceCommand command = new WebServiceCommand();
    command.setClients(clients);
    ExecutionResults results = command.execute(commandContext);
    assertNotNull(results);
    assertEquals("testResults", results.getData("Result"));
    assertNotNull(http.getAuthorization());
    AuthorizationPolicy authorizationPolicy = http.getAuthorization();
    assertEquals("Basic", authorizationPolicy.getAuthorizationType());
    assertEquals("testUserName", authorizationPolicy.getUserName());
    assertEquals("testPassword", authorizationPolicy.getPassword());
}
Also used : HTTPConduit(org.apache.cxf.transport.http.HTTPConduit) AuthorizationPolicy(org.apache.cxf.configuration.security.AuthorizationPolicy) ExecutionResults(org.kie.api.executor.ExecutionResults) WorkItemImpl(org.drools.core.process.instance.impl.WorkItemImpl) Test(org.junit.Test)

Aggregations

ExecutionResults (org.kie.api.executor.ExecutionResults)23 Date (java.util.Date)5 EntityManagerFactory (javax.persistence.EntityManagerFactory)4 Test (org.junit.Test)4 WorkItem (org.kie.api.runtime.process.WorkItem)4 ByteArrayInputStream (java.io.ByteArrayInputStream)3 IOException (java.io.IOException)3 ObjectInputStream (java.io.ObjectInputStream)3 HashMap (java.util.HashMap)3 CommandContext (org.kie.api.executor.CommandContext)3 RuntimeEngine (org.kie.api.runtime.manager.RuntimeEngine)3 RuntimeManager (org.kie.api.runtime.manager.RuntimeManager)3 QueryContext (org.kie.api.runtime.query.QueryContext)3 SimpleDateFormat (java.text.SimpleDateFormat)2 Map (java.util.Map)2 AtomicLong (java.util.concurrent.atomic.AtomicLong)2 BeanManager (javax.enterprise.inject.spi.BeanManager)2 WorkItemImpl (org.drools.core.process.instance.impl.WorkItemImpl)2 TransactionalCommandService (org.jbpm.shared.services.impl.TransactionalCommandService)2 ExecutorService (org.kie.api.executor.ExecutorService)2