Search in sources :

Example 1 with ProcessDefinition

use of org.camunda.bpm.engine.repository.ProcessDefinition in project camunda-bpm-platform by camunda.

the class TaskRestServiceInteractionTest method setUpRuntimeData.

@Before
public void setUpRuntimeData() {
    taskServiceMock = mock(TaskService.class);
    when(processEngine.getTaskService()).thenReturn(taskServiceMock);
    mockTask = MockProvider.createMockTask();
    mockQuery = mock(TaskQuery.class);
    when(mockQuery.initializeFormKeys()).thenReturn(mockQuery);
    when(mockQuery.taskId(anyString())).thenReturn(mockQuery);
    when(mockQuery.singleResult()).thenReturn(mockTask);
    when(taskServiceMock.createTaskQuery()).thenReturn(mockQuery);
    List<IdentityLink> identityLinks = new ArrayList<IdentityLink>();
    mockAssigneeIdentityLink = MockProvider.createMockUserAssigneeIdentityLink();
    identityLinks.add(mockAssigneeIdentityLink);
    mockOwnerIdentityLink = MockProvider.createMockUserOwnerIdentityLink();
    identityLinks.add(mockOwnerIdentityLink);
    mockCandidateGroupIdentityLink = MockProvider.createMockCandidateGroupIdentityLink();
    identityLinks.add(mockCandidateGroupIdentityLink);
    mockCandidateGroup2IdentityLink = MockProvider.createAnotherMockCandidateGroupIdentityLink();
    identityLinks.add(mockCandidateGroup2IdentityLink);
    when(taskServiceMock.getIdentityLinksForTask(EXAMPLE_TASK_ID)).thenReturn(identityLinks);
    mockTaskComment = MockProvider.createMockTaskComment();
    when(taskServiceMock.getTaskComment(EXAMPLE_TASK_ID, EXAMPLE_TASK_COMMENT_ID)).thenReturn(mockTaskComment);
    mockTaskComments = MockProvider.createMockTaskComments();
    when(taskServiceMock.getTaskComments(EXAMPLE_TASK_ID)).thenReturn(mockTaskComments);
    when(taskServiceMock.createComment(EXAMPLE_TASK_ID, null, EXAMPLE_TASK_COMMENT_FULL_MESSAGE)).thenReturn(mockTaskComment);
    mockTaskAttachment = MockProvider.createMockTaskAttachment();
    when(taskServiceMock.getTaskAttachment(EXAMPLE_TASK_ID, EXAMPLE_TASK_ATTACHMENT_ID)).thenReturn(mockTaskAttachment);
    mockTaskAttachments = MockProvider.createMockTaskAttachments();
    when(taskServiceMock.getTaskAttachments(EXAMPLE_TASK_ID)).thenReturn(mockTaskAttachments);
    when(taskServiceMock.createAttachment(anyString(), anyString(), anyString(), anyString(), anyString(), anyString())).thenReturn(mockTaskAttachment);
    when(taskServiceMock.createAttachment(anyString(), anyString(), anyString(), anyString(), anyString(), any(InputStream.class))).thenReturn(mockTaskAttachment);
    when(taskServiceMock.getTaskAttachmentContent(EXAMPLE_TASK_ID, EXAMPLE_TASK_ATTACHMENT_ID)).thenReturn(new ByteArrayInputStream(createMockByteData()));
    formServiceMock = mock(FormService.class);
    when(processEngine.getFormService()).thenReturn(formServiceMock);
    TaskFormData mockFormData = MockProvider.createMockTaskFormData();
    when(formServiceMock.getTaskFormData(anyString())).thenReturn(mockFormData);
    VariableMap variablesMock = MockProvider.createMockFormVariables();
    when(formServiceMock.getTaskFormVariables(eq(EXAMPLE_TASK_ID), Matchers.<Collection<String>>any(), anyBoolean())).thenReturn(variablesMock);
    repositoryServiceMock = mock(RepositoryService.class);
    when(processEngine.getRepositoryService()).thenReturn(repositoryServiceMock);
    ProcessDefinition mockDefinition = MockProvider.createMockDefinition();
    when(repositoryServiceMock.getProcessDefinition(MockProvider.EXAMPLE_PROCESS_DEFINITION_ID)).thenReturn(mockDefinition);
    managementServiceMock = mock(ManagementService.class);
    when(processEngine.getManagementService()).thenReturn(managementServiceMock);
    when(managementServiceMock.getProcessApplicationForDeployment(MockProvider.EXAMPLE_DEPLOYMENT_ID)).thenReturn(MockProvider.EXAMPLE_PROCESS_APPLICATION_NAME);
    when(managementServiceMock.getHistoryLevel()).thenReturn(ProcessEngineConfigurationImpl.HISTORYLEVEL_FULL);
    HistoryService historyServiceMock = mock(HistoryService.class);
    when(processEngine.getHistoryService()).thenReturn(historyServiceMock);
    historicTaskInstanceQueryMock = mock(HistoricTaskInstanceQuery.class);
    when(historyServiceMock.createHistoricTaskInstanceQuery()).thenReturn(historicTaskInstanceQueryMock);
    when(historicTaskInstanceQueryMock.taskId(eq(EXAMPLE_TASK_ID))).thenReturn(historicTaskInstanceQueryMock);
    HistoricTaskInstance historicTaskInstanceMock = createMockHistoricTaskInstance();
    when(historicTaskInstanceQueryMock.singleResult()).thenReturn(historicTaskInstanceMock);
    // replace the runtime container delegate & process application service with a mock
    ProcessApplicationService processApplicationService = mock(ProcessApplicationService.class);
    ProcessApplicationInfo appMock = MockProvider.createMockProcessApplicationInfo();
    when(processApplicationService.getProcessApplicationInfo(MockProvider.EXAMPLE_PROCESS_APPLICATION_NAME)).thenReturn(appMock);
    RuntimeContainerDelegate delegate = mock(RuntimeContainerDelegate.class);
    when(delegate.getProcessApplicationService()).thenReturn(processApplicationService);
    RuntimeContainerDelegate.INSTANCE.set(delegate);
}
Also used : HistoricTaskInstance(org.camunda.bpm.engine.history.HistoricTaskInstance) MockProvider.createMockHistoricTaskInstance(org.camunda.bpm.engine.rest.helper.MockProvider.createMockHistoricTaskInstance) TaskService(org.camunda.bpm.engine.TaskService) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) ProcessApplicationService(org.camunda.bpm.ProcessApplicationService) FormService(org.camunda.bpm.engine.FormService) ArrayList(java.util.ArrayList) HistoryService(org.camunda.bpm.engine.HistoryService) TaskFormData(org.camunda.bpm.engine.form.TaskFormData) ProcessDefinition(org.camunda.bpm.engine.repository.ProcessDefinition) Matchers.containsString(org.hamcrest.Matchers.containsString) Matchers.anyString(org.mockito.Matchers.anyString) HistoricTaskInstanceQuery(org.camunda.bpm.engine.history.HistoricTaskInstanceQuery) IdentityLink(org.camunda.bpm.engine.task.IdentityLink) ManagementService(org.camunda.bpm.engine.ManagementService) ByteArrayInputStream(java.io.ByteArrayInputStream) VariableMap(org.camunda.bpm.engine.variable.VariableMap) TaskQuery(org.camunda.bpm.engine.task.TaskQuery) ProcessApplicationInfo(org.camunda.bpm.application.ProcessApplicationInfo) RuntimeContainerDelegate(org.camunda.bpm.container.RuntimeContainerDelegate) RepositoryService(org.camunda.bpm.engine.RepositoryService) Before(org.junit.Before)

