This exercise is designed to evaluate your understanding of Java, SQL, code organization, and RESTful API design concepts.
- Java 21
- PostgreSQL 15
- Create a
tax_forms_dev
database. - Copy application-example.properties to
application-dev.properties
in thesrc/main/resources
directory. - Create a run configuration for the IDE of your choosing(IntelliJ, Eclipse, etc.).
This application sample is the API portion of a form workflow application for users to fill out tax form information and submit to a separate reviewing user group which may either return the submitted form information to the user, or accept the form.
Authentication, authorization, and users are outside the scope of the exercise.
One entity and table is provided: TaxForm
See src/main/java/consulting/reason/taxformsexample/entity/TaxForm.java.
This entity has the following columns:
id
- Integer and primary keyform_year
- Integerform_name
- Stringstatus
- Enum, one of'NOT_STARTED'
,'IN_PROGRESS'
,'SUBMITTED'
,'RETURNED'
, or'ACCEPTED'
. The initial status of a form is'NOT_STARTED'
details
- JSONB, represents a JSON object used for storing inputted information from a UIcreated_at
- ZonedDateTimeupdated_at
- ZonedDateTime
There are 3 provided endpoints implemented:
GET /forms?year=:year
Lists all forms by yearGET /forms/:id
Return a single form by id
- If a form with the provided id does not exist, a 404 response is returned
PATCH /forms/:id
Saves the form by id and updating thedetails
column of the record
- If a form with the provided id does not exist, a 404 response is returned
- If a form status is
'NOT_STARTED'
, the form status is updated to'IN_PROGRESS'
- If a form status is
'SUBMITTED'
or'ACCEPTED'
the request fails and an exception is returned
An Insomnia REST client JSON file is included with the exercise TaxForms_Insomnia.json
to help facilitate development.
5 assessment tasks are provided targeted towards adding features to an existing application. Tasks 4 and 5 are entirely optional.
-
Add the following validation constraints to the
TaxFormDetailsRequest
class used as the request body in thePATCH /forms/:id
endpoint:assessedValue
: Required; Must be in between 0 and 100,000appraisedValue
: Not Required; Must be in between 0 and 100,000ratio
: Required; Must be in between 0 and 1comments
: Not required; Max length of 500 characters
-
Add relevant tests to
TaxFormControllerTest
-
Add relevant tests to
TaxFormServiceTest
-
Create a new database table
tax_form_histories
andEntity
TaxFormHistory
.- The entity should have a
ManyToOne
relationship to aTaxForm
record and contain the following fields: taxFormId
createdAt
type
- One of'SUBMITTED'
,'RETURNED'
, or'ACCEPTED'
- The entity should have a
-
Create a new DTO class for the new
TaxFormHistory
entity and add a new variable toTaxFormDto
containing a list of the new DTO objects.
Reference ModelMapperConfig
on how to map the entity instance to a DTO instance.
- Add relevant tests to
TaxFormServiceTest
- Update
TaxFormStatusUtils
to handle the status change toSUBMITTED
using the provided status workflow diagram as a reference - Create a new endpoint in
TaxFormController
that acceptsid
as a path variable.- Endpoint must update a
TaxForm
record status toSUBMITTED
if permitted. - Endpoint must create a new
TaxFormHistory
record for the respectiveTaxForm
record with a type ofSUBMITTED
- If a form with the provided
id
does not exist, a 404 response should be returned. - If the status change is not permitted or does not follow the status workflow, throw an exception similar to the save endpoint.
- Endpoint must update a
- Add relevant tests to
TaxFormControllerTest
- Add relevant tests to
TaxFormServiceTest
- Add relevant tests to
TaxFormStatusUtilsTest
- Update
TaxFormStatusUtils
to handle the status change toRETURNED
using the provided status workflow diagram as a reference - Create a new endpoint in
TaxFormController
that acceptsid
as a path variable.- Endpoint must update a
TaxForm
record status toRETURNED
if permitted. - Endpoint must create a new
TaxFormHistory
record for the respectiveTaxForm
record with a type ofRETURNED
- If a form with the provided
id
does not exist, a 404 response should be returned. - If the status change is not permitted or does not follow the status workflow, throw an exception similar to the save endpoint
- Endpoint must update a
- Add relevant tests to
TaxFormControllerTest
- Add relevant tests to
TaxFormServiceTest
- Add relevant tests to
TaxFormStatusUtilsTest
- Update
TaxFormStatusUtils
to handle the status change toACCEPTED
using the provided status workflow diagram as a reference - Create a new endpoint in
TaxFormController
that acceptsid
as a path variable.- Endpoint must update a
TaxForm
record's status toACCEPTED
if permitted. - Endpoint must create a new
TaxFormHistory
record for the respectiveTaxForm
record with a type ofACCEPTED
- If a form with the provided
id
does not exist, a 404 response should be returned. - If the status change is not permitted or does not follow the status workflow, throw an exception similar to the save endpoint
- Endpoint must update a
- Add relevant tests to
TaxFormControllerTest
- Add relevant tests to
TaxFormServiceTest
- Add relevant tests to
TaxFormStatusUtilsTest
Reference the provided workflow diagram to validate the status changes for the above tasks.