Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -59,5 +59,19 @@ public void CatchesAndReturnsNotFoundWhenUseCaseThrowsPropertyAlertNotFoundExcep
response.Value.Should().Be($"Property cautionary alert(s) for property reference {propertyReference} not found");
response.StatusCode.Should().Be(404);
}

[TestCase("")]
[TestCase(" ")]
[TestCase(null)]
public void ViewPropertyCautionaryAlertsWhenTagRefIsNullOrWhiteSpaceReturnsBadRequest(string tagRef)
{
// Arrange

// Act
var response = _classUnderTest.ViewPeopleCautionaryAlerts(tagRef, string.Empty) as BadRequestObjectResult;

// Assert
response.StatusCode.Should().Be(400);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,20 @@ public CautionaryAlertsApiController(IGetAlertsForPeople getAlertsForPeople, IGe
/// <param name="personNo">The number of the person you are interested in within a property. person_no in UH. e.g. 01</param>
/// <response code="200">Successful. One or more records found for given tag_ref and person_no</response>
/// <response code="404">No records found for given tag_ref and person_no</response>
/// <response code="400">Bad request - tag_ref cannot be null or whitespace</response>
[ProducesResponseType(typeof(ListPersonsCautionaryAlerts), StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status404NotFound)]
[ProducesResponseType(StatusCodes.Status400BadRequest)]
[HttpGet]
[Route("people")]
public IActionResult ViewPeopleCautionaryAlerts([FromQuery(Name = "tag_ref"), BindRequired] string tagRef,
[FromQuery(Name = "person_number")] string personNo)
{
if (string.IsNullOrWhiteSpace(tagRef))
{
return BadRequest($"Parameter {nameof(tagRef)} cannot be null or whitespace");
}

try
{
return Ok(_getAlertsForPeople.Execute(tagRef, personNo));
Expand Down