public void activateJobDefinitionByProcessDefinitionKey(String processDefinitionKey) { updateJobDefinitionSuspensionState() .byProcessDefinitionKey(processDefinitionKey) .activate(); }
public void activateJobDefinitionByProcessDefinitionKey(String processDefinitionKey) { updateJobDefinitionSuspensionState() .byProcessDefinitionKey(processDefinitionKey) .activate(); }
@Test public void testActivateJobDefinitionByProcessDefinitionKey() { Map<String, Object> params = new HashMap<String, Object>(); params.put("suspended", false); params.put("processDefinitionKey", MockProvider.EXAMPLE_PROCESS_DEFINITION_KEY); given() .contentType(ContentType.JSON) .body(params) .then() .expect() .statusCode(Status.NO_CONTENT.getStatusCode()) .when() .put(JOB_DEFINITION_SUSPENDED_URL); verify(mockSuspensionStateSelectBuilder).byProcessDefinitionKey(MockProvider.EXAMPLE_PROCESS_DEFINITION_KEY); verify(mockSuspensionStateBuilder).activate(); }
@Test public void testActivateJobDefinitionByProcessDefinitionKeyWithoutTenantId() { Map<String, Object> params = new HashMap<String, Object>(); params.put("suspended", false); params.put("processDefinitionKey", MockProvider.EXAMPLE_PROCESS_DEFINITION_KEY); params.put("processDefinitionWithoutTenantId", true); given() .contentType(ContentType.JSON) .body(params) .then() .expect() .statusCode(Status.NO_CONTENT.getStatusCode()) .when() .put(JOB_DEFINITION_SUSPENDED_URL); verify(mockSuspensionStateSelectBuilder).byProcessDefinitionKey(MockProvider.EXAMPLE_PROCESS_DEFINITION_KEY); verify(mockSuspensionStateBuilder).processDefinitionWithoutTenantId(); verify(mockSuspensionStateBuilder).activate(); }
@Test public void testActivateJobDefinitionByProcessDefinitionKeyIncludingInstaces() { Map<String, Object> params = new HashMap<String, Object>(); params.put("suspended", false); params.put("includeJobs", true); params.put("processDefinitionKey", MockProvider.EXAMPLE_PROCESS_DEFINITION_KEY); given() .contentType(ContentType.JSON) .body(params) .then() .expect() .statusCode(Status.NO_CONTENT.getStatusCode()) .when() .put(JOB_DEFINITION_SUSPENDED_URL); verify(mockSuspensionStateSelectBuilder).byProcessDefinitionKey(MockProvider.EXAMPLE_PROCESS_DEFINITION_KEY); verify(mockSuspensionStateBuilder).includeJobs(true); verify(mockSuspensionStateBuilder).activate(); }
@Test public void testActivateJobDefinitionByProcessDefinitionKeyAndTenantId() { Map<String, Object> params = new HashMap<String, Object>(); params.put("suspended", false); params.put("processDefinitionKey", MockProvider.EXAMPLE_PROCESS_DEFINITION_KEY); params.put("processDefinitionTenantId", MockProvider.EXAMPLE_TENANT_ID); given() .contentType(ContentType.JSON) .body(params) .then() .expect() .statusCode(Status.NO_CONTENT.getStatusCode()) .when() .put(JOB_DEFINITION_SUSPENDED_URL); verify(mockSuspensionStateSelectBuilder).byProcessDefinitionKey(MockProvider.EXAMPLE_PROCESS_DEFINITION_KEY); verify(mockSuspensionStateBuilder).processDefinitionTenantId(MockProvider.EXAMPLE_TENANT_ID); verify(mockSuspensionStateBuilder).activate(); }
@Test public void testActivateJobDefinitionByProcessDefinitionIdIncludingInstaces() { Map<String, Object> params = new HashMap<String, Object>(); params.put("suspended", false); params.put("includeJobs", true); params.put("processDefinitionId", MockProvider.EXAMPLE_PROCESS_DEFINITION_ID); given() .contentType(ContentType.JSON) .body(params) .then() .expect() .statusCode(Status.NO_CONTENT.getStatusCode()) .when() .put(JOB_DEFINITION_SUSPENDED_URL); verify(mockSuspensionStateSelectBuilder).byProcessDefinitionId(MockProvider.EXAMPLE_PROCESS_DEFINITION_ID); verify(mockSuspensionStateBuilder).includeJobs(true); verify(mockSuspensionStateBuilder).activate(); }
@Test public void testActivateJobDefinitionByProcessDefinitionId() { Map<String, Object> params = new HashMap<String, Object>(); params.put("suspended", false); params.put("processDefinitionId", MockProvider.EXAMPLE_PROCESS_DEFINITION_ID); given() .contentType(ContentType.JSON) .body(params) .then() .expect() .statusCode(Status.NO_CONTENT.getStatusCode()) .when() .put(JOB_DEFINITION_SUSPENDED_URL); verify(mockSuspensionStateSelectBuilder).byProcessDefinitionId(MockProvider.EXAMPLE_PROCESS_DEFINITION_ID); verify(mockSuspensionStateBuilder).activate(); }
@Test public void testActivateJobDefinitionByProcessDefinitionKeyWithException() { Map<String, Object> params = new HashMap<String, Object>(); params.put("suspended", false); params.put("processDefinitionKey", MockProvider.EXAMPLE_PROCESS_DEFINITION_KEY); String expectedException = "expectedException"; doThrow(new ProcessEngineException(expectedException)) .when(mockSuspensionStateBuilder) .activate(); given() .contentType(ContentType.JSON) .body(params) .then() .expect() .statusCode(Status.INTERNAL_SERVER_ERROR.getStatusCode()) .body("type", is(ProcessEngineException.class.getSimpleName())) .body("message", is(expectedException)) .when() .put(JOB_DEFINITION_SUSPENDED_URL); }
@Test public void testDelayedActivateJobDefinitionByProcessDefinitionKey() { Map<String, Object> params = new HashMap<String, Object>(); params.put("suspended", false); params.put("processDefinitionKey", MockProvider.EXAMPLE_PROCESS_DEFINITION_KEY); params.put("executionDate", MockProvider.EXAMPLE_PROCESS_DEFINITION_DELAYED_EXECUTION); Date executionDate = DateTimeUtil.parseDate(MockProvider.EXAMPLE_PROCESS_DEFINITION_DELAYED_EXECUTION); given() .contentType(ContentType.JSON) .body(params) .then() .expect() .statusCode(Status.NO_CONTENT.getStatusCode()) .when() .put(JOB_DEFINITION_SUSPENDED_URL); verify(mockSuspensionStateSelectBuilder).byProcessDefinitionKey(MockProvider.EXAMPLE_PROCESS_DEFINITION_KEY); verify(mockSuspensionStateBuilder).executionDate(executionDate); verify(mockSuspensionStateBuilder).activate(); }
@Test public void testActivateJobDefinitionByProcessDefinitionKeyWithAuthorizationException() { Map<String, Object> params = new HashMap<String, Object>(); params.put("suspended", false); params.put("processDefinitionKey", MockProvider.EXAMPLE_PROCESS_DEFINITION_KEY); String expectedException = "expectedException"; doThrow(new AuthorizationException(expectedException)) .when(mockSuspensionStateBuilder) .activate(); given() .contentType(ContentType.JSON) .body(params) .then() .expect() .statusCode(Status.FORBIDDEN.getStatusCode()) .body("type", is(AuthorizationException.class.getSimpleName())) .body("message", is(expectedException)) .when() .put(JOB_DEFINITION_SUSPENDED_URL); }
@Test public void testActivateJobDefinitionByProcessDefinitionIdWithException() { Map<String, Object> params = new HashMap<String, Object>(); params.put("suspended", false); params.put("processDefinitionId", MockProvider.EXAMPLE_PROCESS_DEFINITION_ID); String expectedException = "expectedException"; doThrow(new ProcessEngineException(expectedException)) .when(mockSuspensionStateBuilder) .activate(); given() .contentType(ContentType.JSON) .body(params) .then() .expect() .statusCode(Status.INTERNAL_SERVER_ERROR.getStatusCode()) .body("type", is(ProcessEngineException.class.getSimpleName())) .body("message", is(expectedException)) .when() .put(JOB_DEFINITION_SUSPENDED_URL); }
@Test public void testActivateJobDefinitionByProcessDefinitionIdWithAuthorizationException() { Map<String, Object> params = new HashMap<String, Object>(); params.put("suspended", false); params.put("processDefinitionId", MockProvider.EXAMPLE_PROCESS_DEFINITION_ID); String expectedException = "expectedException"; doThrow(new AuthorizationException(expectedException)) .when(mockSuspensionStateBuilder) .activate(); given() .contentType(ContentType.JSON) .body(params) .then() .expect() .statusCode(Status.FORBIDDEN.getStatusCode()) .body("type", is(AuthorizationException.class.getSimpleName())) .body("message", is(expectedException)) .when() .put(JOB_DEFINITION_SUSPENDED_URL); }
@Test public void testDelayedActivateJobDefinitionByProcessDefinitionKeyIncludingInstaces() { Map<String, Object> params = new HashMap<String, Object>(); params.put("suspended", false); params.put("includeJobs", true); params.put("processDefinitionKey", MockProvider.EXAMPLE_PROCESS_DEFINITION_KEY); params.put("executionDate", MockProvider.EXAMPLE_PROCESS_DEFINITION_DELAYED_EXECUTION); Date executionDate = DateTimeUtil.parseDate(MockProvider.EXAMPLE_PROCESS_DEFINITION_DELAYED_EXECUTION); given() .contentType(ContentType.JSON) .body(params) .then() .expect() .statusCode(Status.NO_CONTENT.getStatusCode()) .when() .put(JOB_DEFINITION_SUSPENDED_URL); verify(mockSuspensionStateSelectBuilder).byProcessDefinitionKey(MockProvider.EXAMPLE_PROCESS_DEFINITION_KEY); verify(mockSuspensionStateBuilder).executionDate(executionDate); verify(mockSuspensionStateBuilder).includeJobs(true); verify(mockSuspensionStateBuilder).activate(); }
@Test public void testDelayedActivateJobDefinitionByProcessDefinitionIdIncludingInstaces() { Map<String, Object> params = new HashMap<String, Object>(); params.put("suspended", false); params.put("includeJobs", true); params.put("processDefinitionId", MockProvider.EXAMPLE_PROCESS_DEFINITION_ID); params.put("executionDate", MockProvider.EXAMPLE_PROCESS_DEFINITION_DELAYED_EXECUTION); Date executionDate = DateTimeUtil.parseDate(MockProvider.EXAMPLE_PROCESS_DEFINITION_DELAYED_EXECUTION); given() .contentType(ContentType.JSON) .body(params) .then() .expect() .statusCode(Status.NO_CONTENT.getStatusCode()) .when() .put(JOB_DEFINITION_SUSPENDED_URL); verify(mockSuspensionStateSelectBuilder).byProcessDefinitionId(MockProvider.EXAMPLE_PROCESS_DEFINITION_ID); verify(mockSuspensionStateBuilder).executionDate(executionDate); verify(mockSuspensionStateBuilder).includeJobs(true); verify(mockSuspensionStateBuilder).activate(); }
@Test public void testDelayedActivateJobDefinitionByProcessDefinitionId() { Map<String, Object> params = new HashMap<String, Object>(); params.put("suspended", false); params.put("processDefinitionId", MockProvider.EXAMPLE_PROCESS_DEFINITION_ID); params.put("executionDate", MockProvider.EXAMPLE_PROCESS_DEFINITION_DELAYED_EXECUTION); Date executionDate = DateTimeUtil.parseDate(MockProvider.EXAMPLE_PROCESS_DEFINITION_DELAYED_EXECUTION); given() .contentType(ContentType.JSON) .body(params) .then() .expect() .statusCode(Status.NO_CONTENT.getStatusCode()) .when() .put(JOB_DEFINITION_SUSPENDED_URL); verify(mockSuspensionStateSelectBuilder).byProcessDefinitionId(MockProvider.EXAMPLE_PROCESS_DEFINITION_ID); verify(mockSuspensionStateBuilder).executionDate(executionDate); verify(mockSuspensionStateBuilder).activate(); }
@Test public void testActivateThrowProcessEngineException() { Map<String, Object> params = new HashMap<String, Object>(); params.put("suspended", false); params.put("includeJobs", false); String expectedMessage = "expectedMessage"; doThrow(new ProcessEngineException(expectedMessage)) .when(mockSuspensionStateBuilder) .activate(); given() .pathParam("id", MockProvider.NON_EXISTING_JOB_DEFINITION_ID) .contentType(ContentType.JSON) .body(params) .then() .expect() .statusCode(Status.INTERNAL_SERVER_ERROR.getStatusCode()) .body("type", is(ProcessEngineException.class.getSimpleName())) .body("message", is(expectedMessage)) .when() .put(SINGLE_JOB_DEFINITION_SUSPENDED_URL); }
@Test public void testActivateJobDefinitionExcludingInstances() { Map<String, Object> params = new HashMap<String, Object>(); params.put("suspended", false); params.put("includeJobs", false); given() .pathParam("id", MockProvider.EXAMPLE_JOB_DEFINITION_ID) .contentType(ContentType.JSON) .body(params) .then() .expect() .statusCode(Status.NO_CONTENT.getStatusCode()) .when() .put(SINGLE_JOB_DEFINITION_SUSPENDED_URL); verify(mockSuspensionStateSelectBuilder).byJobDefinitionId(MockProvider.EXAMPLE_JOB_DEFINITION_ID); verify(mockSuspensionStateBuilder).activate(); }
@Test public void testDelayedActivateJobDefinitionExcludingInstances() { Map<String, Object> params = new HashMap<String, Object>(); params.put("suspended", false); params.put("includeJobs", false); params.put("executionDate", MockProvider.EXAMPLE_JOB_DEFINITION_DELAYED_EXECUTION); Date executionDate = DateTimeUtil.parseDate(MockProvider.EXAMPLE_JOB_DEFINITION_DELAYED_EXECUTION); given() .pathParam("id", MockProvider.EXAMPLE_JOB_DEFINITION_ID) .contentType(ContentType.JSON) .body(params) .then() .expect() .statusCode(Status.NO_CONTENT.getStatusCode()) .when() .put(SINGLE_JOB_DEFINITION_SUSPENDED_URL); verify(mockSuspensionStateSelectBuilder).byJobDefinitionId(MockProvider.EXAMPLE_JOB_DEFINITION_ID); verify(mockSuspensionStateBuilder).executionDate(executionDate); verify(mockSuspensionStateBuilder).includeJobs(false); verify(mockSuspensionStateBuilder).activate(); }
@Test public void testActivateJobDefinitionIncludingInstances() { Map<String, Object> params = new HashMap<String, Object>(); params.put("suspended", false); params.put("includeJobs", true); given() .pathParam("id", MockProvider.EXAMPLE_JOB_DEFINITION_ID) .contentType(ContentType.JSON) .body(params) .then() .expect() .statusCode(Status.NO_CONTENT.getStatusCode()) .when() .put(SINGLE_JOB_DEFINITION_SUSPENDED_URL); verify(mockSuspensionStateSelectBuilder).byJobDefinitionId(MockProvider.EXAMPLE_JOB_DEFINITION_ID); verify(mockSuspensionStateBuilder).includeJobs(true); verify(mockSuspensionStateBuilder).activate(); }