Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix:API-paging #172

Merged
merged 33 commits into from
Nov 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
77b421c
fix:API-paging
Nov 2, 2023
f5e476d
Adding tests
Nov 3, 2023
89a5d58
Update BeekeeperApiIntegrationTest.java
Nov 3, 2023
9e7f763
Update CHANGELOG.md
HamzaJugon Nov 7, 2023
1a59b02
Update CHANGELOG.md
HamzaJugon Nov 7, 2023
6db5465
Update CHANGELOG.md
HamzaJugon Nov 7, 2023
4966b56
[maven-release-plugin] prepare release beekeeper-parent-3.5.5
eg-oss-ci Nov 7, 2023
a47309e
[maven-release-plugin] prepare for next development iteration
eg-oss-ci Nov 7, 2023
16bb13d
Update pom.xml
HamzaJugon Nov 8, 2023
643d1ca
Update pom.xml
HamzaJugon Nov 8, 2023
db6a691
Update pom.xml
HamzaJugon Nov 8, 2023
03d3f4b
Update pom.xml
HamzaJugon Nov 8, 2023
2c29d08
Update pom.xml
HamzaJugon Nov 8, 2023
586a11f
Update pom.xml
HamzaJugon Nov 8, 2023
4a18f68
Update pom.xml
HamzaJugon Nov 8, 2023
249c99f
Update pom.xml
HamzaJugon Nov 8, 2023
ccead96
Update pom.xml
HamzaJugon Nov 8, 2023
d9e016a
Update pom.xml
HamzaJugon Nov 8, 2023
30c2040
Remove surplus comments
Nov 8, 2023
7a02cc5
Update CHANGELOG.md
HamzaJugon Nov 8, 2023
bad68e0
Update CHANGELOG.md
HamzaJugon Nov 9, 2023
4496f4d
Update beekeeper-api/src/test/java/com/expediagroup/beekeeper/api/res…
andreeapad Nov 9, 2023
fcc6a73
Update beekeeper-api/src/main/java/com/expediagroup/beekeeper/api/res…
HamzaJugon Nov 9, 2023
9d913fe
Update MetadataResponseConverter.java
HamzaJugon Nov 9, 2023
ebacb6d
Update PathResponseConverter.java
HamzaJugon Nov 9, 2023
8f94433
Update CHANGELOG.md
HamzaJugon Nov 9, 2023
e1de760
Update BeekeeperApiIntegrationTest.java
Nov 10, 2023
fdabfc5
Update BeekeeperApiIntegrationTest.java
Nov 10, 2023
9e3f1d3
Update BeekeeperApiIntegrationTest.java
Nov 10, 2023
fd4d461
Update BeekeeperApiIntegrationTest.java
Nov 10, 2023
c067716
Refactoring tests
Nov 10, 2023
6d5e33d
Update beekeeper-integration-tests/src/test/java/com/expediagroup/bee…
HamzaJugon Nov 10, 2023
d853eb7
Refactoring tests
Nov 10, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [3.5.5] - 2023-11-10
### Fixed
- Fixed paged API response by updating 'MetadataResponseConverter' and 'PathResponseConverter' to pass complete information about the number of pages and elements to the response Page.

## [3.5.4] - 2023-09-14
### Fixed
- Added localisation normalization so locations like `s3:/a/b` and `s3:/a/b/` will be considered the same and path won't be scheduled for deletion.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,12 @@ public static Page<HousekeepingMetadataResponse> convertToHousekeepingMetadataRe
List<HousekeepingMetadata> housekeepingMetadataList = housekeepingMetadataPage.getContent();
List<HousekeepingMetadataResponse> housekeepingMetadataResponseList = new ArrayList<>();
for (HousekeepingMetadata housekeepingMetadata : housekeepingMetadataList) {
HousekeepingMetadataResponse housekeepingMetadataResponse = convertToHousekeepingMetadataResponse(
housekeepingMetadata);
HousekeepingMetadataResponse housekeepingMetadataResponse = convertToHousekeepingMetadataResponse(housekeepingMetadata);
housekeepingMetadataResponseList.add(housekeepingMetadataResponse);
}
return new PageImpl<>(housekeepingMetadataResponseList);
PageImpl<HousekeepingMetadataResponse> housekeepingMetadataResponses = new PageImpl<>(
housekeepingMetadataResponseList, housekeepingMetadataPage.getPageable(), housekeepingMetadataPage.getTotalElements());
return housekeepingMetadataResponses;
}

private static HousekeepingMetadataResponse convertToHousekeepingMetadataResponse(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,9 @@ public static Page<HousekeepingPathResponse> convertToHousekeepingPathResponsePa
HousekeepingPathResponse housekeepingPathResponse = convertToHousekeepingPathResponse(housekeepingPath);
housekeepingPathResponseList.add(housekeepingPathResponse);
}
return new PageImpl<>(housekeepingPathResponseList);
PageImpl<HousekeepingPathResponse> housekeepingPathResponses = new PageImpl<>(
housekeepingPathResponseList, housekeepingPathPage.getPageable(), housekeepingPathPage.getTotalElements());
return housekeepingPathResponses;
}

}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright (C) 2019-2021 Expedia, Inc.
* Copyright (C) 2019-2023 Expedia, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -21,11 +21,13 @@
import static com.expediagroup.beekeeper.api.util.DummyHousekeepingEntityGenerator.generateDummyHousekeepingMetadata;
import static com.expediagroup.beekeeper.api.util.DummyHousekeepingEntityGenerator.generateDummyHousekeepingMetadataResponse;

