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

Revert "NN-5365: get adjudication data from AdjudicationsAPI instead of PrisonAPI (#240)" #243

Merged
merged 1 commit into from
Aug 14, 2023
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
1 change: 0 additions & 1 deletion .env-local-wiremock
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ USE_OF_FORCE_UI_URL=http://localhost:9091/implement-wiremock-rule-if-required
MANAGE_A_WARRANT_FOLDER_UI_URL=http://localhost:9091/implement-wiremock-rule-if-required
PATHFINDER_UI_URL=http://localhost:9091/implement-wiremock-rule-if-required
MANAGE_SOC_CASES_UI_URL=http://localhost:9091/implement-wiremock-rule-if-required
MANAGE_ADJUDICATIONS_API_URL=http://localhost:9091/implement-wiremock-rule-if-required
TOKEN_VERIFICATION_ENABLED=false
NODE_ENV=development
API_CLIENT_ID=hmpps-prisoner-profile
Expand Down
2 changes: 0 additions & 2 deletions cypress.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import caseNotesApi from './integration_tests/mockApis/caseNotesApi'
import incentivesMockApi from './integration_tests/mockApis/incentivesMockApi'
import pathfinderApi from './integration_tests/mockApis/pathfinderApi'
import socApi from './integration_tests/mockApis/socApi'
import adjudicationsApi from './integration_tests/mockApis/adjudications'

