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.
Browse files
Browse the repository at this point in the history
* PI-2400: Sent reports without values to app insights
- Loading branch information
Showing
16 changed files
with
370 additions
and
203 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 |
---|---|---|
|
@@ -20,6 +20,7 @@ import uk.gov.justice.digital.hmpps.data.generator.ReferenceDataGenerator.RELIGI | |
import uk.gov.justice.digital.hmpps.data.generator.ReferenceDataGenerator.SECOND_NATIONALITY | ||
import uk.gov.justice.digital.hmpps.data.generator.ReferenceDataGenerator.SEXUAL_ORIENTATION | ||
import uk.gov.justice.digital.hmpps.data.generator.ReferenceDataGenerator.TITLE | ||
import uk.gov.justice.digital.hmpps.integrations.delius.entity.ReferenceData | ||
import uk.gov.justice.digital.hmpps.integrations.delius.person.entity.* | ||
import java.time.LocalDate | ||
import java.time.ZonedDateTime | ||
|
@@ -56,25 +57,32 @@ object PersonGenerator { | |
id: Long = IdGenerator.getAndIncrement(), | ||
currentDisposal: Boolean = false, | ||
currentExclusion: Boolean = false, | ||
currentRestriction: Boolean = false | ||
currentRestriction: Boolean = false, | ||
emailAddress: String? = "[email protected]", | ||
secondName: String? = "MiddleName", | ||
thirdName: String? = "OtherMiddleName", | ||
mobileNumber: String? = "07876545678", | ||
telephoneNumber: String? = "0161786567", | ||
title: ReferenceData? = TITLE, | ||
currentTier: ReferenceData? = DEFAULT_TIER | ||
) = | ||
Person( | ||
id = id, | ||
crn = crn, | ||
softDeleted = softDeleted, | ||
emailAddress = "[email protected]", | ||
emailAddress = emailAddress, | ||
currentDisposal = currentDisposal, | ||
currentExclusion = currentExclusion, | ||
currentRestriction = currentRestriction, | ||
currentHighestRiskColour = "RED", | ||
dateOfBirth = LocalDate.of(1977, 8, 12), | ||
partitionArea = PARTITION_AREA, | ||
allowSms = true, | ||
mobileNumber = "07876545678", | ||
telephoneNumber = "0161786567", | ||
mobileNumber = mobileNumber, | ||
telephoneNumber = telephoneNumber, | ||
forename = "TestForename", | ||
secondName = "MiddleName", | ||
thirdName = "OtherMiddleName", | ||
secondName = secondName, | ||
thirdName = thirdName, | ||
gender = GENDER_MALE, | ||
surname = "TestSurname", | ||
preferredName = "Other name", | ||
|
@@ -98,11 +106,11 @@ object PersonGenerator { | |
immigrationNumber = "IMA123", | ||
mostRecentPrisonerNumber = "PRS123", | ||
previousSurname = "Previous", | ||
title = TITLE, | ||
title = title, | ||
offenderManagers = emptyList(), | ||
restrictionMessage = "restrictionMessage", | ||
exclusionMessage = "exclusionMessage", | ||
currentTier = DEFAULT_TIER | ||
currentTier = currentTier | ||
) | ||
|
||
fun generatePrisonManager(person: Person) = PrisonManager( | ||
|
@@ -139,14 +147,14 @@ object PersonGenerator { | |
providerEmployee = ProviderEmployeeGenerator.PROVIDER_EMPLOYEE | ||
) | ||
|
||
fun generatePersonAlias(person: Person) = | ||
fun generatePersonAlias(person: Person, secondName: String? = "Reg", thirdName: String? = "Xavier") = | ||
OffenderAlias( | ||
aliasID = IdGenerator.getAndIncrement(), | ||
personId = person.id, | ||
dateOfBirth = LocalDate.of(1968, 1, 1), | ||
firstName = "Bob", | ||
secondName = "Reg", | ||
thirdName = "Xavier", | ||
secondName = secondName, | ||
thirdName = thirdName, | ||
surname = "Potts", | ||
gender = GENDER_MALE, | ||
softDeleted = false | ||
|
@@ -174,24 +182,25 @@ object PersonGenerator { | |
finishDate = end, | ||
) | ||
|
||
fun generateAddress(personId: Long, softDeleted: Boolean) = PersonAddress( | ||
id = IdGenerator.getAndIncrement(), | ||
personId = personId, | ||
type = DEFAULT_ADDRESS_TYPE, | ||
status = DEFAULT_ADDRESS_STATUS, | ||
streetName = "A Street", | ||
town = "A town", | ||
county = "A county", | ||
postcode = "NE209XL", | ||
telephoneNumber = "089876765", | ||
buildingName = "The building", | ||
district = "A District", | ||
addressNumber = "20", | ||
noFixedAbode = false, | ||
typeVerified = true, | ||
startDate = LocalDate.now().minusDays(1), | ||
endDate = null, | ||
softDeleted = softDeleted, | ||
createdDatetime = ZonedDateTime.now().minusDays(1), | ||
) | ||
fun generateAddress(personId: Long, softDeleted: Boolean, type: ReferenceData? = DEFAULT_ADDRESS_TYPE) = | ||
PersonAddress( | ||
id = IdGenerator.getAndIncrement(), | ||
personId = personId, | ||
type = type, | ||
status = DEFAULT_ADDRESS_STATUS, | ||
streetName = "A Street", | ||
town = "A town", | ||
county = "A county", | ||
postcode = "NE209XL", | ||
telephoneNumber = "089876765", | ||
buildingName = "The building", | ||
district = "A District", | ||
addressNumber = "20", | ||
noFixedAbode = false, | ||
typeVerified = true, | ||
startDate = LocalDate.now().minusDays(1), | ||
endDate = null, | ||
softDeleted = softDeleted, | ||
createdDatetime = ZonedDateTime.now().minusDays(1), | ||
) | ||
} |
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
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 |
---|---|---|
|
@@ -2,17 +2,22 @@ package uk.gov.justice.digital.hmpps | |
|
||
import org.junit.jupiter.api.BeforeEach | ||
import org.junit.jupiter.api.Test | ||
import org.mockito.kotlin.any | ||
import org.mockito.kotlin.eq | ||
import org.mockito.kotlin.verify | ||
import org.mockito.kotlin.whenever | ||
import org.springframework.beans.factory.annotation.Autowired | ||
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc | ||
import org.springframework.boot.test.context.SpringBootTest | ||
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT | ||
import org.springframework.boot.test.mock.mockito.MockBean | ||
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor | ||
import org.springframework.test.web.servlet.MockMvc | ||
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get | ||
import org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath | ||
import org.springframework.test.web.servlet.result.MockMvcResultMatchers.status | ||
import uk.gov.justice.digital.hmpps.flags.FeatureFlags | ||
import uk.gov.justice.digital.hmpps.telemetry.TelemetryService | ||
import uk.gov.justice.digital.hmpps.test.MockMvcExtensions.withToken | ||
|
||
@AutoConfigureMockMvc | ||
|
@@ -21,9 +26,15 @@ internal class ProxyToNewIntegrationTest { | |
@Autowired | ||
lateinit var mockMvc: MockMvc | ||
|
||
@Autowired | ||
lateinit var taskExecutor: ThreadPoolTaskExecutor | ||
|
||
@MockBean | ||
lateinit var featureFlags: FeatureFlags | ||
|
||
@MockBean | ||
lateinit var telemetryService: TelemetryService | ||
|
||
@BeforeEach | ||
fun setup() { | ||
whenever(featureFlags.enabled("ccd-offender-detail-enabled")).thenReturn(true) | ||
|
@@ -32,10 +43,14 @@ internal class ProxyToNewIntegrationTest { | |
|
||
@Test | ||
fun `proxies to community api for offenders all`() { | ||
|
||
mockMvc | ||
.perform(get("/secure/offenders/crn/C123456/all").withToken()) | ||
.andExpect(status().is2xxSuccessful) | ||
.andExpect(jsonPath("$.otherIds.crn").value("C123456")) | ||
|
||
whileTrue { taskExecutor.threadPoolExecutor.completedTaskCount == 0L } | ||
verify(telemetryService).trackEvent(eq("ComparisonFailureEvent"), any(), any()) | ||
} | ||
|
||
@Test | ||
|
@@ -45,4 +60,8 @@ internal class ProxyToNewIntegrationTest { | |
.andExpect(status().is2xxSuccessful) | ||
.andExpect(jsonPath("$.contactDetails.emailAddresses[0]").value("[email protected]")) | ||
} | ||
|
||
private fun whileTrue(action: () -> Boolean) { | ||
while (action.invoke()); | ||
} | ||
} |
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
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
Oops, something went wrong.