Exercise 4: Update the Information of an Existing Row

After you have finished this exercise, you understand how you can use custom assertion methods when you have to write integration tests for code that updates the information of an existing row. You can finish this exercise by following these steps:

1. Open the UpdateTodoItemTest class that’s found from the com.cleantestautomation.assertjdb.todoitem package.

2. Write the table and row level assertions which ensure that the system under test doesn’t make any changes to the data that’s found from the todo_item table when the updated todo item isn’t found from the database. You have to add these assertions to the test methods found from the WhenUpdatedTodoItemIsNotFound class. Remember to use the custom assertion methods which you wrote during the exercise 2.

3. Write the table level assertion which ensures that system under test doesn’t insert new todo items into the database or delete todo items from the database when the updated todo item is found from the database. You have to add this assertion to the shouldNotInsertNewTodoItemsIntoDatabaseOrDeleteTodoItemsFromDatabase() method of the WhenUpdatedTodoItemIsFound class.

4. Write the row level assertions which ensure that the system under test updates the description, title, modifier ID, modification time, and version of the ‘Read all lessons’ todo item when the updated todo item is found from the database. You have to add these assertions to the test methods found from the WhenUpdatedTodoItemIsFound class. Remember to use the custom assertion methods which you wrote during the exercise 1.

You can get the “current local date and time” by using the CURRENT_LOCAL_DATE_TIME constant that’s found from the ConstantDateTimeService class.

5. Write the row level assertions which ensure that the system under test doesn’t make any changes to the information of the ‘Finish all exercises’ todo item when the updated todo item is found from the database. You have to add these assertions to the shouldNotMakeAnyChangesToInformationOfFinishAllExercisesTodoItem() method that’s found from the WhenUpdatedTodoItemIsFound class. Use the custom assertion method which you wrote during the exercise 2.

6. Run the tests found from the UpdateTodoItemTest class class and make sure that they pass.