generated from ministryofjustice/template-repository
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b0e8e5a
commit c71c2b4
Showing
6 changed files
with
95 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,24 +4,45 @@ import uk.gov.justice.digital.hmpps.entity.Person | |
import uk.gov.justice.digital.hmpps.entity.PersonManager | ||
import uk.gov.justice.digital.hmpps.entity.Staff | ||
import uk.gov.justice.digital.hmpps.entity.Team | ||
import java.time.LocalDate | ||
|
||
object PersonGenerator { | ||
val DEFAULT = generate("X123123", "A1234YZ") | ||
val DEFAULT = generate( | ||
"X123123", | ||
"A1234YZ", | ||
"Fred", | ||
"Williams", | ||
LocalDate.of(1982, 8, 19), | ||
"020 346 7982", | ||
"07452819463", | ||
"[email protected]" | ||
) | ||
val DEFAULT_MANAGER = generateManager(DEFAULT) | ||
val CREATE_APPOINTMENT = generate("C123456") | ||
val CREATE_APPOINTMENT = generate("C123456", null, "James", "Brown", LocalDate.of(1990, 5, 12)) | ||
|
||
fun generate( | ||
crn: String, | ||
noms: String? = null, | ||
firstName: String, | ||
surname: String, | ||
dateOfBirth: LocalDate, | ||
telephoneNumber: String? = null, | ||
mobileNumber: String? = null, | ||
emailAddress: String? = null, | ||
softDeleted: Boolean = false, | ||
id: Long = IdGenerator.getAndIncrement() | ||
) = | ||
Person( | ||
id, | ||
crn, | ||
noms, | ||
softDeleted | ||
) | ||
) = Person( | ||
id, | ||
crn, | ||
noms, | ||
firstName, | ||
surname, | ||
dateOfBirth, | ||
telephoneNumber, | ||
mobileNumber, | ||
emailAddress, | ||
softDeleted | ||
) | ||
|
||
fun generateManager( | ||
person: Person, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,10 +10,7 @@ import org.springframework.boot.test.context.SpringBootTest | |
import org.springframework.test.web.servlet.MockMvc | ||
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get | ||
import org.springframework.test.web.servlet.result.MockMvcResultMatchers.status | ||
import uk.gov.justice.digital.hmpps.api.model.CaseIdentifiers | ||
import uk.gov.justice.digital.hmpps.api.model.Manager | ||
import uk.gov.justice.digital.hmpps.api.model.MappaDetail | ||
import uk.gov.justice.digital.hmpps.api.model.Name | ||
import uk.gov.justice.digital.hmpps.api.model.* | ||
import uk.gov.justice.digital.hmpps.data.generator.PersonGenerator | ||
import uk.gov.justice.digital.hmpps.data.generator.ProviderGenerator | ||
import uk.gov.justice.digital.hmpps.test.MockMvcExtensions.contentAsJson | ||
|
@@ -66,4 +63,24 @@ class CaseDetailIntegrationTests { | |
) | ||
assertFalse(manager.unallocated) | ||
} | ||
|
||
@Test | ||
fun `person detail is returned correctly`() { | ||
val detail = mockMvc.perform(get("/probation-cases/${PersonGenerator.DEFAULT.crn}").withToken()) | ||
.andExpect(status().is2xxSuccessful) | ||
.andReturn().response.contentAsJson<PersonDetail>() | ||
|
||
assertThat(detail.crn, equalTo(PersonGenerator.DEFAULT.crn)) | ||
assertThat(detail.name, equalTo(Name("Fred", "Williams"))) | ||
assertThat(detail.dateOfBirth, equalTo(LocalDate.of(1982, 8, 19))) | ||
assertThat( | ||
detail.contactDetails, equalTo( | ||
ContactDetails( | ||
"020 346 7982", | ||
"07452819463", | ||
"[email protected]" | ||
) | ||
) | ||
) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
...assport-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/api/model/PersonDetail.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package uk.gov.justice.digital.hmpps.api.model | ||
|
||
import java.time.LocalDate | ||
|
||
data class PersonDetail( | ||
val crn: String, | ||
val name: Name, | ||
val dateOfBirth: LocalDate, | ||
val contactDetails: ContactDetails? | ||
) | ||
|
||
data class ContactDetails(val telephone: String?, val mobile: String?, val email: String?) { | ||
companion object { | ||
fun of(telephone: String?, mobile: String?, email: String?): ContactDetails? = | ||
if (telephone == null && mobile == null && email == null) { | ||
null | ||
} else { | ||
ContactDetails(telephone, mobile, email) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters