Search in sources :

Example 51 with Deployment

use of org.activiti.engine.test.Deployment in project Activiti by Activiti.

the class ProcessInstanceCollectionResourceTest method testGetProcessInstancesTenant.

/**
   * Test getting a list of process instance, using all tenant filters.
   */
@Deployment(resources = { "org/activiti/rest/service/api/runtime/ProcessInstanceResourceTest.process-one.bpmn20.xml" })
public void testGetProcessInstancesTenant() throws Exception {
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("processOne", "myBusinessKey");
    String id = processInstance.getId();
    // Test without tenant id
    String url = RestUrls.createRelativeResourceUrl(RestUrls.URL_PROCESS_INSTANCE_COLLECTION) + "?withoutTenantId=true";
    assertResultsPresentInDataResponse(url, id);
    // Update the tenant for the deployment
    managementService.executeCommand(new ChangeDeploymentTenantIdCmd(deploymentId, "myTenant"));
    // Test tenant id
    url = RestUrls.createRelativeResourceUrl(RestUrls.URL_PROCESS_INSTANCE_COLLECTION) + "?tenantId=myTenant";
    assertResultsPresentInDataResponse(url, id);
    url = RestUrls.createRelativeResourceUrl(RestUrls.URL_PROCESS_INSTANCE_COLLECTION) + "?tenantId=anotherTenant";
    assertResultsPresentInDataResponse(url);
    // Test tenant id like
    url = RestUrls.createRelativeResourceUrl(RestUrls.URL_PROCESS_INSTANCE_COLLECTION) + "?tenantIdLike=" + encode("%enant");
    assertResultsPresentInDataResponse(url, id);
    url = RestUrls.createRelativeResourceUrl(RestUrls.URL_PROCESS_INSTANCE_COLLECTION) + "?tenantIdLike=" + encode("%what");
    assertResultsPresentInDataResponse(url);
    // Test without tenant id
    url = RestUrls.createRelativeResourceUrl(RestUrls.URL_PROCESS_INSTANCE_COLLECTION) + "?withoutTenantId=true";
    assertResultsPresentInDataResponse(url);
}
Also used : ChangeDeploymentTenantIdCmd(org.activiti.engine.impl.cmd.ChangeDeploymentTenantIdCmd) HistoricProcessInstance(org.activiti.engine.history.HistoricProcessInstance) ProcessInstance(org.activiti.engine.runtime.ProcessInstance) Deployment(org.activiti.engine.test.Deployment)

Example 52 with Deployment

use of org.activiti.engine.test.Deployment in project Activiti by Activiti.

the class ProcessInstanceDiagramResourceTest method testGetProcessDiagramWithoutDiagram.

@Deployment
public void testGetProcessDiagramWithoutDiagram() throws Exception {
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("oneTaskProcess");
    closeResponse(executeRequest(new HttpGet(SERVER_URL_PREFIX + RestUrls.createRelativeResourceUrl(RestUrls.URL_PROCESS_INSTANCE_DIAGRAM, processInstance.getId())), HttpStatus.SC_BAD_REQUEST));
}
Also used : HttpGet(org.apache.http.client.methods.HttpGet) ProcessInstance(org.activiti.engine.runtime.ProcessInstance) Deployment(org.activiti.engine.test.Deployment)

Example 53 with Deployment

use of org.activiti.engine.test.Deployment in project Activiti by Activiti.

the class ProcessInstanceIdentityLinkResourceTest method testCreateIdentityLink.

/**
   * Test creating an identity link.
   */
