@@ -2,14 +2,18 @@ package uk.gov.justice.digital.hmpps.hmppsintegrationapi.controllers.v1.person
2
2
3
3
import io.kotest.core.spec.style.DescribeSpec
4
4
import io.kotest.matchers.shouldBe
5
+ import io.kotest.matchers.string.shouldContain
5
6
import org.mockito.Mockito
7
+ import org.mockito.internal.verification.VerificationModeFactory
8
+ import org.mockito.kotlin.verify
6
9
import org.mockito.kotlin.whenever
7
10
import org.springframework.beans.factory.annotation.Autowired
8
11
import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest
9
12
import org.springframework.boot.test.mock.mockito.MockBean
10
13
import org.springframework.http.HttpStatus
11
14
import org.springframework.test.context.ActiveProfiles
12
15
import org.springframework.test.web.servlet.MockMvc
16
+ import uk.gov.justice.digital.hmpps.hmppsintegrationapi.extensions.removeWhitespaceAndNewlines
13
17
import uk.gov.justice.digital.hmpps.hmppsintegrationapi.helpers.IntegrationAPIMockMvc
14
18
import uk.gov.justice.digital.hmpps.hmppsintegrationapi.models.hmpps.CommunityOffenderManager
15
19
import uk.gov.justice.digital.hmpps.hmppsintegrationapi.models.hmpps.PersonResponsibleOfficerName
@@ -75,6 +79,52 @@ internal class PersonResponsibleOfficerControllerTest(
75
79
76
80
result.response.status.shouldBe(HttpStatus .OK .value())
77
81
}
82
+
83
+ it(" gets the person responsible officer for a person with the matching ID" ) {
84
+ mockMvc.performAuthorised(path)
85
+ verify(getCommunityOffenderManagerForPersonService, VerificationModeFactory .times(1 )).execute(hmppsId)
86
+ }
87
+
88
+ it(" logs audit" ) {
89
+ mockMvc.performAuthorised(path)
90
+
91
+ verify(
92
+ auditService,
93
+ VerificationModeFactory .times(1 ),
94
+ ).createEvent(" GET_PERSON_RESPONSIBLE_OFFICER" , mapOf (" hmppsId" to hmppsId))
95
+ }
96
+
97
+ it(" returns the person responsible officer for a person with the matching ID" ) {
98
+ val result = mockMvc.performAuthorised(path)
99
+
100
+ result.response.contentAsString.shouldContain(
101
+ """
102
+ "data": {
103
+ "prisonOffenderManager": {
104
+ "forename": "Paul",
105
+ "surname": "Reds",
106
+ "prison": {
107
+ "code": "PrisonCode1"
108
+ }
109
+ },
110
+ "communityOffenderManager": {
111
+ "name": {
112
+ "forename": "Helen",
113
+ "surname": "Miller"
114
+ },
115
+ "email": "helenemail@email.com",
116
+ "telephoneNumber": "0987654321",
117
+ "team": {
118
+ "code": "PrisonCode2",
119
+ "description": "Description",
120
+ "email": "email_again@email.com",
121
+ "telephoneNumber": "01234567890"
122
+ }
123
+ }
124
+ }
125
+ """ .removeWhitespaceAndNewlines(),
126
+ )
127
+ }
78
128
}
79
129
}
80
130
}
0 commit comments