Skip to content

Commit

Permalink
Merge pull request #954 from catenax-ng/bug/778-return-empty-pageResu…
Browse files Browse the repository at this point in the history
…lt-instead-404

bug: #778 return empty page result insteadof http 404
  • Loading branch information
ds-mwesener authored May 8, 2024
2 parents 0b3fa79 + 3b4bee1 commit b9b23f8
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
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();
}

}

0 comments on commit b9b23f8

Please sign in to comment.