From 9b446751be242422604db941187d9a72187909d4 Mon Sep 17 00:00:00 2001 From: ChrisS1512 <87066931+ChrisS1512@users.noreply.github.com> Date: Fri, 29 Nov 2024 16:51:56 +0000 Subject: [PATCH] PUB-2573 - Updated functional tests --- .../MediaApplicationCreationTest.java | 32 +++++++++---------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/src/functionalTest/java/uk/gov/hmcts/reform/pip/account/management/controllers/MediaApplicationCreationTest.java b/src/functionalTest/java/uk/gov/hmcts/reform/pip/account/management/controllers/MediaApplicationCreationTest.java index 3b5cad09..9583034a 100644 --- a/src/functionalTest/java/uk/gov/hmcts/reform/pip/account/management/controllers/MediaApplicationCreationTest.java +++ b/src/functionalTest/java/uk/gov/hmcts/reform/pip/account/management/controllers/MediaApplicationCreationTest.java @@ -110,8 +110,8 @@ void shouldBeAbleToGetApplicationsByStatus() throws Exception { MediaApplication mediaApplication = createApplication(); MediaApplication approvedMediaApplication = createApplication(); - approvedMediaApplication = doPutRequest(String.format(APPROVE_APPLICATION, approvedMediaApplication.getId()), - bearer).getBody().as(MediaApplication.class); + doPutRequest(String.format(APPROVE_APPLICATION, approvedMediaApplication.getId()), + bearer); final Response getResponse = doGetRequest(GET_APPLICATIONS_BY_STATUS, bearer); @@ -119,8 +119,8 @@ void shouldBeAbleToGetApplicationsByStatus() throws Exception { assertThat(getResponse.getStatusCode()).isEqualTo(OK.value()); MediaApplication[] retrievedApplciations = getResponse.getBody().as(MediaApplication[].class); - assertThat(retrievedApplciations).contains(mediaApplication); - assertThat(retrievedApplciations).doesNotContain(approvedMediaApplication); + assertThat(retrievedApplciations).anyMatch(app -> app.getId().equals(mediaApplication.getId())); + assertThat(retrievedApplciations).noneMatch(app -> app.getId().equals(approvedMediaApplication.getId())); } @Test @@ -128,19 +128,17 @@ void shouldBeAbleToGetAllMediaApplications() throws Exception { MediaApplication mediaApplication = createApplication(); MediaApplication approvedMediaApplication = createApplication(); - Response approvedResponse = doPutRequest(String.format(APPROVE_APPLICATION, approvedMediaApplication.getId()), + doPutRequest(String.format(APPROVE_APPLICATION, approvedMediaApplication.getId()), bearer); - approvedMediaApplication = approvedResponse.getBody().as(MediaApplication.class); - final Response getResponse = doGetRequest(GET_ALL_APPLICATIONS, bearer); assertThat(getResponse.getStatusCode()).isEqualTo(OK.value()); - MediaApplication[] retrievedApplciations = getResponse.getBody().as(MediaApplication[].class); + MediaApplication[] retrievedApplications = getResponse.getBody().as(MediaApplication[].class); - assertThat(retrievedApplciations).contains(mediaApplication); - assertThat(retrievedApplciations).contains(approvedMediaApplication); + assertThat(retrievedApplications).anyMatch(app -> app.getId().equals(mediaApplication.getId())); + assertThat(retrievedApplications).anyMatch(app -> app.getId().equals(approvedMediaApplication.getId())); } @Test @@ -244,13 +242,13 @@ void shouldNoLongerBeAbleToGetImageWhenApplicationIsRejectedWithReasons() throws void ensureMediaApplicationsAreDeletedWhenReportingIsCalled() throws Exception { MediaApplication rejectedApplication = createApplication(); - rejectedApplication = doPutRequest(String.format(REJECT_APPLICATION, rejectedApplication.getId()), - bearer).getBody().as(MediaApplication.class); + doPutRequest(String.format(REJECT_APPLICATION, rejectedApplication.getId()), + bearer); MediaApplication approvedApplication = createApplication(); - approvedApplication = doPutRequest(String.format(APPROVE_APPLICATION, approvedApplication.getId()), - bearer).getBody().as(MediaApplication.class); + doPutRequest(String.format(APPROVE_APPLICATION, approvedApplication.getId()), + bearer); MediaApplication pendingApplication = createApplication(); @@ -262,8 +260,8 @@ void ensureMediaApplicationsAreDeletedWhenReportingIsCalled() throws Exception { MediaApplication[] retrievedApplications = getResponse.getBody().as(MediaApplication[].class); - assertThat(retrievedApplications).contains(pendingApplication); - assertThat(retrievedApplications).doesNotContain(rejectedApplication); - assertThat(retrievedApplications).doesNotContain(approvedApplication); + assertThat(retrievedApplications).anyMatch(app -> app.getId().equals(pendingApplication.getId())); + assertThat(retrievedApplications).noneMatch(app -> app.getId().equals(rejectedApplication.getId())); + assertThat(retrievedApplications).noneMatch(app -> app.getId().equals(approvedApplication.getId())); } }