### Question:
CaseEngineClient { public ProcessInstance start(final long userId, final long processId) { return start(userId, processId, null); } CaseEngineClient(final ProcessAPI processAPI); ProcessInstance start(final long userId, final long processId); ProcessInstance start(final long userId, final long processId, final Map<String, Serializable> variables); long countOpenedCases(); List<ArchivedProcessInstance> searchArchivedCasesInAllStates(final SearchOptions searchOptions); ProcessInstance getProcessInstance(final long processInstanceId); ArchivedProcessInstance getArchivedProcessInstance(final long processInstanceId);  }### Answer:
@Test public void a_process_can_be_started_without_variables() throws Exception { final long expectedProcessId = 1L; final long userId = 1L; caseEngineClient.start(userId, expectedProcessId); verify(processAPI).startProcess(userId, expectedProcessId); }
@Test public void a_process_can_be_started_with_variables() throws Exception { final long expectedProcessId = 1L; final long userId = 1L; final Map<String, Serializable> variables = someVariables(); caseEngineClient.start(userId, expectedProcessId, variables); verify(processAPI).startProcess(userId, expectedProcessId, variables); }
@Test(expected = APIException.class) public void cant_create_case_if_process_definition_is_not_found() throws Exception { when(processAPI.startProcess(anyLong())).thenThrow(new ProcessDefinitionNotFoundException("")); caseEngineClient.start(-1L, 1L); }
@Test(expected = APIException.class) public void cant_create_case_if_process_is_not_activated() throws Exception { when(processAPI.startProcess(anyLong())).thenThrow(new ProcessActivationException("")); caseEngineClient.start(-1L, 1L); }
@Test(expected = APIException.class) public void we_get_an_exception_if_process_fail_to_start() throws Exception { when(processAPI.startProcess(anyLong())).thenThrow(new ProcessExecutionException("")); caseEngineClient.start(-1L, 1L); }
@SuppressWarnings("unchecked") @Test(expected = APIException.class) public void cant_create_case_with_variables_if_process_definition_is_not_found() throws Exception { when(processAPI.startProcess(anyLong(), anyMap())).thenThrow(new ProcessDefinitionNotFoundException("")); caseEngineClient.start(-1L, 1L, someVariables()); }
@SuppressWarnings("unchecked") @Test(expected = APIException.class) public void cant_create_case_with_variables_if_process_is_not_activated() throws Exception { when(processAPI.startProcess(anyLong(), anyMap())).thenThrow(new ProcessActivationException("")); caseEngineClient.start(-1L, 1L, someVariables()); }
@SuppressWarnings("unchecked") @Test(expected = APIException.class) public void we_get_an_exception_if_process_fail_to_start_with_variables() throws Exception { when(processAPI.startProcess(anyLong(), anyMap())).thenThrow(new ProcessExecutionException("")); caseEngineClient.start(-1L, 1L, someVariables()); }