From 2eb1c5b8ec63a7bd46b5323196ddf89455823889 Mon Sep 17 00:00:00 2001 From: jimpurvisTCO <151734116+jimpurvisTCO@users.noreply.github.com> Date: Tue, 26 Mar 2024 11:22:10 +0000 Subject: [PATCH] TMI2-725 - Remove Contentful slug when unpublishing an advert (#264) Co-authored-by: Jim Purvis --- .../gap/adminbackend/services/GrantAdvertService.java | 1 + .../gap/adminbackend/services/GrantAdvertServiceTest.java | 2 ++ 2 files changed, 3 insertions(+) diff --git a/src/main/java/gov/cabinetoffice/gap/adminbackend/services/GrantAdvertService.java b/src/main/java/gov/cabinetoffice/gap/adminbackend/services/GrantAdvertService.java index 502b1e30..868556bf 100644 --- a/src/main/java/gov/cabinetoffice/gap/adminbackend/services/GrantAdvertService.java +++ b/src/main/java/gov/cabinetoffice/gap/adminbackend/services/GrantAdvertService.java @@ -328,6 +328,7 @@ public void unpublishAdvert(UUID advertId) { } advert.setStatus(GrantAdvertStatus.DRAFT); + advert.setContentfulSlug(null); advert.setUnpublishedDate(Instant.now()); save(advert); diff --git a/src/test/java/gov/cabinetoffice/gap/adminbackend/services/GrantAdvertServiceTest.java b/src/test/java/gov/cabinetoffice/gap/adminbackend/services/GrantAdvertServiceTest.java index f411e6c7..7ce06cb0 100644 --- a/src/test/java/gov/cabinetoffice/gap/adminbackend/services/GrantAdvertServiceTest.java +++ b/src/test/java/gov/cabinetoffice/gap/adminbackend/services/GrantAdvertServiceTest.java @@ -1067,6 +1067,7 @@ void unpublishAdvert_UnpublishesAdvertFromContentful_AndSetsStatusToDraftInDb() assertThat(advertCaptor.getValue().getId()).isEqualTo(grantAdvertId); assertThat(advertCaptor.getValue().getStatus()).isEqualTo(GrantAdvertStatus.DRAFT); assertThat(advertCaptor.getValue().getUnpublishedDate()).isNotNull(); + assertThat(advertCaptor.getValue().getContentfulSlug()).isNull(); } @Test @@ -1097,6 +1098,7 @@ void unpublishAdvertThroughLambda_successfullyUnpublishedAdvert() { assertThat(advertCaptor.getValue().getId()).isEqualTo(grantAdvertId); assertThat(advertCaptor.getValue().getStatus()).isEqualTo(GrantAdvertStatus.DRAFT); assertThat(advertCaptor.getValue().getUnpublishedDate()).isNotNull(); + assertThat(advertCaptor.getValue().getContentfulSlug()).isNull(); } }