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);
}
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));
}
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));
}
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));
}
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));
}
Aggregations