Skip to content

Commit

Permalink
bug: #778 return empty PageResult in /contracts instead of HTTP 404
Browse files Browse the repository at this point in the history
  • Loading branch information
ds-lcapellino committed May 8, 2024
1 parent a60931d commit 10c11e3
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ _**For better traceability add the corresponding GitHub issue number in each cha
- #XXX update of cucumber-bom from 7.16.1 to 7.17.0
- #XXX Updated spring boot from 3.2.4 to 3.2.5
- #XXX Bumped logback-core & logback-classic from 1.5.4 to 1.5.5
- #778 return empty PageResult when no contract agreement Ids are found instead of http 404 in /contacts API

### Removed
- #602 digitalTwinType instead of semanticId. DigitalTwinType causes problems in release 24.05
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 10c11e3

Please sign in to comment.