Search in sources :

Example 16 with NullValueException

use of org.camunda.bpm.engine.exception.NullValueException in project camunda-bpm-platform by camunda.

the class HistoricCaseInstanceTest method testDeleteHistoricCaseInstance.

@Deployment(resources = { "org/camunda/bpm/engine/test/api/cmmn/emptyStageWithManualActivationCase.cmmn" })
public void testDeleteHistoricCaseInstance() {
    CaseInstance caseInstance = createCaseInstance();
    HistoricCaseInstance historicInstance = queryHistoricCaseInstance(caseInstance.getId());
    assertNotNull(historicInstance);
    try {
        // should not be able to delete historic case instance cause the case instance is still running
        historyService.deleteHistoricCaseInstance(historicInstance.getId());
        fail("Exception expected");
    } catch (NullValueException e) {
    // expected
    }
    terminate(caseInstance.getId());
    close(caseInstance.getId());
    historyService.deleteHistoricCaseInstance(historicInstance.getId());
    assertCount(0, historicQuery());
}
Also used : CaseInstance(org.camunda.bpm.engine.runtime.CaseInstance) HistoricCaseInstance(org.camunda.bpm.engine.history.HistoricCaseInstance) HistoricCaseInstance(org.camunda.bpm.engine.history.HistoricCaseInstance) NullValueException(org.camunda.bpm.engine.exception.NullValueException) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 17 with NullValueException

use of org.camunda.bpm.engine.exception.NullValueException in project camunda-bpm-platform by camunda.

the class MessageRestServiceTest method testMessageCorrelationWithoutBusinessKey.

@Test
public void testMessageCorrelationWithoutBusinessKey() {
    when(messageCorrelationBuilderMock.processInstanceBusinessKey(null)).thenThrow(new NullValueException());
    String messageName = "aMessageName";
    Map<String, Object> messageParameters = new HashMap<String, Object>();
    messageParameters.put("messageName", messageName);
    given().contentType(POST_JSON_CONTENT_TYPE).body(messageParameters).then().expect().statusCode(Status.NO_CONTENT.getStatusCode()).when().post(MESSAGE_URL);
    verify(runtimeServiceMock).createMessageCorrelation(eq(messageName));
    verify(messageCorrelationBuilderMock, Mockito.never()).processInstanceBusinessKey(anyString());
    verify(messageCorrelationBuilderMock).correlateWithResult();
    verifyNoMoreInteractions(messageCorrelationBuilderMock);
}
Also used : HashMap(java.util.HashMap) Matchers.anyString(org.mockito.Matchers.anyString) Matchers.containsString(org.hamcrest.Matchers.containsString) NullValueException(org.camunda.bpm.engine.exception.NullValueException) Test(org.junit.Test)

Example 18 with NullValueException

use of org.camunda.bpm.engine.exception.NullValueException in project camunda-bpm-platform by camunda.

the class FilterRestServiceInteractionTest method setUpRuntimeData.

@Before
@SuppressWarnings("unchecked")
public void setUpRuntimeData() {
    filterServiceMock = mock(FilterService.class);
    when(processEngine.getFilterService()).thenReturn(filterServiceMock);
    FilterQuery filterQuery = MockProvider.createMockFilterQuery();
    when(filterServiceMock.createFilterQuery()).thenReturn(filterQuery);
    filterMock = MockProvider.createMockFilter();
    when(filterServiceMock.newTaskFilter()).thenReturn(filterMock);
    when(filterServiceMock.saveFilter(eq(filterMock))).thenReturn(filterMock);
    when(filterServiceMock.getFilter(eq(EXAMPLE_FILTER_ID))).thenReturn(filterMock);
    when(filterServiceMock.getFilter(eq(MockProvider.NON_EXISTING_ID))).thenReturn(null);
    List<Object> mockTasks = Collections.<Object>singletonList(new TaskEntity());
    when(filterServiceMock.singleResult(eq(EXAMPLE_FILTER_ID))).thenReturn(mockTasks.get(0));
    when(filterServiceMock.singleResult(eq(EXAMPLE_FILTER_ID), any(Query.class))).thenReturn(mockTasks.get(0));
    when(filterServiceMock.list(eq(EXAMPLE_FILTER_ID))).thenReturn(mockTasks);
    when(filterServiceMock.list(eq(EXAMPLE_FILTER_ID), any(Query.class))).thenReturn(mockTasks);
    when(filterServiceMock.listPage(eq(EXAMPLE_FILTER_ID), anyInt(), anyInt())).thenReturn(mockTasks);
    when(filterServiceMock.listPage(eq(EXAMPLE_FILTER_ID), any(Query.class), anyInt(), anyInt())).thenReturn(mockTasks);
    when(filterServiceMock.count(eq(EXAMPLE_FILTER_ID))).thenReturn((long) 1);
    when(filterServiceMock.count(eq(EXAMPLE_FILTER_ID), any(Query.class))).thenReturn((long) 1);
    doThrow(new NullValueException("No filter found with given id")).when(filterServiceMock).singleResult(eq(MockProvider.NON_EXISTING_ID));
    doThrow(new NullValueException("No filter found with given id")).when(filterServiceMock).singleResult(eq(MockProvider.NON_EXISTING_ID), any(Query.class));
    doThrow(new NullValueException("No filter found with given id")).when(filterServiceMock).list(eq(MockProvider.NON_EXISTING_ID));
    doThrow(new NullValueException("No filter found with given id")).when(filterServiceMock).list(eq(MockProvider.NON_EXISTING_ID), any(Query.class));
    doThrow(new NullValueException("No filter found with given id")).when(filterServiceMock).listPage(eq(MockProvider.NON_EXISTING_ID), anyInt(), anyInt());
    doThrow(new NullValueException("No filter found with given id")).when(filterServiceMock).listPage(eq(MockProvider.NON_EXISTING_ID), any(Query.class), anyInt(), anyInt());
    doThrow(new NullValueException("No filter found with given id")).when(filterServiceMock).count(eq(MockProvider.NON_EXISTING_ID));
    doThrow(new NullValueException("No filter found with given id")).when(filterServiceMock).count(eq(MockProvider.NON_EXISTING_ID), any(Query.class));
    doThrow(new NullValueException("No filter found with given id")).when(filterServiceMock).deleteFilter(eq(MockProvider.NON_EXISTING_ID));
    authorizationServiceMock = mock(AuthorizationServiceImpl.class);
    identityServiceMock = mock(IdentityServiceImpl.class);
    processEngineConfigurationMock = mock(ProcessEngineConfiguration.class);
    when(processEngine.getAuthorizationService()).thenReturn(authorizationServiceMock);
    when(processEngine.getIdentityService()).thenReturn(identityServiceMock);
    when(processEngine.getProcessEngineConfiguration()).thenReturn(processEngineConfigurationMock);
    TaskService taskService = processEngine.getTaskService();
    when(taskService.createTaskQuery()).thenReturn(new TaskQueryImpl());
    variableInstanceQueryMock = mock(VariableInstanceQuery.class);
    when(processEngine.getRuntimeService().createVariableInstanceQuery()).thenReturn(variableInstanceQueryMock);
    when(variableInstanceQueryMock.variableScopeIdIn((String) anyVararg())).thenReturn(variableInstanceQueryMock);
    when(variableInstanceQueryMock.variableNameIn((String) anyVararg())).thenReturn(variableInstanceQueryMock);
    when(variableInstanceQueryMock.disableBinaryFetching()).thenReturn(variableInstanceQueryMock);
    when(variableInstanceQueryMock.disableCustomObjectDeserialization()).thenReturn(variableInstanceQueryMock);
}
Also used : TaskEntity(org.camunda.bpm.engine.impl.persistence.entity.TaskEntity) FilterQuery(org.camunda.bpm.engine.filter.FilterQuery) Query(org.camunda.bpm.engine.query.Query) VariableInstanceQuery(org.camunda.bpm.engine.runtime.VariableInstanceQuery) TaskQuery(org.camunda.bpm.engine.task.TaskQuery) IdentityServiceImpl(org.camunda.bpm.engine.impl.IdentityServiceImpl) TaskService(org.camunda.bpm.engine.TaskService) FilterService(org.camunda.bpm.engine.FilterService) FilterQuery(org.camunda.bpm.engine.filter.FilterQuery) NullValueException(org.camunda.bpm.engine.exception.NullValueException) ProcessEngineConfiguration(org.camunda.bpm.engine.ProcessEngineConfiguration) TaskQueryImpl(org.camunda.bpm.engine.impl.TaskQueryImpl) VariableInstanceQuery(org.camunda.bpm.engine.runtime.VariableInstanceQuery) AuthorizationServiceImpl(org.camunda.bpm.engine.impl.AuthorizationServiceImpl) Before(org.junit.Before)

Aggregations

NullValueException (org.camunda.bpm.engine.exception.NullValueException)18 Test (org.junit.Test)7 InvalidRequestException (org.camunda.bpm.engine.rest.exception.InvalidRequestException)3 ProcessInstanceQuery (org.camunda.bpm.engine.runtime.ProcessInstanceQuery)3 Deployment (org.camunda.bpm.engine.test.Deployment)3 Date (java.util.Date)2 BadUserRequestException (org.camunda.bpm.engine.BadUserRequestException)2 Batch (org.camunda.bpm.engine.batch.Batch)2 HistoricActivityInstance (org.camunda.bpm.engine.history.HistoricActivityInstance)2 CompositeDbHistoryEventHandler (org.camunda.bpm.engine.impl.history.handler.CompositeDbHistoryEventHandler)2 CompositeHistoryEventHandler (org.camunda.bpm.engine.impl.history.handler.CompositeHistoryEventHandler)2 HistoryEventHandler (org.camunda.bpm.engine.impl.history.handler.HistoryEventHandler)2 ActivityInstance (org.camunda.bpm.engine.runtime.ActivityInstance)2 ProcessInstance (org.camunda.bpm.engine.runtime.ProcessInstance)2 Matchers.anyString (org.mockito.Matchers.anyString)2 HashMap (java.util.HashMap)1 FilterService (org.camunda.bpm.engine.FilterService)1 ProcessEngineConfiguration (org.camunda.bpm.engine.ProcessEngineConfiguration)1 TaskService (org.camunda.bpm.engine.TaskService)1 NotValidException (org.camunda.bpm.engine.exception.NotValidException)1