Further Improvement in Create and Update Commands Test Cases

I started off the week by adding more test cases for the Update command, observing the update logic in different scenarios. Found out there was a bug in the Update logic which was allowing the code to update the line items with Ids that were already taken before and also which did not yet exist. 

After some brainstorming I was finally able to fix the bug. I added a piece of code which acted as validation for Ids. It would throw an error if the LineItem Id that was provided was not present in that retail order.

Next, I got a new task to add a new field of Order No which was to be generated by a sequence generator. Purpose of adding this field was to give each order a distinguished identity, as we won’t be using their Ids as identification in actual business. Following this change I made changes to my Create command Handler so that now it creates a new sequence whenever an Order was created.

Now it was time to test my Create command which was modified with a new feature. I was able to successfully run 3 test cases, for the test cases I had to create a new Sequence Generator Id then pass it into the Create function which was then handled, by Create logic handler, and a OrderNo would be created. To test if my transaction which I added last week, I created a test case that would fail and observed if the transaction rolled back to the last savepoint.

Had a problem with validating the Sequence Generator Id as it was optional to input when there is no Id created, after discussing with my supervisor we came to the conclusion to not include a validation for the Sequence Generator.

Furthermore, I wrote test cases for Update command testing the Order No update and altered the DTO of Get query to output the Order No to the user.

Since a basic model of API was done, I was introduced to new tasks and features to make the API more robust.

Leave a Reply