use of org.activiti.engine.test.Deployment in project Activiti by Activiti.
the class JobResourceTest method testExecuteJob.
/**
* Test executing a single job.
*/
@Deployment(resources = { "org/activiti/rest/service/api/management/JobResourceTest.testTimerProcess.bpmn20.xml" })
public void testExecuteJob() throws Exception {
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("timerProcess");
Job timerJob = managementService.createJobQuery().processInstanceId(processInstance.getId()).singleResult();
assertNotNull(timerJob);
ObjectNode requestNode = objectMapper.createObjectNode();
requestNode.put("action", "execute");
HttpPost httpPost = new HttpPost(SERVER_URL_PREFIX + RestUrls.createRelativeResourceUrl(RestUrls.URL_JOB, timerJob.getId()));
httpPost.setEntity(new StringEntity(requestNode.toString()));
CloseableHttpResponse response = executeRequest(httpPost, HttpStatus.SC_NO_CONTENT);
closeResponse(response);
// Job should be executed
assertNull(managementService.createJobQuery().processInstanceId(processInstance.getId()).singleResult());
}
use of org.activiti.engine.test.Deployment in project Activiti by Activiti.
the class JobResourceTest method testGetJob.
/**
* Test getting a single job.
*/
@Deployment(resources = { "org/activiti/rest/service/api/management/JobResourceTest.testTimerProcess.bpmn20.xml" })
public void testGetJob() throws Exception {
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("timerProcess");
Job timerJob = managementService.createJobQuery().processInstanceId(processInstance.getId()).singleResult();
assertNotNull(timerJob);
Calendar now = Calendar.getInstance();
now.set(Calendar.MILLISECOND, 0);
processEngineConfiguration.getClock().setCurrentTime(now.getTime());
CloseableHttpResponse response = executeRequest(new HttpGet(SERVER_URL_PREFIX + RestUrls.createRelativeResourceUrl(RestUrls.URL_JOB, timerJob.getId())), HttpStatus.SC_OK);
JsonNode responseNode = objectMapper.readTree(response.getEntity().getContent());
closeResponse(response);
assertNotNull(responseNode);
assertEquals(timerJob.getId(), responseNode.get("id").textValue());
assertEquals(timerJob.getExceptionMessage(), responseNode.get("exceptionMessage").textValue());
assertEquals(timerJob.getExecutionId(), responseNode.get("executionId").textValue());
assertEquals(timerJob.getProcessDefinitionId(), responseNode.get("processDefinitionId").textValue());
assertEquals(timerJob.getProcessInstanceId(), responseNode.get("processInstanceId").textValue());
assertEquals(timerJob.getRetries(), responseNode.get("retries").intValue());
assertEquals(timerJob.getDuedate(), getDateFromISOString(responseNode.get("dueDate").textValue()));
assertEquals("", responseNode.get("tenantId").textValue());
// Set tenant on deployment
managementService.executeCommand(new ChangeDeploymentTenantIdCmd(deploymentId, "myTenant"));
response = executeRequest(new HttpGet(SERVER_URL_PREFIX + RestUrls.createRelativeResourceUrl(RestUrls.URL_JOB, timerJob.getId())), HttpStatus.SC_OK);
responseNode = objectMapper.readTree(response.getEntity().getContent());
closeResponse(response);
assertNotNull(responseNode);
assertEquals("myTenant", responseNode.get("tenantId").textValue());
}
use of org.activiti.engine.test.Deployment in project Activiti by Activiti.
the class GroupCollectionResourceTest method testGetGroups.
/**
* Test getting all groups.
*/
@Deployment
public void testGetGroups() throws Exception {
List<Group> savedGroups = new ArrayList<Group>();
try {
Group group1 = identityService.newGroup("testgroup1");
group1.setName("Test group");
group1.setType("Test type");
identityService.saveGroup(group1);
savedGroups.add(group1);
Group group2 = identityService.newGroup("testgroup2");
group2.setName("Another group");
group2.setType("Another type");
identityService.saveGroup(group2);
savedGroups.add(group2);
Group group3 = identityService.createGroupQuery().groupId("admin").singleResult();
assertNotNull(group3);
// Test filter-less
String url = RestUrls.createRelativeResourceUrl(RestUrls.URL_GROUP_COLLECTION);
assertResultsPresentInDataResponse(url, group1.getId(), group2.getId(), group3.getId());
// Test based on name
url = RestUrls.createRelativeResourceUrl(RestUrls.URL_GROUP_COLLECTION) + "?name=" + encode("Test group");
assertResultsPresentInDataResponse(url, group1.getId());
// Test based on name like
url = RestUrls.createRelativeResourceUrl(RestUrls.URL_GROUP_COLLECTION) + "?nameLike=" + encode("% group");
assertResultsPresentInDataResponse(url, group2.getId(), group1.getId());
// Test based on type
url = RestUrls.createRelativeResourceUrl(RestUrls.URL_GROUP_COLLECTION) + "?type=" + encode("Another type");
assertResultsPresentInDataResponse(url, group2.getId());
// Test based on group member
url = RestUrls.createRelativeResourceUrl(RestUrls.URL_GROUP_COLLECTION) + "?member=kermit";
assertResultsPresentInDataResponse(url, group3.getId());
// Test based on potentialStarter
String processDefinitionId = repositoryService.createProcessDefinitionQuery().processDefinitionKey("simpleProcess").singleResult().getId();
repositoryService.addCandidateStarterGroup(processDefinitionId, "admin");
url = RestUrls.createRelativeResourceUrl(RestUrls.URL_GROUP_COLLECTION) + "?potentialStarter=" + processDefinitionId;
assertResultsPresentInDataResponse(url, group3.getId());
} finally {
// Delete groups after test passes or fails
if (!savedGroups.isEmpty()) {
for (Group group : savedGroups) {
identityService.deleteGroup(group.getId());
}
}
}
}
use of org.activiti.engine.test.Deployment in project Activiti by Activiti.
the class WebServiceSimplisticTest method testWebResponseKeywordName.
@Deployment
public void testWebResponseKeywordName() throws Exception {
Map<String, Object> variables = new HashMap<String, Object>();
variables.put("PrefixVariable", "The counter has the value ");
variables.put("SuffixVariable", ". Good news Keyword");
ProcessInstance instance = processEngine.getRuntimeService().startProcessInstanceByKey("webServiceInvocationWithSimplisticDataFlow", variables);
waitForJobExecutorToProcessAllJobs(10000L, 250L);
String response = (String) processEngine.getRuntimeService().getVariable(instance.getId(), "OutputVariable");
assertEquals("The counter has the value -1. Good news Keyword", response);
}
use of org.activiti.engine.test.Deployment in project Activiti by Activiti.
the class WebServiceSimplisticTest method testWebResponseNoName.
@Deployment
public void testWebResponseNoName() throws Exception {
Map<String, Object> variables = new HashMap<String, Object>();
variables.put("PrefixVariable", "The counter has the value ");
variables.put("SuffixVariable", ". Good news (NO NAME)");
ProcessInstance instance = processEngine.getRuntimeService().startProcessInstanceByKey("webServiceInvocationWithSimplisticDataFlow", variables);
waitForJobExecutorToProcessAllJobs(10000L, 250L);
String response = (String) processEngine.getRuntimeService().getVariable(instance.getId(), "OutputVariable");
assertEquals("The counter has the value -1. Good news (NO NAME)", response);
}
Aggregations