export default defineConfig({
viewportWidth: 1152,
Expand Down Expand Up @@ -46,7 +45,6 @@ export default defineConfig({
...incentivesMockApi,
...pathfinderApi,
...socApi,
...adjudicationsApi,
})
},
baseUrl: 'http://localhost:3007',
Expand Down
1 change: 0 additions & 1 deletion feature.env
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ MANAGE_A_WARRANT_FOLDER_UI_URL=http://localhost:9091/manageawarrant
PATHFINDER_UI_URL=http://localhost:9091/pathfinderui
MANAGE_SOC_CASES_UI_URL=http://localhost:9091/managesoccasesui
WELCOME_PEOPLE_INTO_PRISON_UI_URL=https://welcome-dev.prison.service.justice.gov.uk
MANAGE_ADJUDICATIONS_API_URL=http://localhost:9091/adjudications
CALCULATE_RELEASE_DATES_UI_URL=https://localhost:9091/calculateRelease
FEEDBACK_DISABLED_PRISONS=LEI
SYSTEM_PHASE=DEV
2 changes: 0 additions & 2 deletions helm_deploy/values-dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@ generic-service:
MANAGE_SOC_CASES_UI_URL: "https://manage-soc-cases-dev.hmpps.service.justice.gov.uk"
WELCOME_PEOPLE_INTO_PRISON_UI_URL: "https://welcome-dev.prison.service.justice.gov.uk"
CREATE_AND_VARY_A_LICENCE_UI_URL: "https://create-and-vary-a-licence-dev.hmpps.service.justice.gov.uk"
MANAGE_ADJUDICATIONS_API_URL: "https://manage-adjudications-api-dev.hmpps.service.justice.gov.uk"
CALCULATE_RELEASE_DATES_UI_URL: "https://calculate-release-dates-dev.hmpps.service.justice.gov.uk"
FEEDBACK_DISABLED_PRISONS: "LEI,FNI"
SYSTEM_PHASE: "DEV"

Expand Down
1 change: 0 additions & 1 deletion helm_deploy/values-preprod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ generic-service:
MANAGE_SOC_CASES_UI_URL: "https://manage-soc-cases-preprod.hmpps.service.justice.gov.uk"
WELCOME_PEOPLE_INTO_PRISON_UI_URL: "https://welcome-preprod.prison.service.justice.gov.uk"
CREATE_AND_VARY_A_LICENCE_UI_URL: "https://create-and-vary-a-licence-preprod.hmpps.service.justice.gov.uk"
MANAGE_ADJUDICATIONS_API_URL: "https://manage-adjudications-api-preprod.hmpps.service.justice.gov.uk"
CALCULATE_RELEASE_DATES_UI_URL: "https://calculate-release-dates-preprod.hmpps.service.justice.gov.uk"
FEEDBACK_DISABLED_PRISONS: "LEI,FNI"
SYSTEM_PHASE: "PRE-PRODUCTION"
Expand Down
1 change: 0 additions & 1 deletion helm_deploy/values-prod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ generic-service:
MANAGE_SOC_CASES_UI_URL: "https://manage-soc-cases.hmpps.service.justice.gov.uk"
WELCOME_PEOPLE_INTO_PRISON_UI_URL: "https://welcome.prison.service.justice.gov.uk"
CREATE_AND_VARY_A_LICENCE_UI_URL: "https://create-and-vary-a-licence.hmpps.service.justice.gov.uk"
MANAGE_ADJUDICATIONS_API_URL: "https://manage-adjudications-api.hmpps.service.justice.gov.uk"
CALCULATE_RELEASE_DATES_UI_URL: "https://calculate-release-dates.hmpps.service.justice.gov.uk"
FEEDBACK_DISABLED_PRISONS: "LEI,FNI"

Expand Down
38 changes: 0 additions & 38 deletions integration_tests/mockApis/adjudications.ts

This file was deleted.

32 changes: 32 additions & 0 deletions integration_tests/mockApis/prison.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { stubFor } from './wiremock'
import {
accountBalancesMock,
adjudicationSummaryMock,
adjudicationSummaryWithActiveMock,
assessmentsMock,
visitBalancesMock,
visitSummaryMock,
Expand Down Expand Up @@ -93,6 +95,36 @@ export default {
},
})
},
stubAdjudications: (bookingId: number) => {
return stubFor({
request: {
method: 'GET',
urlPattern: `/prison/api/bookings/${bookingId}/adjudications`,
},
response: {
status: 200,
headers: {
'Content-Type': 'application/json;charset=UTF-8',
},
jsonBody: adjudicationSummaryMock,
},
})
},
stubAdjudicationsWithActive: (bookingId: number) => {
return stubFor({
request: {
method: 'GET',
urlPattern: `/prison/api/bookings/${bookingId}/adjudications`,
},
response: {
status: 200,
headers: {
'Content-Type': 'application/json;charset=UTF-8',
},
jsonBody: adjudicationSummaryWithActiveMock,
},
})
},
stubVisitSummary: (bookingId: number) => {
return stubFor({
request: {
Expand Down
8 changes: 0 additions & 8 deletions server/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,14 +147,6 @@ export default {
},
agent: new AgentConfig(Number(get('MANAGE_SOC_CASES_API_TIMEOUT_DEADLINE', 20000))),
},
adjudicationsApi: {
url: get('MANAGE_ADJUDICATIONS_API_URL', 'http://localhost:8082', requiredInProduction),
timeout: {
response: Number(get('MANAGE_ADJUDICATIONS_API_TIMEOUT_RESPONSE', 20000)),
deadline: Number(get('MANAGE_ADJUDICATIONS_API_TIMEOUT_DEADLINE', 20000)),
},
agent: new AgentConfig(Number(get('MANAGE_ADJUDICATIONS_API_TIMEOUT_DEADLINE', 20000))),
},
},
serviceUrls: {
offenderCategorisation: get('OFFENDER_CATEGORISATION_UI_URL', 'http://localhost:3001', requiredInProduction),
Expand Down
42 changes: 0 additions & 42 deletions server/data/adjudicationsApiClient.test.ts

This file was deleted.

23 changes: 0 additions & 23 deletions server/data/adjudicationsApiClient.ts

This file was deleted.

7 changes: 0 additions & 7 deletions server/data/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,10 @@ import ManageSocCasesApiRestClient from './manageSocCasesApiClient'
import PathfinderApiRestClient from './pathfinderApiClient'
import PrisonApiRestClient from './prisonApiClient'
import PrisonerSearchClient from './prisonerSearchClient'
import { AdjudicationsApiClient } from './interfaces/adjudicationsApiClient'

import { createRedisClient } from './redisClient'
import RestClient, { RestClientBuilder as CreateRestClientBuilder } from './restClient'
import TokenStore from './tokenStore'
import AdjudicationsApiRestClient from './adjudicationsApiClient'

initialiseAppInsights()
buildAppInsightsClient()
Expand Down Expand Up @@ -86,11 +84,6 @@ export const dataAccess = {
config.apis.pathfinderApi,
PathfinderApiRestClient,
),
adjudicationsApiClientBuilder: restClientBuilder<AdjudicationsApiClient>(
'Adjudications API',
config.apis.adjudicationsApi,
AdjudicationsApiRestClient,
),
prisonApiClientBuilder: restClientBuilder<PrisonApiClient>('Prison API', config.apis.prisonApi, PrisonApiRestClient),
prisonerSearchApiClientBuilder: restClientBuilder<PrisonerSearchClient>(
'Prison Offender Search API',
Expand Down
5 changes: 0 additions & 5 deletions server/data/interfaces/adjudicationsApiClient.ts

This file was deleted.

2 changes: 2 additions & 0 deletions server/data/interfaces/prisonApiClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Readable } from 'stream'
import { CaseLoad } from '../../interfaces/caseLoad'
import { NonAssociationDetails } from '../../interfaces/nonAssociationDetails'
import { AccountBalances } from '../../interfaces/accountBalances'
import { AdjudicationSummary } from '../../interfaces/adjudicationSummary'
import { VisitSummary } from '../../interfaces/visitSummary'
import { VisitBalances } from '../../interfaces/visitBalances'
import { Assessment } from '../../interfaces/prisonApi/assessment'
Expand Down Expand Up @@ -37,6 +38,7 @@ export interface PrisonApiClient {
getUserCaseLoads(): Promise<CaseLoad[]>
getNonAssociationDetails(prisonerNumber: string): Promise<NonAssociationDetails>
getAccountBalances(bookingId: number): Promise<AccountBalances>
getAdjudications(bookingId: number): Promise<AdjudicationSummary>
getVisitSummary(bookingId: number): Promise<VisitSummary>
getVisitBalances(prisonerNumber: string): Promise<VisitBalances>
getAssessments(bookingId: number): Promise<Assessment[]>
Expand Down
14 changes: 14 additions & 0 deletions server/data/prisonApiClient.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import nonAssociationDetailsDummyData from './localMockData/nonAssociations'
import PrisonApiClient from './prisonApiClient'
import {
accountBalancesMock,
adjudicationSummaryMock,
assessmentsMock,
visitBalancesMock,
visitSummaryMock,
Expand Down Expand Up @@ -88,6 +89,19 @@ describe('prisonApiClient', () => {
})
})

describe('getAdjudications', () => {
it('Should return data from the API', async () => {
const bookingId = 123456
fakePrisonApi
.get(`/api/bookings/${bookingId}/adjudications`)
.matchHeader('authorization', `Bearer ${token.access_token}`)
.reply(200, adjudicationSummaryMock)

const output = await prisonApiClient.getAdjudications(bookingId)
expect(output).toEqual(adjudicationSummaryMock)
})
})

describe('getVisitSummary', () => {
it('Should return data from the API', async () => {
const bookingId = 123456
Expand Down
5 changes: 5 additions & 0 deletions server/data/prisonApiClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { NonAssociationDetails } from '../interfaces/nonAssociationDetails'
import nonAssociationDetailsDummyData from './localMockData/nonAssociations'
import { PrisonApiClient } from './interfaces/prisonApiClient'
import { AccountBalances } from '../interfaces/accountBalances'
import { AdjudicationSummary } from '../interfaces/adjudicationSummary'
import { VisitSummary } from '../interfaces/visitSummary'
import { VisitBalances } from '../interfaces/visitBalances'
import { Assessment } from '../interfaces/prisonApi/assessment'
Expand Down Expand Up @@ -92,6 +93,10 @@ export default class PrisonApiRestClient implements PrisonApiClient {
})
}

async getAdjudications(bookingId: number): Promise<AdjudicationSummary> {
return this.get<AdjudicationSummary>({ path: `/api/bookings/${bookingId}/adjudications` })
}

async getVisitSummary(bookingId: number): Promise<VisitSummary> {
return this.get<VisitSummary>({ path: `/api/bookings/${bookingId}/visits/summary` })
}
Expand Down
12 changes: 6 additions & 6 deletions server/services/activePunishmentsService.test.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
import { PrisonApiClient } from '../data/interfaces/prisonApiClient'
import { Prisoner } from '../interfaces/prisoner'
import { prisonApiClientMock } from '../../tests/mocks/prisonApiClientMock'
import ActivePunishmentsService from './activePunishmentsService'
import { adjudicationSummaryWithActiveMock } from '../data/localMockData/miniSummaryMock'
import { AdjudicationsApiClient } from '../data/interfaces/adjudicationsApiClient'
import { adjudicationsApiClientMock } from '../../tests/mocks/adjudicationsApiClientMock'

describe('ActivePunishmentsPageService', () => {
let adjudicationsApiClient: AdjudicationsApiClient
let prisonApiClient: PrisonApiClient

const activePunishmentsPageServiceConstruct = jest.fn(() => {
return new ActivePunishmentsService(() => adjudicationsApiClient)
return new ActivePunishmentsService(() => prisonApiClient)
})

beforeEach(() => {
adjudicationsApiClient = adjudicationsApiClientMock()
adjudicationsApiClient.getAdjudications = jest.fn(async () => adjudicationSummaryWithActiveMock)
prisonApiClient = prisonApiClientMock()
prisonApiClient.getAdjudications = jest.fn(async () => adjudicationSummaryWithActiveMock)
})

describe('Active Punishments Page', () => {
Expand Down
10 changes: 5 additions & 5 deletions server/services/activePunishmentsService.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import { PrisonApiClient } from '../data/interfaces/prisonApiClient'
import { Prisoner } from '../interfaces/prisoner'
import { formatName } from '../utils/utils'
import { NameFormatStyle } from '../data/enums/nameFormatStyle'
import { RestClientBuilder } from '../data'
import { AdjudicationsApiClient } from '../data/interfaces/adjudicationsApiClient'

export default class ActivePunishmentsService {
private adjudicationsApiClient: AdjudicationsApiClient
private prisonApiClient: PrisonApiClient

constructor(private readonly adjudicationsApiClientBuilder: RestClientBuilder<AdjudicationsApiClient>) {}
constructor(private readonly prisonApiClientBuilder: RestClientBuilder<PrisonApiClient>) {}

public async get(token: string, prisonerData: Prisoner) {
this.adjudicationsApiClient = this.adjudicationsApiClientBuilder(token)
this.prisonApiClient = this.prisonApiClientBuilder(token)
const { bookingId, firstName, middleNames, lastName } = prisonerData

const adjudications = await this.getAdjudications(bookingId)
Expand All @@ -23,7 +23,7 @@ export default class ActivePunishmentsService {
}

private async getAdjudications(bookingId: number) {
const adjudications = await this.adjudicationsApiClient.getAdjudications(bookingId)
const adjudications = await this.prisonApiClient.getAdjudications(bookingId)
return adjudications
}
}
4 changes: 1 addition & 3 deletions server/services/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ export const services = () => {
keyworkerApiClientBuilder,
incentivesApiClientBuilder,
curiousApiClientBuilder,
adjudicationsApiClientBuilder,
} = dataAccess

const userService = new UserService(hmppsAuthClientBuilder, prisonApiClientBuilder)
Expand All @@ -36,12 +35,11 @@ export const services = () => {
allocationManagerApiClientBuilder,
keyworkerApiClientBuilder,
incentivesApiClientBuilder,
adjudicationsApiClientBuilder,
offencesPageService,
)
const personalPageService = new PersonalPageService(prisonApiClientBuilder)
const workAndSkillsPageService = new WorkAndSkillsPageService(curiousApiClientBuilder, prisonApiClientBuilder)
const activePunishmentsPageService = new ActivePunishmentsService(adjudicationsApiClientBuilder)
const activePunishmentsPageService = new ActivePunishmentsService(prisonApiClientBuilder)

return {
dataAccess,
Expand Down
Loading