Example 2 with ProcessDefinition

use of org.camunda.bpm.engine.repository.ProcessDefinition in project camunda-bpm-platform by camunda.

the class TaskRestServiceInteractionTest method testGetSingleTaskHal.

@Test
@SuppressWarnings("unchecked")
public void testGetSingleTaskHal() {
    // setup user query mock
    List<User> mockUsers = Arrays.asList(MockProvider.mockUser().id(EXAMPLE_TASK_ASSIGNEE_NAME).build(), MockProvider.mockUser().id(EXAMPLE_TASK_OWNER).build());
    UserQuery sampleUserQuery = mock(UserQuery.class);
    when(sampleUserQuery.userIdIn(eq(EXAMPLE_TASK_ASSIGNEE_NAME), eq(EXAMPLE_TASK_OWNER))).thenReturn(sampleUserQuery);
    when(sampleUserQuery.userIdIn(eq(EXAMPLE_TASK_OWNER), eq(EXAMPLE_TASK_ASSIGNEE_NAME))).thenReturn(sampleUserQuery);
    when(sampleUserQuery.listPage(eq(0), eq(2))).thenReturn(mockUsers);
    when(sampleUserQuery.count()).thenReturn((long) mockUsers.size());
    when(processEngine.getIdentityService().createUserQuery()).thenReturn(sampleUserQuery);
    // setup group query mock
    List<Group> mockGroups = Arrays.asList(MockProvider.mockGroup().id(mockCandidateGroupIdentityLink.getGroupId()).build(), MockProvider.mockGroup().id(mockCandidateGroup2IdentityLink.getGroupId()).build());
    GroupQuery sampleGroupQuery = mock(GroupQuery.class);
    when(sampleGroupQuery.groupIdIn(eq(EXAMPLE_GROUP_ID), eq(EXAMPLE_GROUP_ID2))).thenReturn(sampleGroupQuery);
    when(sampleGroupQuery.groupIdIn(eq(EXAMPLE_GROUP_ID2), eq(EXAMPLE_GROUP_ID))).thenReturn(sampleGroupQuery);
    when(sampleGroupQuery.listPage(eq(0), eq(2))).thenReturn(mockGroups);
    when(sampleGroupQuery.count()).thenReturn((long) mockGroups.size());
    when(processEngine.getIdentityService().createGroupQuery()).thenReturn(sampleGroupQuery);
    // setup process definition query mock
    List<ProcessDefinition> mockDefinitions = MockProvider.createMockDefinitions();
    ProcessDefinitionQuery sampleProcessDefinitionQuery = mock(ProcessDefinitionQuery.class);
    when(sampleProcessDefinitionQuery.listPage(0, 1)).thenReturn(mockDefinitions);
    when(sampleProcessDefinitionQuery.processDefinitionIdIn(MockProvider.EXAMPLE_PROCESS_DEFINITION_ID)).thenReturn(sampleProcessDefinitionQuery);
    when(sampleProcessDefinitionQuery.count()).thenReturn(1l);
    when(processEngine.getRepositoryService().createProcessDefinitionQuery()).thenReturn(sampleProcessDefinitionQuery);
    // setup case definition query mock
    List<CaseDefinition> mockCaseDefinitions = MockProvider.createMockCaseDefinitions();
    CaseDefinitionQuery sampleCaseDefinitionQuery = mock(CaseDefinitionQuery.class);
    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)).body("tenantId", equalTo(MockProvider.EXAMPLE_TENANT_ID)).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.identityLink.href", endsWith("/task/" + EXAMPLE_TASK_ID + "/identity-links")).body("_links.self.href", endsWith(EXAMPLE_TASK_ID)).when().get(SINGLE_TASK_URL);
    String content = response.asString();
    // validate embedded users:
    List<Map<String, Object>> embeddedUsers = from(content).getList("_embedded.user");
    Assert.assertEquals("There should be two users returned.", 2, embeddedUsers.size());
    Map<String, Object> embeddedUser = embeddedUsers.get(0);
    assertNotNull("The returned user should not be null.", embeddedUser);
    assertEquals(MockProvider.EXAMPLE_TASK_ASSIGNEE_NAME, embeddedUser.get("id"));
    assertEquals(MockProvider.EXAMPLE_USER_FIRST_NAME, embeddedUser.get("firstName"));
    assertEquals(MockProvider.EXAMPLE_USER_LAST_NAME, embeddedUser.get("lastName"));
    assertEquals(MockProvider.EXAMPLE_USER_EMAIL, embeddedUser.get("email"));
    assertNull(embeddedUser.get("_embedded"));
    Map<String, Object> links = (Map<String, Object>) embeddedUser.get("_links");
    assertEquals(1, links.size());
    assertHalLink(links, "self", UserRestService.PATH + "/" + MockProvider.EXAMPLE_TASK_ASSIGNEE_NAME);
    embeddedUser = embeddedUsers.get(1);
    assertNotNull("The returned user should not be null.", embeddedUser);
    assertEquals(MockProvider.EXAMPLE_TASK_OWNER, embeddedUser.get("id"));
    assertEquals(MockProvider.EXAMPLE_USER_FIRST_NAME, embeddedUser.get("firstName"));
    assertEquals(MockProvider.EXAMPLE_USER_LAST_NAME, embeddedUser.get("lastName"));
    assertEquals(MockProvider.EXAMPLE_USER_EMAIL, embeddedUser.get("email"));
    assertNull(embeddedUser.get("_embedded"));
    links = (Map<String, Object>) embeddedUser.get("_links");
    assertEquals(1, links.size());
    assertHalLink(links, "self", UserRestService.PATH + "/" + MockProvider.EXAMPLE_TASK_OWNER);
    // validate embedded groups:
    List<Map<String, Object>> embeddedGroups = from(content).getList("_embedded.group");
    Assert.assertEquals("There should be two groups returned.", 2, embeddedGroups.size());
    Map<String, Object> embeddedGroup = embeddedGroups.get(0);
    assertNotNull("The returned group should not be null.", embeddedGroup);
    assertEquals(MockProvider.EXAMPLE_GROUP_ID, embeddedGroup.get("id"));
    assertEquals(MockProvider.EXAMPLE_GROUP_NAME, embeddedGroup.get("name"));
    assertEquals(MockProvider.EXAMPLE_GROUP_TYPE, embeddedGroup.get("type"));
    assertNull(embeddedGroup.get("_embedded"));
    links = (Map<String, Object>) embeddedGroup.get("_links");
    assertEquals(1, links.size());
    assertHalLink(links, "self", GroupRestService.PATH + "/" + MockProvider.EXAMPLE_GROUP_ID);
    embeddedGroup = embeddedGroups.get(1);
    assertNotNull("The returned group should not be null.", embeddedGroup);
    assertEquals(MockProvider.EXAMPLE_GROUP_ID2, embeddedGroup.get("id"));
    assertEquals(MockProvider.EXAMPLE_GROUP_NAME, embeddedGroup.get("name"));
    assertEquals(MockProvider.EXAMPLE_GROUP_TYPE, embeddedGroup.get("type"));
    assertNull(embeddedGroup.get("_embedded"));
    links = (Map<String, Object>) embeddedGroup.get("_links");
    assertEquals(1, links.size());
    assertHalLink(links, "self", GroupRestService.PATH + "/" + MockProvider.EXAMPLE_GROUP_ID2);
    // validate embedded processDefinitions:
    List<Map<String, Object>> embeddedDefinitions = from(content).getList("_embedded.processDefinition");
    Assert.assertEquals("There should be one processDefinition returned.", 1, embeddedDefinitions.size());
    Map<String, Object> embeddedProcessDefinition = embeddedDefinitions.get(0);
    Assert.assertNotNull("The returned processDefinition should not be null.", embeddedProcessDefinition);
    Assert.assertEquals(MockProvider.EXAMPLE_PROCESS_DEFINITION_ID, embeddedProcessDefinition.get("id"));
    Assert.assertEquals(MockProvider.EXAMPLE_PROCESS_DEFINITION_KEY, embeddedProcessDefinition.get("key"));
    Assert.assertEquals(MockProvider.EXAMPLE_PROCESS_DEFINITION_CATEGORY, embeddedProcessDefinition.get("category"));
    Assert.assertEquals(MockProvider.EXAMPLE_PROCESS_DEFINITION_NAME, embeddedProcessDefinition.get("name"));
    Assert.assertEquals(MockProvider.EXAMPLE_PROCESS_DEFINITION_DESCRIPTION, embeddedProcessDefinition.get("description"));
    Assert.assertEquals(MockProvider.EXAMPLE_PROCESS_DEFINITION_VERSION, embeddedProcessDefinition.get("version"));
    Assert.assertEquals(MockProvider.EXAMPLE_PROCESS_DEFINITION_RESOURCE_NAME, embeddedProcessDefinition.get("resource"));
    Assert.assertEquals(MockProvider.EXAMPLE_DEPLOYMENT_ID, embeddedProcessDefinition.get("deploymentId"));
    Assert.assertEquals(MockProvider.EXAMPLE_PROCESS_DEFINITION_DIAGRAM_RESOURCE_NAME, embeddedProcessDefinition.get("diagram"));
    Assert.assertEquals(MockProvider.EXAMPLE_PROCESS_DEFINITION_IS_SUSPENDED, embeddedProcessDefinition.get("suspended"));
    Assert.assertEquals(MockProvider.EXAMPLE_PROCESS_APPLICATION_CONTEXT_PATH, embeddedProcessDefinition.get("contextPath"));
    links = (Map<String, Object>) embeddedProcessDefinition.get("_links");
    Assert.assertEquals(3, links.size());
    assertHalLink(links, "self", "/process-definition/" + MockProvider.EXAMPLE_PROCESS_DEFINITION_ID);
    assertHalLink(links, "deployment", "/deployment/" + MockProvider.EXAMPLE_DEPLOYMENT_ID);
    assertHalLink(links, "resource", "/deployment/" + MockProvider.EXAMPLE_DEPLOYMENT_ID + "/resources/" + MockProvider.EXAMPLE_PROCESS_DEFINITION_RESOURCE_NAME);
    // validate embedded caseDefinitions:
    List<Map<String, Object>> embeddedCaseDefinitions = from(content).getList("_embedded.caseDefinition");
    Assert.assertEquals("There should be one caseDefinition returned.", 1, embeddedCaseDefinitions.size());
    Map<String, Object> embeddedCaseDefinition = embeddedCaseDefinitions.get(0);
    Assert.assertNotNull("The returned caseDefinition should not be null.", embeddedCaseDefinition);
    Assert.assertEquals(MockProvider.EXAMPLE_CASE_DEFINITION_ID, embeddedCaseDefinition.get("id"));
    Assert.assertEquals(MockProvider.EXAMPLE_CASE_DEFINITION_KEY, embeddedCaseDefinition.get("key"));
    Assert.assertEquals(MockProvider.EXAMPLE_CASE_DEFINITION_CATEGORY, embeddedCaseDefinition.get("category"));
    Assert.assertEquals(MockProvider.EXAMPLE_CASE_DEFINITION_NAME, embeddedCaseDefinition.get("name"));
    Assert.assertEquals(MockProvider.EXAMPLE_CASE_DEFINITION_VERSION, embeddedCaseDefinition.get("version"));
    Assert.assertEquals(MockProvider.EXAMPLE_CASE_DEFINITION_RESOURCE_NAME, embeddedCaseDefinition.get("resource"));
    Assert.assertEquals(MockProvider.EXAMPLE_DEPLOYMENT_ID, embeddedCaseDefinition.get("deploymentId"));
    Assert.assertEquals(MockProvider.EXAMPLE_PROCESS_APPLICATION_CONTEXT_PATH, embeddedCaseDefinition.get("contextPath"));
    links = (Map<String, Object>) embeddedCaseDefinition.get("_links");
    Assert.assertEquals(3, links.size());
    assertHalLink(links, "self", "/case-definition/" + MockProvider.EXAMPLE_CASE_DEFINITION_ID);
    assertHalLink(links, "deployment", "/deployment/" + MockProvider.EXAMPLE_DEPLOYMENT_ID);
    assertHalLink(links, "resource", "/deployment/" + MockProvider.EXAMPLE_DEPLOYMENT_ID + "/resources/" + MockProvider.EXAMPLE_CASE_DEFINITION_RESOURCE_NAME);
    // validate embedded identity links
    List<Map<String, Object>> embeddedIdentityLinks = from(content).getList("_embedded.identityLink");
    assertEquals("There should be three identityLink returned", 4, embeddedIdentityLinks.size());
    assertEmbeddedIdentityLink(mockAssigneeIdentityLink, embeddedIdentityLinks.get(0));
    assertEmbeddedIdentityLink(mockOwnerIdentityLink, embeddedIdentityLinks.get(1));
    assertEmbeddedIdentityLink(mockCandidateGroupIdentityLink, embeddedIdentityLinks.get(2));
    assertEmbeddedIdentityLink(mockCandidateGroup2IdentityLink, embeddedIdentityLinks.get(3));
}
Also used : Group(org.camunda.bpm.engine.identity.Group) User(org.camunda.bpm.engine.identity.User) ProcessDefinition(org.camunda.bpm.engine.repository.ProcessDefinition) ProcessDefinitionQuery(org.camunda.bpm.engine.repository.ProcessDefinitionQuery) Matchers.containsString(org.hamcrest.Matchers.containsString) Matchers.anyString(org.mockito.Matchers.anyString) CaseDefinitionQuery(org.camunda.bpm.engine.repository.CaseDefinitionQuery) Response(com.jayway.restassured.response.Response) UserQuery(org.camunda.bpm.engine.identity.UserQuery) GroupQuery(org.camunda.bpm.engine.identity.GroupQuery) CaseDefinition(org.camunda.bpm.engine.repository.CaseDefinition) Map(java.util.Map) LinkedHashMap(java.util.LinkedHashMap) EqualsMap(org.camunda.bpm.engine.rest.helper.EqualsMap) VariableMap(org.camunda.bpm.engine.variable.VariableMap) HashMap(java.util.HashMap) Test(org.junit.Test)

Example 3 with ProcessDefinition

use of org.camunda.bpm.engine.repository.ProcessDefinition in project camunda-bpm-platform by camunda.

the class ProcessDefinitionRestServiceInteractionTest method testGetStartForm_StartFormDataEqualsNull.

@Test
public void testGetStartForm_StartFormDataEqualsNull() {
    ProcessDefinition mockDefinition = MockProvider.createMockDefinition();
    when(formServiceMock.getStartFormData(mockDefinition.getId())).thenReturn(null);
    given().pathParam("id", MockProvider.EXAMPLE_PROCESS_DEFINITION_ID).then().expect().statusCode(Status.OK.getStatusCode()).body("contextPath", equalTo(MockProvider.EXAMPLE_PROCESS_APPLICATION_CONTEXT_PATH)).when().get(START_FORM_URL);
}
Also used : ProcessDefinition(org.camunda.bpm.engine.repository.ProcessDefinition) Test(org.junit.Test)

Example 4 with ProcessDefinition

use of org.camunda.bpm.engine.repository.ProcessDefinition in project camunda-bpm-platform by camunda.

the class ProcessDefinitionRestServiceInteractionTest method testDefinitionRetrieval_ByKeyAndTenantId.

@Test
public void testDefinitionRetrieval_ByKeyAndTenantId() {
    ProcessDefinition mockDefinition = MockProvider.mockDefinition().tenantId(MockProvider.EXAMPLE_TENANT_ID).build();
    setUpRuntimeDataForDefinition(mockDefinition);
    given().pathParam("key", MockProvider.EXAMPLE_PROCESS_DEFINITION_KEY).pathParam("tenant-id", MockProvider.EXAMPLE_TENANT_ID).then().expect().statusCode(Status.OK.getStatusCode()).body("id", equalTo(MockProvider.EXAMPLE_PROCESS_DEFINITION_ID)).body("key", equalTo(MockProvider.EXAMPLE_PROCESS_DEFINITION_KEY)).body("category", equalTo(MockProvider.EXAMPLE_PROCESS_DEFINITION_CATEGORY)).body("name", equalTo(MockProvider.EXAMPLE_PROCESS_DEFINITION_NAME)).body("description", equalTo(MockProvider.EXAMPLE_PROCESS_DEFINITION_DESCRIPTION)).body("deploymentId", equalTo(MockProvider.EXAMPLE_DEPLOYMENT_ID)).body("version", equalTo(MockProvider.EXAMPLE_PROCESS_DEFINITION_VERSION)).body("resource", equalTo(MockProvider.EXAMPLE_PROCESS_DEFINITION_RESOURCE_NAME)).body("diagram", equalTo(MockProvider.EXAMPLE_PROCESS_DEFINITION_DIAGRAM_RESOURCE_NAME)).body("suspended", equalTo(MockProvider.EXAMPLE_PROCESS_DEFINITION_IS_SUSPENDED)).body("tenantId", equalTo(MockProvider.EXAMPLE_TENANT_ID)).when().get(SINGLE_PROCESS_DEFINITION_BY_KEY_AND_TENANT_ID_URL);
    verify(processDefinitionQueryMock).tenantIdIn(MockProvider.EXAMPLE_TENANT_ID);
    verify(repositoryServiceMock).getProcessDefinition(MockProvider.EXAMPLE_PROCESS_DEFINITION_ID);
}
Also used : ProcessDefinition(org.camunda.bpm.engine.repository.ProcessDefinition) Test(org.junit.Test)

