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

Need help on creating the contract test example for filtering end point using yaml #2148

Open
mj967817 opened this issue Jan 3, 2025 · 2 comments

Comments

@mj967817
Copy link

mj967817 commented Jan 3, 2025

@GetMapping(value = "/product", produces = MediaType.APPLICATION_JSON_VALUE)
@PreAuthorize(ConstantsRoles.USERS_WITH_FETCH_ACCESS)
@PostAuthorize("@postAuthorizeValidator.hasAccess(returnObject)")
MappingJacksonValue productFind(
@RequestHeader(value = ConstantsDefaultValues.X_CLIENT) String xClient,
@RequestHeader(value = ConstantsDefaultValues.X_INTERNAL_CLIENT, required = false) String xInternalClient,
@RequestParam(name = "relatedParty.id", required = false) String relatedPartyId,
@RequestParam(name = "relatedParty.role", required = false) String relatedPartyRole,
@RequestParam(required = false) String fields,
@RequestParam(name = "billingAccount.id", required = false) String billingAccountId,
@RequestParam(name = "paymentIds", required = false) String[] paymentIds
);

 @Override
public MappingJacksonValue productFind(String xClient, String xInternalClient,
                                       String relatedPartyId, String relatedPartyRole, String fields,
                                     String billingAccountId,
                                       String[] paymentIds) {

    HashMap<String, String> searchCriteriaMap = new HashMap<>();
  
    searchCriteriaMap.put(BILLING_ACCOUNT_ID, billingAccountId);
    if (paymentIds != null) {
        searchCriteriaMap.put(PAYMENT_IDS, String.join(",", paymentIds));
    }

    return wrapperService.productFind(fields, searchCriteriaMap, Collections.emptyList());
}
**wrapperService**
 public MappingJacksonValue productFind(String fields, Map<String, String> searchCriteriaMap,
  List<String> contractNrList) {
List<Product> productsFromFind = productService.productFind(searchCriteriaMap, contractNrList);
return WrapperUtil.setWrapper(productsFromFind, WrapperUtil.searchCriteriaJsonPostFiltering(searchCriteriaMap),
    ProductServiceUtil.fieldsValuesValidation(fields));

}

mock wrapperService

yaml
description: Contract for retrieving a product by billingAccountId
request:
method: GET
url: /v1/product
queryParameters:
relatedParty.id: "3635318"
billingAccount.id: "138672149"
headers:
Content-Type: application/json
X-Client: test
X-Internal-Client: test
response:
status: 200
body:
- id: "co_68290814"
href: "/productInventoryManagement/v1/product/co_68290814"
isCustomerVisible: true
name: "766174030"
activated: "2024-10-04T11:44:05.000+02:00"
startDate: "2024-10-02T11:44:05.000+02:00"
status: "active"
"@type": "contract"
place:
- name: "-, null, 00000"
productOffering:
id: "7603"
"@referredType": "ProductOffering"
productRelationship:
- type: "product"
product:
id: "385662383"
billingAccount:
- id: "138672149"
relatedParty:
- id: "3635318"
role: "OWNER"
"@referredType": "INDIVIDUAL"

@mj967817
Copy link
Author

mj967817 commented Jan 6, 2025

hello @smh

@marcingrzejszczak
Copy link
Contributor

Can you please provide which version of sc contract you are using, what the concrete problem is and what's not working fine?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants