From f456d9bc52741db3416e8c3543b451829cf25db1 Mon Sep 17 00:00:00 2001 From: Amit Sinha Date: Fri, 12 Nov 2021 13:47:24 +0000 Subject: [PATCH] Status bug fix (#285) * Renaming completed to processed status enum to match the previous data * adding feature toggle on/off for status * auto patch increment Co-authored-by: ras-rm-pr-bot --- _infra/helm/collection-exercise/Chart.yaml | 4 ++-- .../collection/exercise/representation/EventDTO.java | 2 +- .../collection/exercise/service/EventService.java | 10 +++++++--- .../message/CaseActionEventStatusReceiverIT.java | 4 ++-- .../collection/exercise/service/EventServiceTest.java | 4 ++-- 5 files changed, 14 insertions(+), 10 deletions(-) diff --git a/_infra/helm/collection-exercise/Chart.yaml b/_infra/helm/collection-exercise/Chart.yaml index f4fe2a8e..9900e889 100644 --- a/_infra/helm/collection-exercise/Chart.yaml +++ b/_infra/helm/collection-exercise/Chart.yaml @@ -14,8 +14,8 @@ type: application # This is the chart version. This version number should be incremented each time you make changes # to the chart and its templates, including the app version. -version: 12.1.8 +version: 12.1.9 # This is the version number of the application being deployed. This version number should be # incremented each time you make changes to the application. -appVersion: 12.1.8 \ No newline at end of file +appVersion: 12.1.9 \ No newline at end of file diff --git a/src/main/java/uk/gov/ons/ctp/response/collection/exercise/representation/EventDTO.java b/src/main/java/uk/gov/ons/ctp/response/collection/exercise/representation/EventDTO.java index 8376c263..5032624b 100644 --- a/src/main/java/uk/gov/ons/ctp/response/collection/exercise/representation/EventDTO.java +++ b/src/main/java/uk/gov/ons/ctp/response/collection/exercise/representation/EventDTO.java @@ -27,7 +27,7 @@ public class EventDTO { @Nullable public enum Status { SCHEDULED, - COMPLETED, + PROCESSED, FAILED, RETRY, PROCESSING diff --git a/src/main/java/uk/gov/ons/ctp/response/collection/exercise/service/EventService.java b/src/main/java/uk/gov/ons/ctp/response/collection/exercise/service/EventService.java index 8f31a18f..220e48c0 100644 --- a/src/main/java/uk/gov/ons/ctp/response/collection/exercise/service/EventService.java +++ b/src/main/java/uk/gov/ons/ctp/response/collection/exercise/service/EventService.java @@ -425,7 +425,8 @@ public void processEvents() { log.with("tag", event.getTag()).info("Event is actionable, beginning processing"); boolean success; // feature toggled based on if action is deprecated - if (appConfig.getActionSvc().isDeprecated()) { + boolean isActionDeprecated = appConfig.getActionSvc().isDeprecated(); + if (isActionDeprecated) { success = caseSvcClient.processEvent(event.getTag(), exercise.getId()); } else { success = actionSvcClient.processEvent(event.getTag(), exercise.getId()); @@ -433,7 +434,10 @@ public void processEvents() { if (success) { log.info("Event processing succeeded, setting to PROCESSING state"); - event.setStatus(EventDTO.Status.PROCESSING); + // feature toggled based on if action is deprecated + EventDTO.Status status = + isActionDeprecated ? EventDTO.Status.PROCESSING : EventDTO.Status.PROCESSED; + event.setStatus(status); event.setMessageSent(Timestamp.from(Instant.now())); } else { log.error( @@ -443,7 +447,7 @@ public void processEvents() { } else { log.with("tag", event.getTag()) .debug("Event is not actionable, setting to COMPLETED state"); - event.setStatus(EventDTO.Status.COMPLETED); + event.setStatus(EventDTO.Status.PROCESSED); } eventRepository.saveAndFlush(event); } else { diff --git a/src/test/java/uk/gov/ons/ctp/response/collection/exercise/message/CaseActionEventStatusReceiverIT.java b/src/test/java/uk/gov/ons/ctp/response/collection/exercise/message/CaseActionEventStatusReceiverIT.java index 731d6d5a..37be64b1 100644 --- a/src/test/java/uk/gov/ons/ctp/response/collection/exercise/message/CaseActionEventStatusReceiverIT.java +++ b/src/test/java/uk/gov/ons/ctp/response/collection/exercise/message/CaseActionEventStatusReceiverIT.java @@ -120,14 +120,14 @@ public void shouldUpdateEventStatus() throws IOException, CTPException, Interrup + "\"collectionExerciseID\": \"%s\"," + "\"tag\": \"mps\"," + "\"status\":" - + "\"COMPLETED\"" + + "\"PROCESSED\"" + "}", collectionExercise.getId()); PUBSUBEMULATOR.publishMessage(eventStatusUpdate, PUBSUB_TOPIC); Thread.sleep(5000); Event finalEvent = eventRepository.findOneByCollectionExerciseIdAndTag(collectionExercise.getId(), "mps"); - Assert.assertEquals(EventDTO.Status.COMPLETED, finalEvent.getStatus()); + Assert.assertEquals(EventDTO.Status.PROCESSED, finalEvent.getStatus()); } private EventDTO createEventDTO( diff --git a/src/test/java/uk/gov/ons/ctp/response/collection/exercise/service/EventServiceTest.java b/src/test/java/uk/gov/ons/ctp/response/collection/exercise/service/EventServiceTest.java index c3c54619..76f386d9 100644 --- a/src/test/java/uk/gov/ons/ctp/response/collection/exercise/service/EventServiceTest.java +++ b/src/test/java/uk/gov/ons/ctp/response/collection/exercise/service/EventServiceTest.java @@ -506,7 +506,7 @@ public void testEventStatusNothingToUpdate() { .thenReturn(null); UUID collectionExerciseId = UUID.randomUUID(); CaseActionEventStatusDTO eventStatusDTO = new CaseActionEventStatusDTO(); - eventStatusDTO.setStatus(EventDTO.Status.COMPLETED); + eventStatusDTO.setStatus(EventDTO.Status.PROCESSED); eventStatusDTO.setTag(CaseActionEventStatusDTO.EventTag.mps); eventStatusDTO.setCollectionExerciseID(collectionExerciseId); // When @@ -533,7 +533,7 @@ public void testEventStatusUpdate() { .thenReturn(event); UUID collectionExerciseId = UUID.randomUUID(); CaseActionEventStatusDTO eventStatusDTO = new CaseActionEventStatusDTO(); - eventStatusDTO.setStatus(EventDTO.Status.COMPLETED); + eventStatusDTO.setStatus(EventDTO.Status.PROCESSED); eventStatusDTO.setTag(CaseActionEventStatusDTO.EventTag.mps); eventStatusDTO.setCollectionExerciseID(collectionExerciseId); // When