After you have finished this exercise, you understand how you can write a constant class that defines the structure of a database table. During this exercise you will write a constant class that defines the structure of the todo_item
table. The SQL script that creates the todo_item
table looks as follows:
CREATE TABLE todo_item( id bigserial NOT NULL, created_by_user_id bigint NOT NULL, creation_time timestamp with time zone NOT NULL DEFAULT now(), description text NOT NULL, modification_time timestamp with time zone NOT NULL DEFAULT now(), modified_by_user_id bigint NOT NULL, resolution text NOT NULL, status text NOT NULL, title text NOT NULL, version bigint NOT NULL DEFAULT 0 //Constraints are omitted on purpose );
You can create your constant class by following these steps:
1. Open the TodoItemTable
class that’s found from the com.cleantestautomation.assertjdb.todoitem
package.
2. Declare the constant that defines the name of the database table (todo_item
).
3. Declare the constants which define the column names.