Add Data Validation to the PUT /facilities/{id} Endpoint

Description

The implementation of PUT /facilities/{id} includes this line of code:

boolean addSuccessful = addSupportedProgramsToFacility(facilityDto.getSupportedPrograms(), facilityToSave);

This line fails when clients provide a request body which lacks an array of supportedPrograms. For example, this request body will cause a NullPointerException at the aforementioned line:

{
"id": "e6799d64-d10d-4011-b8c2-0e4d4a3f65ce",
"active": true
}

This ticket may be considered complete when the NullPointerException is no longer thrown. The "putShouldReturnBadRequestForNonExistentSupportedProgram" test suggests that a 400 error should instead be returned by throwing a ValidationMessageException with a key/message describing the validation exception.

Environment

None

QAlity Plus - Test Management

Checklists

Activity

Show:
Paulina Borowa
March 9, 2017 at 1:25 PM
(edited)

Now when I set supported program as null or an empty array I got appropriate message:

{ "messageKey": "referenceData.error.facility.supportedPrograms.required", "message": "Supported programs are required for a facility." }
Done
Pinned fields
Click on the next to a field label to start pinning.

Details

Assignee

Reporter

Story Points

Original estimate

Time tracking

3h 30m logged

Components

Sprint

None

Fix versions

Affects versions

Priority

Time Assistant

Created February 24, 2017 at 5:36 AM
Updated March 15, 2017 at 2:12 PM
Resolved March 9, 2017 at 1:26 PM