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

Bump io.swagger.parser.v3:swagger-parser-v3 from 2.1.21 to 2.1.22 #708

Merged
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
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ dependencies {
testImplementation("io.rest-assured:json-path")
testImplementation("io.rest-assured:xml-path")
testImplementation("io.rest-assured:spring-mock-mvc")
testImplementation("io.swagger.parser.v3:swagger-parser-v3:2.1.21")
testImplementation("io.swagger.parser.v3:swagger-parser-v3:2.1.22")
}

java {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ class OffenderSearchController(
)
@PreAuthorize("hasAnyRole('ROLE_COMMUNITY', 'ROLE_PROBATION__SEARCH_PERSON')")
@RequestMapping("/search", method = [POST, GET])
fun searchOffenders(@RequestBody searchForm: SearchDto): List<OffenderDetail?>? = searchService.performSearch(searchForm)
fun searchOffenders(@RequestBody searchForm: SearchDto): List<OffenderDetail?>? =
searchService.performSearch(searchForm)

@Operation(
summary = "Search for an offender in Delius using a search phrase. Only offenders matching all request attributes will be returned",
Expand Down Expand Up @@ -123,8 +124,16 @@ class OffenderSearchController(
@ApiResponses(
value = [
ApiResponse(responseCode = "200", description = "OK"),
ApiResponse(responseCode = "401", description = "Unauthorised, requires a valid Oauth2 token", content = [Content(examples = [])]),
ApiResponse(responseCode = "403", description = "Forbidden, requires an authorisation with role ROLE_PROBATION__SEARCH_PERSON", content = [Content(examples = [])]),
ApiResponse(
responseCode = "401",
description = "Unauthorised, requires a valid Oauth2 token",
content = [Content(examples = [])]
),
ApiResponse(
responseCode = "403",
description = "Forbidden, requires an authorisation with role ROLE_PROBATION__SEARCH_PERSON",
content = [Content(examples = [])]
),
],
)
@PostMapping("/phrase")
Expand All @@ -143,9 +152,21 @@ class OffenderSearchController(
@ApiResponses(
value = [
ApiResponse(responseCode = "200", description = "OK"),
ApiResponse(responseCode = "401", description = "Unauthorised, requires a valid Oauth2 token", content = [Content(examples = [])]),
ApiResponse(responseCode = "403", description = "Forbidden, requires an authorisation with role ROLE_PROBATION__SEARCH_PERSON", content = [Content(examples = [])]),
ApiResponse(responseCode = "500", description = "The list of CRNs provided exceeds the maximum of 512", content = [Content(examples = [])]),
ApiResponse(
responseCode = "401",
description = "Unauthorised, requires a valid Oauth2 token",
content = [Content(examples = [])]
),
ApiResponse(
responseCode = "403",
description = "Forbidden, requires an authorisation with role ROLE_PROBATION__SEARCH_PERSON",
content = [Content(examples = [])]
),
ApiResponse(
responseCode = "500",
description = "The list of CRNs provided exceeds the maximum of 512",
content = [Content(examples = [])]
),
],
)
@PostMapping("/crns")
Expand All @@ -169,12 +190,23 @@ class OffenderSearchController(
@ApiResponses(
value = [
ApiResponse(responseCode = "200", description = "OK"),
ApiResponse(responseCode = "401", description = "Unauthorised, requires a valid Oauth2 token", content = [Content(examples = [])]),
ApiResponse(responseCode = "403", description = "Forbidden, requires an authorisation with role ROLE_PROBATION__SEARCH_PERSON", content = [Content(examples = [])]),
ApiResponse(
responseCode = "401",
description = "Unauthorised, requires a valid Oauth2 token",
content = [Content(examples = [])]
),
ApiResponse(
responseCode = "403",
description = "Forbidden, requires an authorisation with role ROLE_PROBATION__SEARCH_PERSON",
content = [Content(examples = [])]
),
],
)
@PostMapping("/nomsNumbers")
@Operation(description = "Match prisoners by a list of prisoner noms numbers", summary = "Requires ROLE_PROBATION__SEARCH_PERSON role")
@Operation(
description = "Match prisoners by a list of prisoner noms numbers",
summary = "Requires ROLE_PROBATION__SEARCH_PERSON role"
)
fun findByNomsNumbers(
@Parameter(required = true, name = "nomsList") @RequestBody nomsList: List<String>,
): List<OffenderDetail> {
Expand All @@ -185,8 +217,16 @@ class OffenderSearchController(
@ApiResponses(
value = [
ApiResponse(responseCode = "200", description = "OK"),
ApiResponse(responseCode = "401", description = "Unauthorised, requires a valid Oauth2 token", content = [Content(examples = [])]),
ApiResponse(responseCode = "403", description = "Forbidden, requires an authorisation with role ROLE_PROBATION__SEARCH_PERSON", content = [Content(examples = [])]),
ApiResponse(
responseCode = "401",
description = "Unauthorised, requires a valid Oauth2 token",
content = [Content(examples = [])]
),
ApiResponse(
responseCode = "403",
description = "Forbidden, requires an authorisation with role ROLE_PROBATION__SEARCH_PERSON",
content = [Content(examples = [])]
),
],
)
@PostMapping("/ldu-codes")
Expand All @@ -202,7 +242,10 @@ class OffenderSearchController(
example = "10",
),
)
@Operation(summary = "Match prisoners by a list of ldu codes", description = "Requires ROLE_PROBATION__SEARCH_PERSON role")
@Operation(
summary = "Match prisoners by a list of ldu codes",
description = "Requires ROLE_PROBATION__SEARCH_PERSON role"
)
fun findByLduCode(
@Parameter(required = true, name = "lduList")
@RequestBody
Expand All @@ -218,8 +261,16 @@ class OffenderSearchController(
@ApiResponses(
value = [
ApiResponse(responseCode = "200", description = "OK"),
ApiResponse(responseCode = "401", description = "Unauthorised, requires a valid Oauth2 token", content = [Content(examples = [])]),
ApiResponse(responseCode = "403", description = "Forbidden, requires an authorisation with role ROLE_PROBATION__SEARCH_PERSON", content = [Content(examples = [])]),
ApiResponse(
responseCode = "401",
description = "Unauthorised, requires a valid Oauth2 token",
content = [Content(examples = [])]
),
ApiResponse(
responseCode = "403",
description = "Forbidden, requires an authorisation with role ROLE_PROBATION__SEARCH_PERSON",
content = [Content(examples = [])]
),
],
)
@PostMapping("/team-codes")
Expand All @@ -235,7 +286,10 @@ class OffenderSearchController(
example = "10",
),
)
@Operation(description = "Match prisoners by a list of team codes", summary = "Requires ROLE_PROBATION__SEARCH_PERSON role")
@Operation(
description = "Match prisoners by a list of team codes",
summary = "Requires ROLE_PROBATION__SEARCH_PERSON role"
)
fun findByTeamCode(
@Parameter(required = true, name = "teamCodeList")
@ParameterObject
Expand All @@ -261,8 +315,16 @@ class OffenderSearchController(
content = [Content(examples = [])],
),
ApiResponse(responseCode = "404", description = "Not found", content = [Content(examples = [])]),
ApiResponse(responseCode = "401", description = "Unauthorised, requires a valid Oauth2 token", content = [Content(examples = [])]),
ApiResponse(responseCode = "403", description = "Forbidden, requires an authorisation with role ROLE_PROBATION__SEARCH_PERSON", content = [Content(examples = [])]),
ApiResponse(
responseCode = "401",
description = "Unauthorised, requires a valid Oauth2 token",
content = [Content(examples = [])]
),
ApiResponse(
responseCode = "403",
description = "Forbidden, requires an authorisation with role ROLE_PROBATION__SEARCH_PERSON",
content = [Content(examples = [])]
),
],
)
@GetMapping("/ldu-codes/{lduCode}")
Expand All @@ -286,8 +348,16 @@ class OffenderSearchController(
content = [Content(examples = [])],
),
ApiResponse(responseCode = "404", description = "Not found", content = [Content(examples = [])]),
ApiResponse(responseCode = "401", description = "Unauthorised, requires a valid Oauth2 token", content = [Content(examples = [])]),
ApiResponse(responseCode = "403", description = "Forbidden, requires an authorisation with role ROLE_PROBATION__SEARCH_PERSON", content = [Content(examples = [])]),
ApiResponse(
responseCode = "401",
description = "Unauthorised, requires a valid Oauth2 token",
content = [Content(examples = [])]
),
ApiResponse(
responseCode = "403",
description = "Forbidden, requires an authorisation with role ROLE_PROBATION__SEARCH_PERSON",
content = [Content(examples = [])]
),
],
)
@GetMapping("/team-codes/{teamCode}")
Expand All @@ -302,6 +372,10 @@ class OffenderSearchController(
val start = System.currentTimeMillis()
val results = searchService.performSearch(SearchDto(surname = "Smith"))

telemetryClient.trackEvent("synthetic-monitor", mapOf("results" to "${results.size}", "timeMs" to (System.currentTimeMillis() - start).toString()), null)
telemetryClient.trackEvent(
"synthetic-monitor",
mapOf("results" to "${results.size}", "timeMs" to (System.currentTimeMillis() - start).toString()),
null
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,14 @@ data class ErrorResponse(
@Schema(required = false, description = "Developer Information message", example = "System is down")
val developerMessage: String? = null,
@Schema(required = true, description = "Internal Error Code", example = "20012") val errorCode: Int? = null,
@Schema(required = true, description = "Error message information", example = "Offender Not Found") val userMessage: String? = null,
@Schema(required = false, description = "Additional information about the error", example = "Hard disk failure") val moreInfo: String? = null,
@Schema(
required = true,
description = "Error message information",
example = "Offender Not Found"
) val userMessage: String? = null,
@Schema(
required = false,
description = "Additional information about the error",
example = "Hard disk failure"
) val moreInfo: String? = null,
)
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,17 @@ data class MatchRequest(
@field:Past(message = "Date of birth must be in the past")
@Schema(description = "Offender date of birth", example = "1996-02-10")
val dateOfBirth: LocalDate? = null,
@Schema(description = "Police National Computer (PNC) number", example = "2018/0123456X") val pncNumber: String? = null,
@Schema(
description = "Police National Computer (PNC) number",
example = "2018/0123456X"
) val pncNumber: String? = null,
@Schema(description = "Criminal Records Office (CRO) number", example = "SF80/655108T") val croNumber: String? = null,
@Schema(description = "The Offender NOMIS Id (aka prison number/offender no in DPS)", example = "G5555TT") val nomsNumber: String? = null,
@Schema(description = "Filter so only offenders on a current sentence managed by probation will be returned", example = "true") val activeSentence: Boolean = false,
@Schema(
description = "The Offender NOMIS Id (aka prison number/offender no in DPS)",
example = "G5555TT"
) val nomsNumber: String? = null,
@Schema(
description = "Filter so only offenders on a current sentence managed by probation will be returned",
example = "true"
) val activeSentence: Boolean = false,
)
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@ data class OffenderDetail(
val restrictionMessage: String? = null,
val currentExclusion: Boolean? = null,
val exclusionMessage: String? = null,
@Schema(description = "map of fields which matched a search term (Only return for phrase searching)", example = "{\"surname\": [\"Smith\"], \"offenderAliases.surname\": [\"SMITH\"]}")
@Schema(
description = "map of fields which matched a search term (Only return for phrase searching)",
example = "{\"surname\": [\"Smith\"], \"offenderAliases.surname\": [\"SMITH\"]}"
)
val highlight: Map<String, List<String>>? = null,
val accessDenied: Boolean? = null,
val currentTier: String? = null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ data class SearchDto(
) {
@get:Schema(hidden = true)
val isValid: Boolean
get() = StringUtils.isNotBlank(firstName) || StringUtils.isNotBlank(surname) || dateOfBirth != null || StringUtils.isNotBlank(pncNumber) || StringUtils.isNotBlank(crn) ||
get() = StringUtils.isNotBlank(firstName) || StringUtils.isNotBlank(surname) || dateOfBirth != null || StringUtils.isNotBlank(
pncNumber
) || StringUtils.isNotBlank(crn) ||
StringUtils.isNotBlank(nomsNumber) || StringUtils.isNotBlank(croNumber)
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@ data class SearchPhraseFilter(
@field:NotBlank(message = "phrase must be supplied")
@Schema(required = true, description = "Phrase containing the terms to search for", example = "john smith 19/07/1965")
val phrase: String = "",
@Schema(required = false, description = "When true, only match offenders that match all terms. Analogous to AND versus OR") val matchAllTerms: Boolean = false,
@Schema(required = false, description = "Filter of probation area codes. Only offenders that have an active offender manager in one of the areas will be returned", example = "[\"N01\",\"N02\"]") val probationAreasFilter: List<String> = listOf(),
@Schema(
required = false,
description = "When true, only match offenders that match all terms. Analogous to AND versus OR"
) val matchAllTerms: Boolean = false,
@Schema(
required = false,
description = "Filter of probation area codes. Only offenders that have an active offender manager in one of the areas will be returned",
example = "[\"N01\",\"N02\"]"
) val probationAreasFilter: List<String> = listOf(),
)
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@ import io.swagger.v3.oas.annotations.media.Schema
data class Team(
@Schema(description = "Team code", example = "C01T04") val code: String? = null,
@Schema(description = "Team description", example = "OMU A") val description: String? = null,
@Schema(description = "Team telephone, often not populated", required = false, example = "OMU A") val telephone: String? = null,
@Schema(
description = "Team telephone, often not populated",
required = false,
example = "OMU A"
) val telephone: String? = null,
@Schema(description = "Local Delivery Unit - LDU") val localDeliveryUnit: KeyValue? = null,
@Schema(description = "Team's district") val district: KeyValue? = null,
@Schema(description = "Team's borough") val borough: KeyValue? = null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,19 @@ abstract class HealthCheck(private val webClient: WebClient, private val timeout
.retrieve()
.toEntity(String::class.java)
.flatMap { Mono.just(Health.up().withDetail("HttpStatus", it?.statusCode).build()) }
.onErrorResume(WebClientResponseException::class.java) { Mono.just(Health.down(it).withDetail("body", it.responseBodyAsString).withDetail("HttpStatus", it.statusCode).build()) }
.onErrorResume(WebClientResponseException::class.java) {
Mono.just(
Health.down(it).withDetail("body", it.responseBodyAsString).withDetail("HttpStatus", it.statusCode).build()
)
}
.onErrorResume(Exception::class.java) { Mono.just(Health.down(it).build()) }
.block(timeout)
}
}

@Component
class CommunityApiHealth
constructor(@Qualifier("communityApiHealthWebClient") webClient: WebClient, @Value("\${api.health-timeout:2s}") timeout: Duration) : HealthCheck(webClient, timeout)
constructor(
@Qualifier("communityApiHealthWebClient") webClient: WebClient,
@Value("\${api.health-timeout:2s}") timeout: Duration
) : HealthCheck(webClient, timeout)
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ import org.springframework.security.oauth2.server.resource.authentication.JwtAut
import org.springframework.security.oauth2.server.resource.authentication.JwtGrantedAuthoritiesConverter

class AuthAwareTokenConverter : Converter<Jwt, AbstractAuthenticationToken> {
private val jwtGrantedAuthoritiesConverter: Converter<Jwt, Collection<GrantedAuthority>> = JwtGrantedAuthoritiesConverter()
private val jwtGrantedAuthoritiesConverter: Converter<Jwt, Collection<GrantedAuthority>> =
JwtGrantedAuthoritiesConverter()

override fun convert(jwt: Jwt): AbstractAuthenticationToken {
return AuthAwareAuthenticationToken(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@ import org.springframework.stereotype.Service
class SearchClient(
@param:Qualifier("openSearchClient") private val openSearchClient: RestHighLevelClient,
) {
fun search(searchRequest: SearchRequest): SearchResponse = openSearchClient.search(searchRequest, RequestOptions.DEFAULT)
fun search(searchRequest: SearchRequest): SearchResponse =
openSearchClient.search(searchRequest, RequestOptions.DEFAULT)
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@ internal fun buildHighlightRequest() = HighlightBuilder()
.preTags("")
.postTags("")

internal fun OffenderDetail.mergeHighlights(highlightFields: Map<String, HighlightField>, phrase: String): OffenderDetail =
internal fun OffenderDetail.mergeHighlights(
highlightFields: Map<String, HighlightField>,
phrase: String
): OffenderDetail =
this.copy(highlight = extractHighlights(highlightFields) + possibleDateOfBirthHighlight(phrase))

private fun OffenderDetail.possibleDateOfBirthHighlight(phrase: String): Map<String, List<String>> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,14 @@ abstract class ElasticIntegrationBase {
it.offenderManagers.find { replacement -> replacement.active == offenderManager.active }
.let { matchingReplacement ->
offenderManager.copy(
probationArea = ProbationArea(code = matchingReplacement?.code, description = matchingReplacement?.description),
team = Team(code = matchingReplacement?.team?.code, localDeliveryUnit = matchingReplacement?.team?.localDeliveryUnit),
probationArea = ProbationArea(
code = matchingReplacement?.code,
description = matchingReplacement?.description
),
team = Team(
code = matchingReplacement?.team?.code,
localDeliveryUnit = matchingReplacement?.team?.localDeliveryUnit
),
softDeleted = matchingReplacement?.softDeleted,
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1097,7 +1097,13 @@ class OffenderSearchPhraseAPIIntegrationTest : ElasticIntegrationBase() {
OffenderReplacement(
crn = "X00006",
surname = "Gramsci",
offenderManagers = listOf(OffenderManagerReplacement(code = "N07", description = "NPS London", active = true)),
offenderManagers = listOf(
OffenderManagerReplacement(
code = "N07",
description = "NPS London",
active = true
)
),
),
OffenderReplacement(
crn = "X00007",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,8 @@ class ProbationStatusIntegrationTest : ElasticIntegrationBase() {
assertThatJson(response).node("matches[0].offender.probationStatus.inBreach").isEqualTo(true)
assertThatJson(response).node("matches[0].offender.probationStatus.awaitingPsr").isEqualTo(true)
assertThatJson(response).node("matches[0].offender.probationStatus.preSentenceActivity").isEqualTo(false)
assertThatJson(response).node("matches[0].offender.probationStatus.previouslyKnownTerminationDate").isEqualTo("2021-02-08")
assertThatJson(response).node("matches[0].offender.probationStatus.previouslyKnownTerminationDate")
.isEqualTo("2021-02-08")
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,13 @@ internal class OffenderDetailTest {
@Test
fun `age is calculated from date of birth`() {
val expectedAge = LocalDate.now().year - 2000
assertThat(OffenderDetail(otherIds = IDs("1234"), offenderId = 99, dateOfBirth = LocalDate.parse("2000-01-01")).age).isEqualTo(expectedAge)
assertThat(
OffenderDetail(
otherIds = IDs("1234"),
offenderId = 99,
dateOfBirth = LocalDate.parse("2000-01-01")
).age
).isEqualTo(expectedAge)
}

@Test
Expand Down
Loading