Example 5 with ProcessDefinition

use of org.camunda.bpm.engine.repository.ProcessDefinition in project camunda-bpm-platform by camunda.

the class ProcessDefinitionRestServiceInteractionTest method testGetStartForm_shouldReturnKeyContainingTaskId.

@Test
public void testGetStartForm_shouldReturnKeyContainingTaskId() {
    ProcessDefinition mockDefinition = MockProvider.createMockDefinition();
    StartFormData mockStartFormData = MockProvider.createMockStartFormDataUsingFormFieldsWithoutFormKey(mockDefinition);
    when(formServiceMock.getStartFormData(mockDefinition.getId())).thenReturn(mockStartFormData);
    given().pathParam("id", MockProvider.EXAMPLE_PROCESS_DEFINITION_ID).then().expect().statusCode(Status.OK.getStatusCode()).body("key", equalTo("embedded:engine://engine/:engine/process-definition/" + mockDefinition.getId() + "/rendered-form")).body("contextPath", equalTo(MockProvider.EXAMPLE_PROCESS_APPLICATION_CONTEXT_PATH)).when().get(START_FORM_URL);
}
Also used : StartFormData(org.camunda.bpm.engine.form.StartFormData) ProcessDefinition(org.camunda.bpm.engine.repository.ProcessDefinition) Test(org.junit.Test)

