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

bug: #778 return empty page result instead of HTTP 404 #954

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
_**For better traceability add the corresponding GitHub issue number in each changelog entry, please.**_
## [UNRELEASED - DD.MM.YYYY]

### Changed
- #778 return empty PageResult when no contract agreement Ids are found instead of http 404 in /contacts API

## [11.0.0 - 08.05.2024]
### Added
- #844 Validation for BPN to Notification API (Create / Edit), Fixed pagination
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ public PageResult<Contract> getContractsByPageable(Pageable pageable, SearchCrit
Page<ContractAgreementView> contractAgreementInfoViews = contractAgreementInfoViewRepository.findAll(specification, pageable);

if (contractAgreementInfoViews.getContent().isEmpty()) {
throw new ContractException("Cannot find contract agreement Ids for asset ids in searchCriteria: " + searchCriteria.getSearchCriteriaFilterList());
log.warn("Cannot find contract agreement Ids for asset ids in searchCriteria: " + searchCriteria.getSearchCriteriaFilterList());
return new PageResult<>(List.of(), 0, 0, 0, 0L);
}

return new PageResult<>(fetchEdcContractAgreements(contractAgreementInfoViews),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,14 +142,14 @@ void shouldReturnOnlyOneContract() throws JoseException {
}

@Test
void shouldReturn404IfAssetIdIsUnknown() throws JoseException {
void shouldReturnEmptyIfAssetIdIsUnknown() throws JoseException {
//GIVEN
edcSupport.edcWillReturnOnlyOneContractAgreement();
edcSupport.edcWillReturnContractAgreementNegotiation();
assetsSupport.defaultAssetsStored();

//WHEN//THEN
given()
PageResult<ContractResponse> contractResponsePageResult = given()
.header(oAuth2Support.jwtAuthorization(ADMIN))
.contentType(ContentType.JSON)
.log().all()
Expand All @@ -158,7 +158,11 @@ void shouldReturn404IfAssetIdIsUnknown() throws JoseException {
.post("/api/contracts")
.then()
.log().all()
.statusCode(404);
.statusCode(200)
.extract().body().as(new TypeRef<>() {
});
//THEN
assertThat(contractResponsePageResult.content()).isEmpty();
}

}
Loading