diff --git a/beekeeper-api/src/main/java/com/expediagroup/beekeeper/api/response/MetadataResponseConverter.java b/beekeeper-api/src/main/java/com/expediagroup/beekeeper/api/response/MetadataResponseConverter.java index 5aa4e2fb..58b671f2 100644 --- a/beekeeper-api/src/main/java/com/expediagroup/beekeeper/api/response/MetadataResponseConverter.java +++ b/beekeeper-api/src/main/java/com/expediagroup/beekeeper/api/response/MetadataResponseConverter.java @@ -37,9 +37,7 @@ public final class MetadataResponseConverter { public static Page convertToHousekeepingMetadataResponsePage( Page housekeepingMetadataPage) { List housekeepingMetadataList = housekeepingMetadataPage.getContent(); - //Create a new ArrayList to store the HousekeepingMetadataResponse objects. List housekeepingMetadataResponseList = new ArrayList<>(); - //Iterate over the list of HousekeepingMetadata objects and convert each one to a HousekeepingMetadataResponse object. for (HousekeepingMetadata housekeepingMetadata : housekeepingMetadataList) { HousekeepingMetadataResponse housekeepingMetadataResponse = convertToHousekeepingMetadataResponse(housekeepingMetadata); housekeepingMetadataResponseList.add(housekeepingMetadataResponse); diff --git a/beekeeper-api/src/main/java/com/expediagroup/beekeeper/api/response/PathResponseConverter.java b/beekeeper-api/src/main/java/com/expediagroup/beekeeper/api/response/PathResponseConverter.java index 45ab128b..d71c80d6 100644 --- a/beekeeper-api/src/main/java/com/expediagroup/beekeeper/api/response/PathResponseConverter.java +++ b/beekeeper-api/src/main/java/com/expediagroup/beekeeper/api/response/PathResponseConverter.java @@ -51,9 +51,7 @@ private static HousekeepingPathResponse convertToHousekeepingPathResponse(Housek public static Page convertToHousekeepingPathResponsePage( Page housekeepingPathPage) { List housekeepingPathList = housekeepingPathPage.getContent(); - //Create a new ArrayList to store the HousekeepingPathResponse objects. List housekeepingPathResponseList = new ArrayList<>(); - //Iterate over the list of HousekeepingPath objects and convert each one to a HousekeepingPathResponse object. for (HousekeepingPath housekeepingPath : housekeepingPathList) { HousekeepingPathResponse housekeepingPathResponse = convertToHousekeepingPathResponse(housekeepingPath); housekeepingPathResponseList.add(housekeepingPathResponse); diff --git a/beekeeper-api/src/test/java/com/expediagroup/beekeeper/api/response/HousekeepingMetadataResponseTest.java b/beekeeper-api/src/test/java/com/expediagroup/beekeeper/api/response/HousekeepingMetadataResponseTest.java index 663bb7a4..8eb0f1aa 100644 --- a/beekeeper-api/src/test/java/com/expediagroup/beekeeper/api/response/HousekeepingMetadataResponseTest.java +++ b/beekeeper-api/src/test/java/com/expediagroup/beekeeper/api/response/HousekeepingMetadataResponseTest.java @@ -55,19 +55,14 @@ public void testConvertToHouseKeepingMetadataResponsePage() { @Test public void testConvertToHouseKeepingMetadataResponsePageWithMultiplePages() { - // Create a list of housekeeping metadata objects that is larger than the page size List housekeepingMetadataList = new ArrayList<>(); for (int i = 0; i < 50; i++) { housekeepingMetadataList.add(generateDummyHousekeepingMetadata("some_database" + i, "some_table" + i)); } - // Create a page of housekeeping metadata objects Page metadataPage = new PageImpl<>(housekeepingMetadataList, PageRequest.of(0, 10), 50); - - // Convert the page of housekeeping metadata objects to a page of housekeeping metadata response objects Page metadataResponsePage = convertToHousekeepingMetadataResponsePage(metadataPage); - // Assert that the housekeeping metadata response page has the correct total elements and total pages assertThat(metadataResponsePage.getTotalElements()).isEqualTo(50L); assertThat(metadataResponsePage.getTotalPages()).isEqualTo(5L); } diff --git a/beekeeper-integration-tests/src/test/java/com/expediagroup/beekeeper/integration/api/BeekeeperApiIntegrationTest.java b/beekeeper-integration-tests/src/test/java/com/expediagroup/beekeeper/integration/api/BeekeeperApiIntegrationTest.java index 1e128024..cdc75cec 100644 --- a/beekeeper-integration-tests/src/test/java/com/expediagroup/beekeeper/integration/api/BeekeeperApiIntegrationTest.java +++ b/beekeeper-integration-tests/src/test/java/com/expediagroup/beekeeper/integration/api/BeekeeperApiIntegrationTest.java @@ -186,32 +186,26 @@ public void testGetPathsWhenThereIsFiltering() throws SQLException, InterruptedE @Test public void testPathsPageable() throws SQLException, InterruptedException, IOException { - // Create three new HousekeepingPath objects HousekeepingPath testPath1 = createHousekeepingPath(someTable, pathA, LifecycleEventType.EXPIRED, duration.toString()); HousekeepingPath testPath2 = createHousekeepingPath(someTable, pathB, LifecycleEventType.UNREFERENCED, duration.toString()); HousekeepingPath testPath3 = createHousekeepingPath(someTable, pathC, LifecycleEventType.UNREFERENCED, duration.toString()); - // Set the housekeepingStatus for all test paths as FAILED for (HousekeepingPath testPath : Arrays.asList(testPath1, testPath2, testPath3)) { testPath.setHousekeepingStatus(HousekeepingStatus.FAILED); } - // Insert the three objects into the database for (HousekeepingPath testPath : Arrays.asList(testPath1, testPath2, testPath3)) { insertUnreferencedPath(testPath); } - // Call the getUnreferencedPaths() method with the relevant filters String filters = "?housekeeping_status=FAILED&page=1&size=" + pageSize; HttpResponse response = testClient.getUnreferencedPaths(someDatabase, someTable, filters); - // Assert that the response contains the entries in the database assertThat(response.statusCode()).isEqualTo(OK.value()); String body = response.body(); Page responsePage = mapper .readValue(body, new TypeReference>() {}); List result = responsePage.getContent(); - assertThat(result).hasSize(1); assertThat(responsePage.getTotalElements()).isEqualTo(3L); assertThat(responsePage.getTotalPages()).isEqualTo(3L); @@ -219,32 +213,26 @@ public void testPathsPageable() throws SQLException, InterruptedException, IOExc @Test public void testMetadataPageable() throws SQLException, InterruptedException, IOException { - // Create three new HousekeepingMetadata objects HousekeepingMetadata testMetadata1 = createHousekeepingMetadata(someTable, pathA, partitionA, LifecycleEventType.EXPIRED, duration.toString()); HousekeepingMetadata testMetadata2 = createHousekeepingMetadata(someTable, pathB, partitionB, LifecycleEventType.EXPIRED, duration.toString()); HousekeepingMetadata testMetadata3 = createHousekeepingMetadata(someTable, pathC, partitionC, LifecycleEventType.EXPIRED, duration.toString()); - // Set the housekeepingStatus and cleanupTimestamp properties for (HousekeepingMetadata testPath : Arrays.asList(testMetadata1, testMetadata2, testMetadata3)) { testPath.setHousekeepingStatus(HousekeepingStatus.FAILED); } - // Insert the three objects into the database for (HousekeepingMetadata testMetadata : Arrays.asList(testMetadata1, testMetadata2, testMetadata3)) { insertExpiredMetadata(testMetadata); } - // Call the getUnreferencedPaths() method with the relevant filters String filters = "?housekeeping_status=FAILED&page=1&size=" + pageSize; HttpResponse response = testClient.getMetadata(someDatabase, someTable, filters); - // Assert that the response contains the entries in the database assertThat(response.statusCode()).isEqualTo(OK.value()); String body = response.body(); Page responsePage = mapper .readValue(body, new TypeReference>() {}); List result = responsePage.getContent(); - assertThat(result).hasSize(1); assertThat(responsePage.getTotalElements()).isEqualTo(3L); assertThat(responsePage.getTotalPages()).isEqualTo(3L);