Aggregations

ProcessDefinition (org.camunda.bpm.engine.repository.ProcessDefinition)1093 Test (org.junit.Test)761 MigrationPlan (org.camunda.bpm.engine.migration.MigrationPlan)474 ProcessInstance (org.camunda.bpm.engine.runtime.ProcessInstance)415 Deployment (org.camunda.bpm.engine.test.Deployment)230 Job (org.camunda.bpm.engine.runtime.Job)148 BpmnModelInstance (org.camunda.bpm.model.bpmn.BpmnModelInstance)119 Batch (org.camunda.bpm.engine.batch.Batch)95 Task (org.camunda.bpm.engine.task.Task)87 HashMap (java.util.HashMap)77 JobDefinition (org.camunda.bpm.engine.management.JobDefinition)64 JobQuery (org.camunda.bpm.engine.runtime.JobQuery)55 JobDefinitionQuery (org.camunda.bpm.engine.management.JobDefinitionQuery)54 ActivityInstance (org.camunda.bpm.engine.runtime.ActivityInstance)47 VariableInstance (org.camunda.bpm.engine.runtime.VariableInstance)42 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)41 MigrationPlanValidationException (org.camunda.bpm.engine.migration.MigrationPlanValidationException)40 ProcessEngineException (org.camunda.bpm.engine.ProcessEngineException)39 Date (java.util.Date)38 HistoricProcessInstance (org.camunda.bpm.engine.history.HistoricProcessInstance)35