Finish updating routers

Fixing a Typo in the REST API and Testing Events

In this lesson, we will address a typo in our code and move on to test our events.

Fixing the Typo

  • 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.

Testing the Events

Let's carry out some tests to ensure that our events are working correctly.

1. Creating a New Company

  • 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.

2. Initiating the Initial Shares Release

  • 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.

3. Running the Capitalization Event

  • 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.

4. Testing the Share Split Event

  • 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.

Validation

At each stage, we check for errors and verify that the events have been triggered successfully.

Irrelevant Event

  • The share purchase event is irrelevant for the current context, so it will not be demonstrated in this video.

Demonstrating the Front-End App

  • 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.