From 66d6f8c477b9af4d4ad975336fa562eec5c183ec Mon Sep 17 00:00:00 2001 From: Jim Purvis Date: Tue, 26 Mar 2024 10:44:43 +0000 Subject: [PATCH] TMI2-725 - Remove Contentful slug when unpublishing an advert --- .../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 41c4c662..b4f1dc21 100644 --- a/src/main/java/gov/cabinetoffice/gap/adminbackend/services/GrantAdvertService.java +++ b/src/main/java/gov/cabinetoffice/gap/adminbackend/services/GrantAdvertService.java @@ -319,6 +319,7 @@ public void unpublishAdvert(UUID advertId) { contentfulManagementClient.entries().unPublish(contentfulAdvert); 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 5b4cb5f4..cf8b691b 100644 --- a/src/test/java/gov/cabinetoffice/gap/adminbackend/services/GrantAdvertServiceTest.java +++ b/src/test/java/gov/cabinetoffice/gap/adminbackend/services/GrantAdvertServiceTest.java @@ -1044,6 +1044,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 @@ -1071,6 +1072,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(); } }