Pull request #464: RED-4424-"lastReviewer" is always equal to "assignee" in the file status

Merge in RED/persistence-service from bugfix/RED-4424 to master

* commit '5c1b732b7dc28c92109ed35350028e32fdbbf202':
  RED-4424-"lastReviewer" is always equal to "assignee" in the file status
This commit is contained in:
Corina Olariu 2022-06-29 16:30:03 +02:00 committed by Dominique Eiflaender
commit 59c91eaf94
3 changed files with 51 additions and 4 deletions

View File

@ -91,9 +91,9 @@ public class FileStatusController implements StatusResource {
String assignee = fileStatus.getAssignee();
if (userId != null) {
assignee = userId;
fileStatusService.setAssignee(fileId, assignee);
}
fileStatusService.setStatusSuccessful(fileId, assignee != null ? WorkflowStatus.UNDER_REVIEW : WorkflowStatus.NEW);
fileStatusService.setAssignee(fileId, assignee);
analysisFlagsCalculationService.calculateFlags(dossierId, fileId);
indexingService.addToIndexingQueue(IndexMessageType.UPDATE, null, dossierId, fileId, 2);
}
@ -108,8 +108,8 @@ public class FileStatusController implements StatusResource {
assignee = approverId;
}
fileStatusService.setStatusSuccessful(fileId, assignee != null ? WorkflowStatus.UNDER_APPROVAL : WorkflowStatus.NEW);
fileStatusService.setAssignee(fileId, approverId);
fileStatusService.setStatusSuccessful(fileId, assignee != null ? WorkflowStatus.UNDER_APPROVAL : WorkflowStatus.NEW);
analysisFlagsCalculationService.calculateFlags(dossierId, fileId);
indexingService.addToIndexingQueue(IndexMessageType.UPDATE, null, dossierId, fileId, 2);
}

View File

@ -384,10 +384,10 @@ public class FileStatusService {
String lastReviewer = fileStatus.getLastReviewer();
String lastApprover = fileStatus.getLastApprover();
if (WorkflowStatus.UNDER_REVIEW.equals(fileStatus.getWorkflowStatus())) {
lastReviewer = StringUtils.isNotEmpty(assignee) ? assignee : fileStatus.getAssignee();
lastReviewer = StringUtils.isNotEmpty(assignee) ? fileStatus.getAssignee() : lastReviewer;
}
if (WorkflowStatus.UNDER_APPROVAL.equals(fileStatus.getWorkflowStatus())) {
lastApprover = StringUtils.isNotEmpty(assignee) ? assignee : fileStatus.getAssignee();
lastApprover = StringUtils.isNotEmpty(assignee) ? fileStatus.getAssignee() : lastApprover;
}
fileStatusPersistenceService.setAssignee(fileId, assignee, lastReviewer, lastApprover);

View File

@ -491,4 +491,51 @@ public class FileTest extends AbstractPersistenceServerServiceTest {
}
@Test
public void testFile4424() {
var start = OffsetDateTime.now();
var dossier = dossierTesterAndProvider.provideTestDossier();
var file = fileTesterAndProvider.testAndProvideFile(dossier);
// update dossier - add new member
CreateOrUpdateDossierRequest cru = new CreateOrUpdateDossierRequest();
BeanUtils.copyProperties(dossier, cru);
cru.getMemberIds().add("2");
var loadedFile = fileClient.getFileStatus(dossier.getId(), file.getId());
assertThat(loadedFile.getAssignee()).isNull();
assertThat(loadedFile.getWorkflowStatus()).isEqualTo(WorkflowStatus.NEW);
assertThat(loadedFile.getLastReviewer()).isNull();
assertThat(loadedFile.getLastApprover()).isNull();
fileClient.setStatusUnderReview(dossier.getId(), file.getId(), "1");
loadedFile = fileClient.getFileStatus(dossier.getId(), file.getId());
assertThat(loadedFile.getWorkflowStatus()).isEqualTo(WorkflowStatus.UNDER_REVIEW);
assertThat(loadedFile.getAssignee()).isEqualTo("1");
assertThat(loadedFile.getLastReviewer()).isNull();
assertThat(loadedFile.getLastApprover()).isNull();
fileClient.setCurrentFileAssignee(dossier.getId(), file.getId(), "2");
loadedFile = fileClient.getFileStatus(dossier.getId(), file.getId());
assertThat(loadedFile.getWorkflowStatus()).isEqualTo(WorkflowStatus.UNDER_REVIEW);
assertThat(loadedFile.getAssignee()).isEqualTo("2");
assertThat(loadedFile.getLastReviewer()).isEqualTo("1");
assertThat(loadedFile.getLastApprover()).isNull();
fileClient.setStatusUnderApproval(dossier.getId(), file.getId(), "2");
loadedFile = fileClient.getFileStatus(dossier.getId(), file.getId());
assertThat(loadedFile.getWorkflowStatus()).isEqualTo(WorkflowStatus.UNDER_APPROVAL);
assertThat(loadedFile.getAssignee()).isEqualTo("2");
assertThat(loadedFile.getLastReviewer()).isEqualTo("2");
assertThat(loadedFile.getLastApprover()).isNull();
fileClient.setCurrentFileAssignee(dossier.getId(), file.getId(), "1");
loadedFile = fileClient.getFileStatus(dossier.getId(), file.getId());
assertThat(loadedFile.getWorkflowStatus()).isEqualTo(WorkflowStatus.UNDER_APPROVAL);
assertThat(loadedFile.getAssignee()).isEqualTo("1");
assertThat(loadedFile.getLastReviewer()).isEqualTo("2");
assertThat(loadedFile.getLastApprover()).isEqualTo("2");
}
}