Skip to content

Commit

Permalink
PUB-2573 - Updated functional tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisS1512 committed Nov 29, 2024
1 parent b358169 commit 9b44675
Showing 1 changed file with 15 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -110,37 +110,35 @@ 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);

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
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
Expand Down Expand Up @@ -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();

Expand All @@ -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()));
}
}

0 comments on commit 9b44675

Please sign in to comment.