@Deployment(resources = { "org/activiti/rest/service/api/runtime/ProcessInstanceIdentityLinkResourceTest.process.bpmn20.xml" })
public void testCreateIdentityLink() throws Exception {
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("oneTaskProcess");
    // Add user link
    ObjectNode requestNode = objectMapper.createObjectNode();
    requestNode.put("user", "kermit");
    requestNode.put("type", "myType");
    HttpPost httpPost = new HttpPost(SERVER_URL_PREFIX + RestUrls.createRelativeResourceUrl(RestUrls.URL_PROCESS_INSTANCE_IDENTITYLINKS_COLLECTION, processInstance.getId()));
    httpPost.setEntity(new StringEntity(requestNode.toString()));
    CloseableHttpResponse response = executeRequest(httpPost, HttpStatus.SC_CREATED);
    JsonNode responseNode = objectMapper.readTree(response.getEntity().getContent());
    closeResponse(response);
    assertNotNull(responseNode);
    assertEquals("kermit", responseNode.get("user").textValue());
    assertEquals("myType", responseNode.get("type").textValue());
    assertTrue(responseNode.get("group").isNull());
    assertTrue(responseNode.get("url").textValue().endsWith(RestUrls.createRelativeResourceUrl(RestUrls.URL_PROCESS_INSTANCE_IDENTITYLINK, processInstance.getId(), "kermit", "myType")));
    // Test with unexisting process
    httpPost = new HttpPost(SERVER_URL_PREFIX + RestUrls.createRelativeResourceUrl(RestUrls.URL_PROCESS_INSTANCE_IDENTITYLINKS_COLLECTION, "unexistingprocess"));
    httpPost.setEntity(new StringEntity(requestNode.toString()));
    closeResponse(executeRequest(httpPost, HttpStatus.SC_NOT_FOUND));
    // Test with no user
    requestNode = objectMapper.createObjectNode();
    requestNode.put("type", "myType");
    httpPost = new HttpPost(SERVER_URL_PREFIX + RestUrls.createRelativeResourceUrl(RestUrls.URL_PROCESS_INSTANCE_IDENTITYLINKS_COLLECTION, processInstance.getId()));
    httpPost.setEntity(new StringEntity(requestNode.toString()));
    closeResponse(executeRequest(httpPost, HttpStatus.SC_BAD_REQUEST));
    // Test with group (which is not supported on processes)
    requestNode = objectMapper.createObjectNode();
    requestNode.put("type", "myType");
    requestNode.put("group", "sales");
    httpPost.setEntity(new StringEntity(requestNode.toString()));
    closeResponse(executeRequest(httpPost, HttpStatus.SC_BAD_REQUEST));
    // Test with no type
    requestNode = objectMapper.createObjectNode();
    requestNode.put("user", "kermit");
    httpPost.setEntity(new StringEntity(requestNode.toString()));
    closeResponse(executeRequest(httpPost, HttpStatus.SC_BAD_REQUEST));
}
Also used : HttpPost(org.apache.http.client.methods.HttpPost) StringEntity(org.apache.http.entity.StringEntity) ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) CloseableHttpResponse(org.apache.http.client.methods.CloseableHttpResponse) ProcessInstance(org.activiti.engine.runtime.ProcessInstance) JsonNode(com.fasterxml.jackson.databind.JsonNode) Deployment(org.activiti.engine.test.Deployment)

Example 54 with Deployment

use of org.activiti.engine.test.Deployment in project Activiti by Activiti.

the class ProcessInstanceIdentityLinkResourceTest method testDeleteSingleIdentityLink.

/**
   * Test deleting a single identity link for a process instance.
   */
@Deployment(resources = { "org/activiti/rest/service/api/runtime/ProcessInstanceIdentityLinkResourceTest.process.bpmn20.xml" })
public void testDeleteSingleIdentityLink() throws Exception {
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("oneTaskProcess");
    runtimeService.addUserIdentityLink(processInstance.getId(), "kermit", "myType");
    closeResponse(executeRequest(new HttpDelete(SERVER_URL_PREFIX + RestUrls.createRelativeResourceUrl(RestUrls.URL_PROCESS_INSTANCE_IDENTITYLINK, processInstance.getId(), "kermit", "myType")), HttpStatus.SC_NO_CONTENT));
    // Test with unexisting process identity link
    closeResponse(executeRequest(new HttpDelete(SERVER_URL_PREFIX + RestUrls.createRelativeResourceUrl(RestUrls.URL_PROCESS_INSTANCE_IDENTITYLINK, processInstance.getId(), "kermit", "myType")), HttpStatus.SC_NOT_FOUND));
    // Test with unexisting process
    closeResponse(executeRequest(new HttpDelete(SERVER_URL_PREFIX + RestUrls.createRelativeResourceUrl(RestUrls.URL_PROCESS_INSTANCE_IDENTITYLINK, "unexistingprocess", RestUrls.SEGMENT_IDENTITYLINKS_FAMILY_USERS, "kermit", "myType")), HttpStatus.SC_NOT_FOUND));
}
Also used : HttpDelete(org.apache.http.client.methods.HttpDelete) ProcessInstance(org.activiti.engine.runtime.ProcessInstance) Deployment(org.activiti.engine.test.Deployment)

