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

While Creating Order, it should have all 3 values of orderItem as mandatory #519

Open
rajadilipkolli opened this issue Sep 18, 2023 · 0 comments
Labels

Comments

@rajadilipkolli
Copy link
Owner

rajadilipkolli commented Sep 18, 2023

Currently for creating a new Order we use below code,

public record OrderRequest(
        @Positive(message = "CustomerId should be positive") Long customerId,
        @NotEmpty(message = "Order without items not valid") List<OrderItemRequest> items) {}

we have validation set up at the Order (parent) level. However, we need to extend this validation to the OrderItem level (child) to ensure that all key attributes are properly validated.

Specifically, we need to enforce the following validation rules for OrderItemRequest:

  • Quantity should not be zero.
  • Price should not be zero.
  • A valid product code must be provided.

To implement this enhancement, the following tasks need to be completed:

  1. Modify OrderItemRequest.java : Add validation logic to the OrderItemRequest class to enforce the above-mentioned rules.
  2. Create a New JUnit : Develop a new test case in the OrderControllerIT.java class to demonstrate that the extended validation at the child level is functioning correctly. This test case should cover various scenarios to ensure thorough testing.
@rajadilipkolli rajadilipkolli changed the title While Creating Order had all 3 values for orderItem as mandatory While Creating Order, it should have all 3 values of orderItem as mandatory Oct 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant