Skip to content

Commit

Permalink
fix inventory check bug
Browse files Browse the repository at this point in the history
  • Loading branch information
tkeburia committed Dec 11, 2023
1 parent 04e1a3d commit f5f648a
Showing 1 changed file with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,17 @@ public String placeOrder(OrderRequest orderRequest) {
InventoryResponse[] inventoryResponsArray = webClientBuilder
.build()
.get()
.uri("http://inventory-service/api/inventory", uriBuilder -> uriBuilder.queryParam("skuCode", skuCodes)
.build())
.uri("http://localhost:9999/api/inventory", uriBuilder -> uriBuilder.queryParam("skuCode", skuCodes)
.build())
.retrieve()
.bodyToMono(InventoryResponse[].class)
.block();

boolean allProductsInStock = Arrays.stream(inventoryResponsArray)
.allMatch(InventoryResponse::isInStock);
.allMatch(InventoryResponse::isInStock) && inventoryResponsArray.length > 0;

System.out.println(Arrays.stream(inventoryResponsArray).toList());
System.out.println(allProductsInStock);

if (allProductsInStock) {
log.info("All requested products are in stock");
Expand Down

0 comments on commit f5f648a

Please sign in to comment.