Skip to content

Commit

Permalink
Remove surplus comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Hamza Jugon committed Nov 8, 2023
1 parent d9e016a commit 30c2040
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,7 @@ public final class MetadataResponseConverter {
public static Page<HousekeepingMetadataResponse> convertToHousekeepingMetadataResponsePage(
Page<HousekeepingMetadata> housekeepingMetadataPage) {
List<HousekeepingMetadata> housekeepingMetadataList = housekeepingMetadataPage.getContent();
//Create a new ArrayList to store the HousekeepingMetadataResponse objects.
List<HousekeepingMetadataResponse> 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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,7 @@ private static HousekeepingPathResponse convertToHousekeepingPathResponse(Housek
public static Page<HousekeepingPathResponse> convertToHousekeepingPathResponsePage(
Page<HousekeepingPath> housekeepingPathPage) {
List<HousekeepingPath> housekeepingPathList = housekeepingPathPage.getContent();
//Create a new ArrayList to store the HousekeepingPathResponse objects.
List<HousekeepingPathResponse> 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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<HousekeepingMetadata> 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<HousekeepingMetadata> 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<HousekeepingMetadataResponse> 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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,65 +186,53 @@ 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<String> 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<HousekeepingPathResponse> responsePage = mapper
.readValue(body, new TypeReference<RestResponsePage<HousekeepingPathResponse>>() {});
List<HousekeepingPathResponse> result = responsePage.getContent();

assertThat(result).hasSize(1);
assertThat(responsePage.getTotalElements()).isEqualTo(3L);
assertThat(responsePage.getTotalPages()).isEqualTo(3L);
}

@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<String> 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<HousekeepingMetadataResponse> responsePage = mapper
.readValue(body, new TypeReference<RestResponsePage<HousekeepingMetadataResponse>>() {});
List<HousekeepingMetadataResponse> result = responsePage.getContent();

assertThat(result).hasSize(1);
assertThat(responsePage.getTotalElements()).isEqualTo(3L);
assertThat(responsePage.getTotalPages()).isEqualTo(3L);
Expand Down

0 comments on commit 30c2040

Please sign in to comment.