use of org.apache.http.client.methods.CloseableHttpResponse in project Activiti by Activiti.
the class ProcessDefinitionResourceTest method testActivateProcessDefinition.
/**
* Test activating a suspended process definition.
* POST repository/process-definitions/{processDefinitionId}
*/
@Deployment(resources = { "org/activiti/rest/service/api/repository/oneTaskProcess.bpmn20.xml" })
public void testActivateProcessDefinition() throws Exception {
ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().singleResult();
repositoryService.suspendProcessDefinitionById(processDefinition.getId());
processDefinition = repositoryService.createProcessDefinitionQuery().singleResult();
assertTrue(processDefinition.isSuspended());
ObjectNode requestNode = objectMapper.createObjectNode();
requestNode.put("action", "activate");
HttpPut httpPut = new HttpPut(SERVER_URL_PREFIX + RestUrls.createRelativeResourceUrl(RestUrls.URL_PROCESS_DEFINITION, processDefinition.getId()));
httpPut.setEntity(new StringEntity(requestNode.toString()));
CloseableHttpResponse response = executeRequest(httpPut, HttpStatus.SC_OK);
// Check "OK" status
JsonNode responseNode = objectMapper.readTree(response.getEntity().getContent());
closeResponse(response);
assertFalse(responseNode.get("suspended").booleanValue());
// Check if process-definitoin is suspended
processDefinition = repositoryService.createProcessDefinitionQuery().singleResult();
assertFalse(processDefinition.isSuspended());
}
use of org.apache.http.client.methods.CloseableHttpResponse in project Activiti by Activiti.
the class ProcessDefinitionResourceTest method testIllegalAction.
/**
* Test executing an unexisting action.
*
* POST repository/process-definitions/{processDefinitionId}
*/
@Deployment(resources = { "org/activiti/rest/service/api/repository/oneTaskProcess.bpmn20.xml" })
public void testIllegalAction() throws Exception {
ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().singleResult();
assertFalse(processDefinition.isSuspended());
ObjectNode requestNode = objectMapper.createObjectNode();
requestNode.put("action", "unexistingaction");
HttpPut httpPut = new HttpPut(SERVER_URL_PREFIX + RestUrls.createRelativeResourceUrl(RestUrls.URL_PROCESS_DEFINITION, processDefinition.getId()));
httpPut.setEntity(new StringEntity(requestNode.toString()));
CloseableHttpResponse response = executeRequest(httpPut, HttpStatus.SC_BAD_REQUEST);
closeResponse(response);
}
use of org.apache.http.client.methods.CloseableHttpResponse in project Activiti by Activiti.
the class ProcessDefinitionResourceTest method testSuspendProcessDefinitionDelayed.
/**
* Test suspending a process definition on a certain date.
* POST repository/process-definitions/{processDefinitionId}
*/
@Deployment(resources = { "org/activiti/rest/service/api/repository/oneTaskProcess.bpmn20.xml" })
public void testSuspendProcessDefinitionDelayed() throws Exception {
ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().singleResult();
assertFalse(processDefinition.isSuspended());
ObjectNode requestNode = objectMapper.createObjectNode();
Calendar cal = Calendar.getInstance();
cal.add(Calendar.HOUR, 2);
// Format the date using ISO date format
DateTimeFormatter formatter = ISODateTimeFormat.dateTime();
String dateString = formatter.print(cal.getTimeInMillis());
requestNode.put("action", "suspend");
requestNode.put("date", dateString);
HttpPut httpPut = new HttpPut(SERVER_URL_PREFIX + RestUrls.createRelativeResourceUrl(RestUrls.URL_PROCESS_DEFINITION, processDefinition.getId()));
httpPut.setEntity(new StringEntity(requestNode.toString()));
CloseableHttpResponse response = executeRequest(httpPut, HttpStatus.SC_OK);
// Check "OK" status
JsonNode responseNode = objectMapper.readTree(response.getEntity().getContent());
closeResponse(response);
assertTrue(responseNode.get("suspended").booleanValue());
// Check if process-definition is not yet suspended
processDefinition = repositoryService.createProcessDefinitionQuery().singleResult();
assertFalse(processDefinition.isSuspended());
// Force suspension by altering time
cal.add(Calendar.HOUR, 1);
processEngineConfiguration.getClock().setCurrentTime(cal.getTime());
waitForJobExecutorToProcessAllJobs(5000, 100);
// Check if process-definition is suspended
processDefinition = repositoryService.createProcessDefinitionQuery().singleResult();
assertTrue(processDefinition.isSuspended());
}
use of org.apache.http.client.methods.CloseableHttpResponse in project Activiti by Activiti.
the class ProcessDefinitionResourceTest method testGetResourceContentForUnexistingProcessDefinition.
/**
* Test getting resource content for an unexisting process-definition .
*/
public void testGetResourceContentForUnexistingProcessDefinition() throws Exception {
HttpGet httpGet = new HttpGet(SERVER_URL_PREFIX + RestUrls.createRelativeResourceUrl(RestUrls.URL_PROCESS_DEFINITION_RESOURCE_CONTENT, "unexisting"));
CloseableHttpResponse response = executeRequest(httpGet, HttpStatus.SC_NOT_FOUND);
closeResponse(response);
}
use of org.apache.http.client.methods.CloseableHttpResponse in project Activiti by Activiti.
the class ExecutionActiveActivitiesCollectionResourceTest method testGetActivities.
@Deployment
public void testGetActivities() throws Exception {
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("processOne");
CloseableHttpResponse response = executeRequest(new HttpGet(SERVER_URL_PREFIX + RestUrls.createRelativeResourceUrl(RestUrls.URL_EXECUTION_ACTIVITIES_COLLECTION, processInstance.getId())), HttpStatus.SC_OK);
// Check resulting instance
JsonNode responseNode = objectMapper.readTree(response.getEntity().getContent());
closeResponse(response);
assertNotNull(responseNode);
assertTrue(responseNode.isArray());
assertEquals(2, responseNode.size());
Set<String> states = new HashSet<String>();
states.add(responseNode.get(0).textValue());
states.add(responseNode.get(1).textValue());
assertTrue(states.contains("waitState"));
assertTrue(states.contains("anotherWaitState"));
}
Aggregations