when(sampleCaseDefinitionQuery.listPage(0, 1)).thenReturn(mockCaseDefinitions);
when(sampleCaseDefinitionQuery.caseDefinitionIdIn(MockProvider.EXAMPLE_CASE_DEFINITION_ID)).thenReturn(sampleCaseDefinitionQuery);
when(sampleCaseDefinitionQuery.count()).thenReturn(1l);
when(processEngine.getRepositoryService().createCaseDefinitionQuery()).thenReturn(sampleCaseDefinitionQuery);
Response response = given()
.header("accept", Hal.APPLICATION_HAL_JSON)
.pathParam("id", EXAMPLE_TASK_ID)
.then().expect().statusCode(Status.OK.getStatusCode())
.body("id", equalTo(EXAMPLE_TASK_ID))
.body("name", equalTo(MockProvider.EXAMPLE_TASK_NAME))
.body("assignee", equalTo(MockProvider.EXAMPLE_TASK_ASSIGNEE_NAME))
.body("created", equalTo(MockProvider.EXAMPLE_TASK_CREATE_TIME))
.body("due", equalTo(MockProvider.EXAMPLE_TASK_DUE_DATE))
.body("delegationState", equalTo(MockProvider.EXAMPLE_TASK_DELEGATION_STATE.toString()))
.body("description", equalTo(MockProvider.EXAMPLE_TASK_DESCRIPTION))
.body("executionId", equalTo(MockProvider.EXAMPLE_TASK_EXECUTION_ID))
.body("owner", equalTo(MockProvider.EXAMPLE_TASK_OWNER))
.body("parentTaskId", equalTo(MockProvider.EXAMPLE_TASK_PARENT_TASK_ID))
.body("priority", equalTo(MockProvider.EXAMPLE_TASK_PRIORITY))
.body("processDefinitionId", equalTo(MockProvider.EXAMPLE_PROCESS_DEFINITION_ID))
.body("processInstanceId", equalTo(MockProvider.EXAMPLE_PROCESS_INSTANCE_ID))
.body("taskDefinitionKey", equalTo(MockProvider.EXAMPLE_TASK_DEFINITION_KEY))
.body("suspended", equalTo(MockProvider.EXAMPLE_TASK_SUSPENSION_STATE))
.body("caseExecutionId", equalTo(MockProvider.EXAMPLE_CASE_EXECUTION_ID))
.body("caseInstanceId", equalTo(MockProvider.EXAMPLE_CASE_INSTANCE_ID))
.body("caseDefinitionId", equalTo(MockProvider.EXAMPLE_CASE_DEFINITION_ID))
// links
.body("_links.assignee.href", endsWith(EXAMPLE_TASK_ASSIGNEE_NAME))
.body("_links.caseDefinition.href", endsWith(EXAMPLE_CASE_DEFINITION_ID))
.body("_links.caseExecution.href", endsWith(EXAMPLE_CASE_EXECUTION_ID))
.body("_links.caseInstance.href", endsWith(EXAMPLE_CASE_INSTANCE_ID))
.body("_links.execution.href", endsWith(EXAMPLE_TASK_EXECUTION_ID))
.body("_links.owner.href", endsWith(EXAMPLE_TASK_OWNER))
.body("_links.parentTask.href", endsWith(EXAMPLE_TASK_PARENT_TASK_ID))
.body("_links.processDefinition.href", endsWith(MockProvider.EXAMPLE_PROCESS_DEFINITION_ID))
.body("_links.processInstance.href", endsWith(MockProvider.EXAMPLE_PROCESS_INSTANCE_ID))
.body("_links.self.href", endsWith(EXAMPLE_TASK_ID))
.when().get(SINGLE_TASK_URL);
String content = response.asString();
// validate embedded assignees:
List<Map<String,Object>> embeddedAssignees = from(content).getList("_embedded.assignee");
Assert.assertEquals("There should be one assignee returned.", 1, embeddedAssignees.size());
Map<String, Object> embeddedAssignee = embeddedAssignees.get(0);