Exercise 2: Specify the Test Data Found From the todo_item Table

After you have finished this exercise, you understand how you can write a constant class that defines the test data that’s found from a database table. During this exercise you will write a constant class that defines the test data that’s found from the todo_item table. The SQL script that insert the test data into the todo_item table looks as follows:

INSERT INTO todo_item (
    id,
    created_by_user_id,
    creation_time,
    description,
    modification_time,
    modified_by_user_id,
    resolution,
    status,
    title,
    version
)
VALUES (
    1,
    1,
    '2023-07-07 10:46:00+00',
    'Be diligent',
    '2023-07-07 10:46:00+00',
    2,
    null,
    'OPEN',
    'Read all lessons',
    0
);

INSERT INTO todo_item (
    id,
    created_by_user_id,
    creation_time,
    description,
    modification_time,
    modified_by_user_id,
    resolution,
    status,
    title,
    version
)
VALUES (
    2,
    1,
    '2023-07-07 12:46:00+00',
    'Do not use copy & paste',
    '2023-07-07 12:46:00+00',
    1,
    null,
    'OPEN',
    'Finish all exercises',
    0
);

You can create your constant class by following these steps:

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

2. Declare the constant that defines the default version (0L) of a new todo item.

3. Declare the constant that defines the expected row count.

4. Declare the constants which specify the column values of the database row which contains the information of the first todo item.

5. Declare the constants which specify the column values of the database row which contains the information of the second todo item.

When you declare the constants which specify the expected creation and modification times, you must use the static transformUTCDateTimeToLocalDateTime() method of the TestDateTimeBuilder class.