Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Thin Slice for Risk Categories #383

Merged
merged 15 commits into from
Mar 5, 2024
Prev Previous commit
Next Next commit
Changed Tests now that we switched to Nomis
  • Loading branch information
chiaramapellimt committed Mar 4, 2024
commit c5190a09e5775dd015f3210881720bc6737e86d7
Original file line number Diff line number Diff line change
@@ -32,15 +32,15 @@ class GetRiskCategoriesForPersonTest(
DescribeSpec(
{
val nomisApiMockServer = NomisApiMockServer()
val offenderNo = "A1234AA"
val offenderNo = "A7796DY"

beforeEach {
nomisApiMockServer.start()
nomisApiMockServer.stubGetRiskCategoriesForPerson(
offenderNo,
"""
{
"offenderNo": "A1234AA",
"offenderNo": "A7796DY",
"assessments": [
{
"classificationCode": "C"
Original file line number Diff line number Diff line change
@@ -30,10 +30,10 @@ internal class GetRiskCategoriesForPersonServiceTest(
) : DescribeSpec(
{
val hmppsId = "1234/56789B"
val deliusCrn = "X123456"
val nomisNumber = "A7796DY"

val personFromProbationOffenderSearch =
Person(firstName = "Phoebe", lastName = "Buffay", identifiers = Identifiers(deliusCrn = deliusCrn))
Person(firstName = "Phoebe", lastName = "Buffay", identifiers = Identifiers(nomisNumber = nomisNumber))

beforeEach {
Mockito.reset(getPersonService)
@@ -45,7 +45,7 @@ internal class GetRiskCategoriesForPersonServiceTest(
),
)

whenever(nomisGateway.getRiskCategoriesForPerson(deliusCrn)).thenReturn(Response(data = RiskCategory()))
whenever(nomisGateway.getRiskCategoriesForPerson(nomisNumber)).thenReturn(Response(data = RiskCategory()))
}

it("gets a person from getPersonService") {
@@ -54,16 +54,16 @@ internal class GetRiskCategoriesForPersonServiceTest(
verify(getPersonService, VerificationModeFactory.times(1)).execute(hmppsId = hmppsId)
}

it("gets a risk category for a person from ARN API using CRN") {
it("gets a risk category for a person from ARN API using Nomis") {
getRiskCategoriesForPersonService.execute(hmppsId)

verify(nomisGateway, VerificationModeFactory.times(1)).getRiskCategoriesForPerson(deliusCrn)
verify(nomisGateway, VerificationModeFactory.times(1)).getRiskCategoriesForPerson(nomisNumber)
}

it("returns a risk category for a person") {
val riskCategory = RiskCategory(offenderNo = "A1234AA", assessments = listOf(RiskAssessment(classificationCode = "987")))
val riskCategory = RiskCategory(offenderNo = "A7796DY", assessments = listOf(RiskAssessment(classificationCode = "987")))

whenever(nomisGateway.getRiskCategoriesForPerson(deliusCrn)).thenReturn(
whenever(nomisGateway.getRiskCategoriesForPerson(nomisNumber)).thenReturn(
Response(data = riskCategory),
)

@@ -74,9 +74,9 @@ internal class GetRiskCategoriesForPersonServiceTest(

describe("when an upstream API returns an error") {

it("returns error from ARN API when person/crn cannot be found in ARN") {
it("returns error from ARN API when person cannot be found in ARN") {

whenever(nomisGateway.getRiskCategoriesForPerson(deliusCrn)).thenReturn(
whenever(nomisGateway.getRiskCategoriesForPerson(nomisNumber)).thenReturn(
Response(
data = RiskCategory(),
errors = listOf(
Loading