import java.util.ArrayList;
import java.util.List;

import org.junit.jupiter.api.Test;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.PageRequest;

import com.expediagroup.beekeeper.core.model.HousekeepingMetadata;

Expand All @@ -46,7 +48,22 @@ public void testConvertToHouseKeepingMetadataResponsePage() {

assertThat(metadataResponsePageList.get(0)).isEqualTo(metadataResponse1);
assertThat(metadataResponsePageList.get(1)).isEqualTo(metadataResponse2);
assertThat(metadataResponsePage.getTotalElements()).isEqualTo(2L);
assertThat(metadataResponsePage.getTotalPages()).isEqualTo(1L);
HamzaJugon marked this conversation as resolved.
Show resolved Hide resolved
assertThat(metadataResponsePage.getPageable()).isEqualTo((new PageImpl<>(housekeepingMetadataList).getPageable()));
}

@Test
public void testConvertToHouseKeepingMetadataResponsePageWithMultiplePages() {
List<HousekeepingMetadata> housekeepingMetadataList = new ArrayList<>();
for (int i = 0; i < 50; i++) {
housekeepingMetadataList.add(generateDummyHousekeepingMetadata("some_database" + i, "some_table" + i));
}

Page<HousekeepingMetadata> metadataPage = new PageImpl<>(housekeepingMetadataList, PageRequest.of(0, 10), 50);
Page<HousekeepingMetadataResponse> metadataResponsePage = convertToHousekeepingMetadataResponsePage(metadataPage);

assertThat(metadataResponsePage.getTotalElements()).isEqualTo(50L);
assertThat(metadataResponsePage.getTotalPages()).isEqualTo(5L);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/**
* Copyright (C) 2019-2023 Expedia, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.expediagroup.beekeeper.api.response;

import static org.assertj.core.api.AssertionsForClassTypes.assertThat;

import static com.expediagroup.beekeeper.api.response.PathResponseConverter.convertToHousekeepingPathResponsePage;
import static com.expediagroup.beekeeper.api.util.DummyHousekeepingEntityGenerator.generateDummyHousekeepingPath;
import static com.expediagroup.beekeeper.api.util.DummyHousekeepingEntityGenerator.generateDummyHousekeepingPathResponse;

import java.util.List;

import org.junit.jupiter.api.Test;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;

import com.expediagroup.beekeeper.core.model.HousekeepingPath;

public class PathResponseConverterTest {

@Test
public void testConvertToHousekeepingPathResponsePage() {
HousekeepingPath housekeepingPath1 = generateDummyHousekeepingPath("some_database1", "some_table1");
HousekeepingPath housekeepingPath2 = generateDummyHousekeepingPath("some_database2", "some_table2");
HousekeepingPathResponse housekeepingPathResponse1 = generateDummyHousekeepingPathResponse(housekeepingPath1);
HousekeepingPathResponse housekeepingPathResponse2 = generateDummyHousekeepingPathResponse(housekeepingPath2);

List<HousekeepingPath> housekeepingPathList = List.of(housekeepingPath1, housekeepingPath2);
Page<HousekeepingPathResponse> housekeepingPathResponsePage = convertToHousekeepingPathResponsePage(
new PageImpl<>(housekeepingPathList));

List<HousekeepingPathResponse> housekeepingPathResponsePageList = housekeepingPathResponsePage.getContent();

assertThat(housekeepingPathResponsePageList.get(0)).isEqualTo(housekeepingPathResponse1);
assertThat(housekeepingPathResponsePageList.get(1)).isEqualTo(housekeepingPathResponse2);
assertThat(housekeepingPathResponsePage.getTotalElements()).isEqualTo(2L);
assertThat(housekeepingPathResponsePage.getTotalPages()).isEqualTo(1L);
assertThat(housekeepingPathResponsePage.getPageable()).isEqualTo((new PageImpl<>(housekeepingPathList).getPageable()));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import java.time.ZoneId;

import com.expediagroup.beekeeper.api.response.HousekeepingMetadataResponse;
import com.expediagroup.beekeeper.api.response.HousekeepingPathResponse;
import com.expediagroup.beekeeper.core.model.HousekeepingMetadata;
import com.expediagroup.beekeeper.core.model.HousekeepingPath;
import com.expediagroup.beekeeper.core.model.PeriodDuration;
Expand Down Expand Up @@ -88,4 +89,19 @@ public static HousekeepingPath generateDummyHousekeepingPath(String databaseName
.build();
}

public static HousekeepingPathResponse generateDummyHousekeepingPathResponse(HousekeepingPath housekeepingPath) {
return HousekeepingPathResponse
.builder()
.path("s3://some/path/")
.databaseName(housekeepingPath.getDatabaseName())
.tableName(housekeepingPath.getTableName())
.housekeepingStatus(SCHEDULED)
.creationTimestamp(CREATION_TIMESTAMP)
.modifiedTimestamp(CREATION_TIMESTAMP)
.cleanupTimestamp(housekeepingPath.getCleanupTimestamp())
.cleanupDelay(CLEANUP_DELAY_STRING)
.cleanupAttempts(0)
.lifecycleType(EXPIRED.toString())
.build();
}
}
Loading
Loading