In this lesson, we will address a typo in our code and move on to test our events.
Previously, there was a mistake where we used both findById
and update
.
We only need to use findById
and can remove the request body associated with the update, as updates can be done via events later.
Let's carry out some tests to ensure that our events are working correctly.
We start by creating a new company, which we'll call company test
.
We verify the creation by finding it with findById
and checking the list of companies.
Next, we initiate the initial shares release.
We increase the shares to 500 and verify the success of this operation.
To confirm, we retrieve a fresh list of companies to ensure the event was triggered correctly and the shares were indeed increased.
We then run the capitalization event to increase the shares further to 1000.
We check to ensure this event was also triggered correctly.
The shares should now be 500 with a capitalization of 1000.
We test a share split event by doubling the number of shares.
Running this event will increase the shares to 1000.
We confirm this change by retrieving the list of companies again.
At each stage, we check for errors and verify that the events have been triggered successfully.
The share purchase event is irrelevant for the current context, so it will not be demonstrated in this video.
Lastly, a simple front-end application will be showcased.
This app will retrieve the list of companies to demonstrate how it interacts with the existing REST API.