Skip to content

Commit

Permalink
chore(engine-rest): Expose "cascade" flag to /job/{id}/duedate REST e…
Browse files Browse the repository at this point in the history
…ndpoint

Merges camunda#466 
Related to CAM-9855
  • Loading branch information
mboskamp authored Sep 24, 2019
1 parent 2e8126f commit b25b8ba
Show file tree
Hide file tree
Showing 11 changed files with 51 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
public class JobDuedateDto {

private Date duedate;
private boolean cascade;

public Date getDuedate() {
return duedate;
Expand All @@ -29,4 +30,12 @@ public Date getDuedate() {
public void setDuedate(Date duedate) {
this.duedate = duedate;
}

public boolean isCascade() {
return cascade;
}

public void setCascade(boolean cascade) {
this.cascade = cascade;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public void executeJob() {
public void setJobDuedate(JobDuedateDto dto) {
try {
ManagementService managementService = engine.getManagementService();
managementService.setJobDuedate(jobId, dto.getDuedate());
managementService.setJobDuedate(jobId, dto.getDuedate(), dto.isCascade());
} catch (AuthorizationException e) {
throw e;
} catch (ProcessEngineException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.anyBoolean;
import static org.mockito.Matchers.anyInt;
import static org.mockito.Matchers.anyListOf;
import static org.mockito.Matchers.anyString;
Expand Down Expand Up @@ -342,8 +343,7 @@ public void testSetJobDuedate() {
.statusCode(Status.NO_CONTENT.getStatusCode())
.when().put(JOB_RESOURCE_SET_DUEDATE_URL);

verify(mockManagementService).setJobDuedate(MockProvider.EXAMPLE_JOB_ID, newDuedate);

verify(mockManagementService).setJobDuedate(MockProvider.EXAMPLE_JOB_ID, newDuedate, false);
}

@Test
Expand All @@ -355,17 +355,43 @@ public void testSetJobDuedateNull() {
.statusCode(Status.NO_CONTENT.getStatusCode())
.when().put(JOB_RESOURCE_SET_DUEDATE_URL);

verify(mockManagementService).setJobDuedate(MockProvider.EXAMPLE_JOB_ID, null);

verify(mockManagementService).setJobDuedate(MockProvider.EXAMPLE_JOB_ID, null, false);
}

@Test
public void testSetJobDuedateCascade() {
Date newDuedate = MockProvider.createMockDuedate();
Map<String, Object> duedateVariableJson = new HashMap<String, Object>();
duedateVariableJson.put("duedate", newDuedate);
duedateVariableJson.put("cascade", true);

given().pathParam("id", MockProvider.EXAMPLE_JOB_ID).contentType(ContentType.JSON).body(duedateVariableJson).then().expect()
.statusCode(Status.NO_CONTENT.getStatusCode())
.when().put(JOB_RESOURCE_SET_DUEDATE_URL);

verify(mockManagementService).setJobDuedate(MockProvider.EXAMPLE_JOB_ID, newDuedate, true);
}

@Test
public void testSetJobDuedateNullCascade() {
Map<String, Object> duedateVariableJson = new HashMap<String, Object>();
duedateVariableJson.put("duedate", null);
duedateVariableJson.put("cascade", true);

given().pathParam("id", MockProvider.EXAMPLE_JOB_ID).contentType(ContentType.JSON).body(duedateVariableJson).then().expect()
.statusCode(Status.NO_CONTENT.getStatusCode())
.when().put(JOB_RESOURCE_SET_DUEDATE_URL);

verify(mockManagementService).setJobDuedate(MockProvider.EXAMPLE_JOB_ID, null, true);
}

@Test
public void testSetJobDuedateNonExistentJob() {
Date newDuedate = MockProvider.createMockDuedate();
String expectedMessage = "No job found with id '" + MockProvider.NON_EXISTING_JOB_ID + "'.";

doThrow(new ProcessEngineException(expectedMessage)).when(mockManagementService).setJobDuedate(MockProvider.NON_EXISTING_JOB_ID,
newDuedate);
newDuedate, false);

Map<String, Object> duedateVariableJson = new HashMap<String, Object>();
duedateVariableJson.put("duedate", newDuedate);
Expand All @@ -377,13 +403,13 @@ public void testSetJobDuedateNonExistentJob() {
.body("message", equalTo(expectedMessage))
.when().put(JOB_RESOURCE_SET_DUEDATE_URL);

verify(mockManagementService).setJobDuedate(MockProvider.NON_EXISTING_JOB_ID, newDuedate);
verify(mockManagementService).setJobDuedate(MockProvider.NON_EXISTING_JOB_ID, newDuedate, false);
}

@Test
public void testSetJobDuedateThrowsAuthorizationException() {
String message = "expected exception";
doThrow(new AuthorizationException(message)).when(mockManagementService).setJobDuedate(anyString(), any(Date.class));
doThrow(new AuthorizationException(message)).when(mockManagementService).setJobDuedate(anyString(), any(Date.class), anyBoolean());

Date newDuedate = MockProvider.createMockDuedate();
Map<String, Object> duedateVariableJson = new HashMap<String, Object>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ create table ACT_RU_JOB (
EXCEPTION_MSG_ varchar(4000),
DUEDATE_ timestamp,
REPEAT_ varchar(255),
REPEAT_OFFSET_ bigint default 0,
REPEAT_OFFSET_ bigint default 0,
HANDLER_TYPE_ varchar(255),
HANDLER_CFG_ varchar(4000),
DEPLOYMENT_ID_ varchar(64),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ ALTER TABLE ACT_RU_JOB

-- https://app.camunda.com/jira/browse/CAM-10672
ALTER TABLE ACT_HI_INCIDENT
ADD HISTORY_CONFIGURATION_ varchar(255);
ADD HISTORY_CONFIGURATION_ varchar(255);
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ ALTER TABLE ACT_RU_JOB

-- https://app.camunda.com/jira/browse/CAM-10672
ALTER TABLE ACT_HI_INCIDENT
ADD HISTORY_CONFIGURATION_ varchar(255);
ADD HISTORY_CONFIGURATION_ varchar(255);
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ ALTER TABLE ACT_RU_JOB

-- https://app.camunda.com/jira/browse/CAM-10672
ALTER TABLE ACT_HI_INCIDENT
ADD HISTORY_CONFIGURATION_ varchar(255);
ADD HISTORY_CONFIGURATION_ varchar(255);
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ ALTER TABLE ACT_RU_JOB

-- https://app.camunda.com/jira/browse/CAM-10672
ALTER TABLE ACT_HI_INCIDENT
ADD HISTORY_CONFIGURATION_ nvarchar(255);
ADD HISTORY_CONFIGURATION_ nvarchar(255);
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ ALTER TABLE ACT_RU_JOB

-- https://app.camunda.com/jira/browse/CAM-10672
ALTER TABLE ACT_HI_INCIDENT
ADD HISTORY_CONFIGURATION_ varchar(255);
ADD HISTORY_CONFIGURATION_ varchar(255);
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ ALTER TABLE ACT_RU_JOB

-- https://app.camunda.com/jira/browse/CAM-10672
ALTER TABLE ACT_HI_INCIDENT
ADD HISTORY_CONFIGURATION_ NVARCHAR2(255);
ADD HISTORY_CONFIGURATION_ NVARCHAR2(255);
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ ALTER TABLE ACT_RU_JOB

-- https://app.camunda.com/jira/browse/CAM-10672
ALTER TABLE ACT_HI_INCIDENT
ADD HISTORY_CONFIGURATION_ varchar(255);
ADD HISTORY_CONFIGURATION_ varchar(255);

0 comments on commit b25b8ba

Please sign in to comment.