Example 55 with Deployment

use of org.activiti.engine.test.Deployment in project Activiti by Activiti.

the class ProcessInstanceIdentityLinkResourceTest method testGetSingleIdentityLink.

/**
   * Test getting a single identity link for a process instance.
   */
@Deployment(resources = { "org/activiti/rest/service/api/runtime/ProcessInstanceIdentityLinkResourceTest.process.bpmn20.xml" })
public void testGetSingleIdentityLink() throws Exception {
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("oneTaskProcess");
    runtimeService.addUserIdentityLink(processInstance.getId(), "kermit", "myType");
    CloseableHttpResponse response = executeRequest(new HttpGet(SERVER_URL_PREFIX + RestUrls.createRelativeResourceUrl(RestUrls.URL_PROCESS_INSTANCE_IDENTITYLINK, processInstance.getId(), "kermit", "myType")), HttpStatus.SC_OK);
    JsonNode responseNode = objectMapper.readTree(response.getEntity().getContent());
    closeResponse(response);
    assertNotNull(responseNode);
    assertEquals("kermit", responseNode.get("user").textValue());
    assertEquals("myType", responseNode.get("type").textValue());
    assertTrue(responseNode.get("group").isNull());
    assertTrue(responseNode.get("url").textValue().endsWith(RestUrls.createRelativeResourceUrl(RestUrls.URL_PROCESS_INSTANCE_IDENTITYLINK, processInstance.getId(), "kermit", "myType")));
    // Test with unexisting process
    closeResponse(executeRequest(new HttpGet(SERVER_URL_PREFIX + RestUrls.createRelativeResourceUrl(RestUrls.URL_PROCESS_INSTANCE_IDENTITYLINK, RestUrls.SEGMENT_IDENTITYLINKS_FAMILY_USERS, "kermit", "myType")), HttpStatus.SC_NOT_FOUND));
}
Also used : HttpGet(org.apache.http.client.methods.HttpGet) CloseableHttpResponse(org.apache.http.client.methods.CloseableHttpResponse) ProcessInstance(org.activiti.engine.runtime.ProcessInstance) JsonNode(com.fasterxml.jackson.databind.JsonNode) Deployment(org.activiti.engine.test.Deployment)

Aggregations

Deployment (org.activiti.engine.test.Deployment)1178 ProcessInstance (org.activiti.engine.runtime.ProcessInstance)846 Task (org.activiti.engine.task.Task)549 HashMap (java.util.HashMap)277 HistoricProcessInstance (org.activiti.engine.history.HistoricProcessInstance)218 Execution (org.activiti.engine.runtime.Execution)151 Date (java.util.Date)94 Job (org.activiti.engine.runtime.Job)91 ProcessDefinition (org.activiti.engine.repository.ProcessDefinition)87 CloseableHttpResponse (org.apache.http.client.methods.CloseableHttpResponse)87 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)85 JsonNode (com.fasterxml.jackson.databind.JsonNode)66 Calendar (java.util.Calendar)63 DelegateTask (org.activiti.engine.delegate.DelegateTask)52 StringEntity (org.apache.http.entity.StringEntity)50 ArrayList (java.util.ArrayList)49 HttpGet (org.apache.http.client.methods.HttpGet)49 HistoricActivityInstance (org.activiti.engine.history.HistoricActivityInstance)41 HistoricTaskInstance (org.activiti.engine.history.HistoricTaskInstance)34 ActivitiException (org.activiti.engine.ActivitiException)31