Skip to content

Commit

Permalink
Release1 (#757)
Browse files Browse the repository at this point in the history
* Updated made on call a required field. (#755)

* Confirm attendance list is taking into account confirmed but returned trial attendances. This should only show the unconfirmed count. (#753)

* Added restrictions to confirm attendance so prevent attendances from being confirmed multiple times.

* Fixed tests

* History stating jury attendance confirmed when return but do not confirm was selected (#752)

* Fixed issue where jury attendance history would get created if you returned the panel but did not confirm attendance

* Fixed tests

* Added additional scheduler metrics (#575)

* Added additional scheduler metrics

* Added additional scheduler metrics

* Added null or blank check when checking if an email / phone number exists

* Minor tidy up

* Fixed compile issue

* Added validating in for invalid phone numbers or email addresses

* Applied review comments

* hotfix/JM-8102 fix for missing days (#756)

* hotfix/JM-8102 fix for missing days

* updated flyway migration name to avoid conflict

* hotfix/JM-7928 update to utilisation report query (#758)

* Updated electronic police check report header (#759)

* Update V2_30__util_report_update.sql

* Update V2_31__util_report_update.sql

* renaming flyway migration to avoid sequence error on deployments

* Feature/JM-8190 (#765)

* task/JM-8193 (#763)

* Task/JM-8191 Manually create a juror record (#764)

* task/JM-8191

* task/JM-8191

* updates for test fix and styles

* adding unit test

* updated tests

* Update JurorRecordServiceTest.java

* Update JurorRecordControllerITest.java

* JM-8196 Amend PNC View (#767)

* Feature/jm 8181 (#768)

* JM-8196 Amend PNC View

* JM-8196 Amend PNC View

* JM-8196 Amend PNC View

* JM-8196 Amend PNC View remove spaces last_name

* remove duplicate migration file

* Task/JM-8188 Pre-mod userids preventing access to digital response records (#769)

* task/JM-8188 Unable to view migrated digital responses

* fixed checkStyle issue

* JM-8196 Amend PNC View remove spaces last_name (#770)

* cleared empty space

* removing redundant spaces to make files same as interim1

---------

Co-authored-by: Ben Edwards <147524406+Ben-Edwards-cgi@users.noreply.github.com>
Co-authored-by: Callum Young <148960132+callum-r-young@users.noreply.github.com>
Co-authored-by: EPatterson1 <140503822+EPatterson1@users.noreply.github.com>
  • Loading branch information
4 people authored Sep 26, 2024
1 parent b91610b commit 7238f4b
Show file tree
Hide file tree
Showing 57 changed files with 1,213 additions and 471 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ pmdTest {
maxFailures = 292
}
pmdMain {
maxFailures = 763
maxFailures = 752
}
pmd {
maxFailures = 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ public static String mintBureauJwt(final BureauJwtPayload payload,
claimsMap.put("staff", payload.getStaff());

claimsMap.put("roles", payload.getRoles());
claimsMap.put("permissions", payload.getPermissions());
claimsMap.put("userType", payload.getUserType());
claimsMap.put("activeUserType", payload.getActiveUserType() == null
? payload.getUserType() : payload.getActiveUserType());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ private void responseValidator(JwtDto response,
assertThat(claims.getIssuedAt()).isAfter(new Date(clock.millis() - 60_000));

assertThat(claims)
.hasSize(13)
.hasSize(14)
.containsEntry("owner", expectedJwtClaims.getOwner())
.containsEntry("email", expectedJwtClaims.getEmail())
.containsEntry("locCode", expectedJwtClaims.getLocCode())
Expand All @@ -241,7 +241,8 @@ private void responseValidator(JwtDto response,
"courts", expectedJwtClaims.getStaff().getCourts()
))
.containsEntry("roles", expectedJwtClaims.getRoles()
.stream().map(Enum::name).toList());
.stream().map(Enum::name).toList())
.containsEntry("permissions", List.of());
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@

import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNull;

Expand Down Expand Up @@ -74,8 +75,7 @@ private void validateJurorWasCompleted(LocalDate completionTime, String jurorNum
JurorPool jurorPool = jurorPoolRepository.findByJurorJurorNumberAndPoolPoolNumber(jurorNumber, poolNumber);
assertEquals(true, jurorPool.getIsActive(),
"Juror pool should be active");
assertEquals(false, jurorPool.getOnCall(),
"Juror pool should not be on call");
assertFalse(jurorPool.isOnCall(), "Juror pool should not be on call");
assertEquals(IJurorStatus.COMPLETED, jurorPool.getStatus().getStatus(),
"Juror pool status should be completed");
Juror juror = jurorPool.getJuror();
Expand All @@ -85,7 +85,7 @@ private void validateJurorWasCompleted(LocalDate completionTime, String jurorNum

if (isDismissal) {
assertThat(jurorPool.getNextDate()).isNull();
assertThat(jurorPool.getOnCall()).isFalse();
assertThat(jurorPool.isOnCall()).isFalse();
}
List<JurorHistory> jurorHistories = jurorHistoryRepository.findByJurorNumberOrderById(jurorNumber);
assertEquals(1, jurorHistories.size(), "Should only be one history entry");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -607,7 +607,7 @@ void updateAttendanceCheckOutAllJurors() {
AttendanceDetailsResponse.Summary summary = response.getBody().getSummary();
assertThat(summary)
.extracting(AttendanceDetailsResponse.Summary::getCheckedOut)
.isEqualTo(3L);
.isEqualTo(5L);

assertThat(summary)
.extracting(AttendanceDetailsResponse.Summary::getPanelled)
Expand Down Expand Up @@ -1032,7 +1032,7 @@ void updateAttendanceNoShow() {
AttendanceDetailsResponse.Summary summary = response.getBody().getSummary();
assertThat(summary)
.extracting(AttendanceDetailsResponse.Summary::getCheckedIn)
.isEqualTo(4L);
.isEqualTo(5L);

assertThat(summary)
.extracting(AttendanceDetailsResponse.Summary::getAbsent)
Expand Down Expand Up @@ -1282,7 +1282,7 @@ void updateAttendanceDateOnCallFlagUpdated() {

// check the on-call flag before invoking the api
Boolean onCallFlagBefore =
jurorPoolRepository.findByJurorJurorNumberAndPoolPoolNumber(JUROR6, POOL_NUMBER_415230101).getOnCall();
jurorPoolRepository.findByJurorJurorNumberAndPoolPoolNumber(JUROR6, POOL_NUMBER_415230101).isOnCall();
assertThat(onCallFlagBefore).as("On-call flag should be True").isEqualTo(Boolean.TRUE);

ResponseEntity<String> responseEntity =
Expand All @@ -1296,7 +1296,7 @@ void updateAttendanceDateOnCallFlagUpdated() {

// verify the on-call flag was updated successfully
Boolean onCallFlagAfter =
jurorPoolRepository.findByJurorJurorNumberAndPoolPoolNumber(JUROR6, POOL_NUMBER_415230101).getOnCall();
jurorPoolRepository.findByJurorJurorNumberAndPoolPoolNumber(JUROR6, POOL_NUMBER_415230101).isOnCall();
assertThat(onCallFlagAfter).as("On-call flag should be False").isEqualTo(Boolean.FALSE);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import uk.gov.hmcts.juror.api.moj.controller.request.FilterableJurorDetailsRequestDto;
import uk.gov.hmcts.juror.api.moj.controller.request.JurorAddressDto;
import uk.gov.hmcts.juror.api.moj.controller.request.JurorCreateRequestDto;
import uk.gov.hmcts.juror.api.moj.controller.request.JurorManualCreationRequestDto;
import uk.gov.hmcts.juror.api.moj.controller.request.JurorNameDetailsDto;
import uk.gov.hmcts.juror.api.moj.controller.request.JurorNotesRequestDto;
import uk.gov.hmcts.juror.api.moj.controller.request.JurorNumberAndPoolNumberDto;
Expand Down Expand Up @@ -75,11 +76,13 @@
import uk.gov.hmcts.juror.api.moj.domain.JurorPool;
import uk.gov.hmcts.juror.api.moj.domain.PaginatedList;
import uk.gov.hmcts.juror.api.moj.domain.PendingJuror;
import uk.gov.hmcts.juror.api.moj.domain.Permission;
import uk.gov.hmcts.juror.api.moj.domain.PoliceCheck;
import uk.gov.hmcts.juror.api.moj.domain.PoolHistory;
import uk.gov.hmcts.juror.api.moj.domain.PoolRequest;
import uk.gov.hmcts.juror.api.moj.domain.Role;
import uk.gov.hmcts.juror.api.moj.domain.SortMethod;
import uk.gov.hmcts.juror.api.moj.domain.User;
import uk.gov.hmcts.juror.api.moj.domain.UserType;
import uk.gov.hmcts.juror.api.moj.domain.jurorresponse.DigitalResponse;
import uk.gov.hmcts.juror.api.moj.domain.jurorresponse.PaperResponse;
Expand Down Expand Up @@ -118,9 +121,11 @@
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Objects;
import java.util.Set;

import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertEquals;
Expand Down Expand Up @@ -5324,6 +5329,192 @@ void markJurorAsRespondedBureauJurorNotFound() throws Exception {

}

@Nested
@DisplayName("POST " + CreateManualJurorRecord.URL)
class CreateManualJurorRecord {

private static final String URL = BASE_URL + "/create-juror-manual";

@Test
@Sql({"/db/mod/truncate.sql", "/db/JurorRecordController_createManualJurorRecord.sql"})
void createManualJurorRecordPoolHappyPath() throws Exception {
String poolNumber = "415220502";
final JurorManualCreationRequestDto requestDto = JurorManualCreationRequestDto.builder()
.poolNumber(poolNumber)
.locationCode("415")
.title("Mr")
.firstName("John")
.lastName("Smith")
.address(JurorAddressDto.builder()
.lineOne("1 High Street")
.lineTwo("Test")
.lineThree("Test")
.town("Chester")
.county("Test")
.postcode("CH1 2AB")
.build())
.primaryPhone("01234567890")
.emailAddress("test@test.com")
.notes("A manually created juror")
.build();

Set<Role> roles = new HashSet<>();
roles.add(Role.MANAGER);
Set<Permission> permissions = new HashSet<>();
permissions.add(Permission.CREATE_JUROR);
User user = User.builder()
.username("BUREAU_USER")
.roles(roles)
.permissions(permissions)
.build();

final BureauJwtPayload bureauJwtPayload = new BureauJwtPayload(user, UserType.BUREAU, "400",
Collections.singletonList(CourtLocation.builder()
.locCode("400")
.name("Bureau")
.owner("400")
.build()));

httpHeaders.set(HttpHeaders.AUTHORIZATION, mintBureauJwt(bureauJwtPayload));

ResponseEntity<?> response =
restTemplate.exchange(new RequestEntity<>(requestDto, httpHeaders, POST,
URI.create(URL)), String.class);

assertThat(response.getStatusCode())
.as("Expect the HTTP POST request to be CREATED")
.isEqualTo(HttpStatus.CREATED);

validateCreatedJuror(poolNumber);
}

private void validateCreatedJuror(String poolNumber) {
// expect this to be the first juror manually created for court 415
Juror juror = jurorRepository.findByJurorNumber("041500001");
assertThat(juror).isNotNull();
assertThat(juror.getTitle()).isEqualTo("Mr");
assertThat(juror.getFirstName()).isEqualTo("John");
assertThat(juror.getLastName()).isEqualTo("Smith");
assertThat(juror.getDateOfBirth()).isNull();
assertThat(juror.getPhoneNumber()).isEqualTo("01234567890");
assertThat(juror.getEmail()).isEqualTo("test@test.com");
assertThat(juror.getNotes()).isEqualTo("A manually created juror");

assertThat(juror.getAddressLine1()).isEqualTo("1 High Street");
assertThat(juror.getAddressLine2()).isEqualTo("Test");
assertThat(juror.getAddressLine3()).isEqualTo("Test");
assertThat(juror.getAddressLine4()).isEqualTo("Chester");
assertThat(juror.getAddressLine5()).isEqualTo("Test");
assertThat(juror.getPostcode()).isEqualTo("CH1 2AB");

JurorPool jurorPool = jurorPoolRepository.findByJurorJurorNumberAndPoolPoolNumber(juror.getJurorNumber(),
poolNumber);
assertThat(jurorPool).isNotNull();
assertThat(jurorPool.getStatus().getStatus()).isEqualTo(IJurorStatus.SUMMONED);
assertThat(jurorPool.getOwner()).isEqualTo("400");
assertThat(jurorPool.getNextDate()).isEqualTo(LocalDate.now().plusDays(10));
assertThat(jurorPool.getPoolNumber()).isEqualTo(poolNumber);

List<JurorHistory> jurorHistory = jurorHistoryRepository
.findByJurorNumberOrderById(juror.getJurorNumber());
assertThat(jurorHistory).isNotEmpty();
assertThat(jurorHistory.get(0).getHistoryCode()).isEqualTo(HistoryCodeMod.PRINT_SUMMONS);

List<BulkPrintData> letters = bulkPrintDataRepository.findByJurorNo(juror.getJurorNumber());
assertThat(letters).isNotEmpty();
BulkPrintData bulkPrintData = letters.get(0);
assertThat(bulkPrintData.getJurorNo()).isEqualTo(juror.getJurorNumber());
assertThat(bulkPrintData.getFormAttribute().getFormType()).isEqualTo(FormCode.ENG_SUMMONS.getCode());
}


@Test
void createManualJurorRecordBureauManagerNoCreateForbidden() throws Exception {
String poolNumber = "415220502";
JurorManualCreationRequestDto requestDto = JurorManualCreationRequestDto.builder()
.poolNumber(poolNumber)
.locationCode("415")
.title("Mr")
.firstName("John")
.lastName("Smith")
.address(JurorAddressDto.builder()
.lineOne("1 High Street")
.lineTwo("Test")
.lineThree("Test")
.town("Chester")
.county("Test")
.postcode("CH1 2AB")
.build())
.primaryPhone("01234567890")
.emailAddress("test@test.com")
.notes("A manually created juror")
.build();

Set<Role> roles = new HashSet<>();
roles.add(Role.MANAGER);
Set<Permission> permissions = new HashSet<>();
User user = User.builder()
.username("BUREAU2")
.roles(roles)
.permissions(permissions)
.build();

BureauJwtPayload bureauJwtPayload = new BureauJwtPayload(user, UserType.BUREAU, "400",
Collections.singletonList(CourtLocation.builder()
.locCode("400")
.name("Bureau")
.owner("400")
.build()));

httpHeaders.set(HttpHeaders.AUTHORIZATION, mintBureauJwt(bureauJwtPayload));

ResponseEntity<?> response =
restTemplate.exchange(new RequestEntity<>(requestDto, httpHeaders, POST,
URI.create(URL)), String.class);

assertThat(response.getStatusCode())
.as("Expect the HTTP POST request to be FORBIDDEN")
.isEqualTo(HttpStatus.FORBIDDEN);

}

@Test
void createManualJurorRecordCourtUserForbidden() throws Exception {
String poolNumber = "415220502";
JurorManualCreationRequestDto requestDto = JurorManualCreationRequestDto.builder()
.poolNumber(poolNumber)
.locationCode("415")
.title("Mr")
.firstName("John")
.lastName("Smith")
.address(JurorAddressDto.builder()
.lineOne("1 High Street")
.lineTwo("Test")
.lineThree("Test")
.town("Chester")
.county("Test")
.postcode("CH1 2AB")
.build())
.primaryPhone("01234567890")
.emailAddress("test@test.com")
.notes("A manually created juror")
.build();

httpHeaders.set(HttpHeaders.AUTHORIZATION, initCourtsJwt("415", Collections.singletonList("415"),
UserType.COURT));

ResponseEntity<?> response =
restTemplate.exchange(new RequestEntity<>(requestDto, httpHeaders, POST,
URI.create(URL)), String.class);

assertThat(response.getStatusCode())
.as("Expect the HTTP POST request to be FORBIDDEN")
.isEqualTo(HttpStatus.FORBIDDEN);

}

}

@Nested
@DisplayName("Search for Juror records")
@Sql({"/db/mod/truncate.sql", "/db/JurorRecordController_searchForJurorRecords.sql"})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2147,7 +2147,7 @@ private void transferJurorPoolValidateNewlyCreatedJurorPool(String jurorNumber,
assertThat(targetJurorPool.getEditTag())
.as(EXPECT_PROPERTY_TO_BE_USE_A_DEFAULT_VALUE)
.isNull();
assertThat(targetJurorPool.getOnCall())
assertThat(targetJurorPool.isOnCall())
.as(EXPECT_PROPERTY_TO_BE_USE_A_DEFAULT_VALUE)
.isFalse();
assertThat(targetJurorPool.getSmartCard())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -800,8 +800,8 @@ void testReturnJuryNoConfirmAttendance() {
"Expect status to be Responded").isEqualTo(IJurorStatus.RESPONDED);
assertThat(
jurorHistoryRepository.findByJurorNumberOrderById(panel.getJurorNumber()).size())
.as("Expect two history item for juror " + panel.getJurorNumber())
.isEqualTo(2);
.as("Expect one history item for juror " + panel.getJurorNumber())
.isEqualTo(1);

Appearance appearance =
appearanceRepository.findByLocCodeAndJurorNumberAndAttendanceDate("415", panel.getJurorNumber(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ private StandardReportResponse buildResponse(String fromDate, String toDate, Sta
.build(),
StandardReportResponse.TableData.Heading.builder()
.id("police_check_timed_out")
.name("Checks completed")
.name("Checks timed out")
.dataType("Long")
.headings(null)
.build(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,18 +105,18 @@ INSERT INTO juror_mod.juror (juror_number, last_name, first_name, dob, address_l
('641800002', 'PERSON', 'TEST', '1990-05-16', '542 STREET NAME', 'ANYTOWN', 'CH1 2AN', true, null),
('641800003', 'PERSON', 'TEST', '1990-05-16', '542 STREET NAME', 'ANYTOWN', 'CH1 2AN', true, '2023-10-24');

INSERT INTO juror_mod.juror_pool (owner, juror_number, pool_number, is_active, next_date, status, on_call) VALUES
('400', '641600001', '416230101', true, '2023-01-23', 2, null),
('416', '641600002', '416230103', true, '2023-01-23', 13, null),
('417', '641700001', '417230101', true, '2023-01-09', 13, null),
('417', '641700002', '417230101', true, '2023-01-09', 7, null),
('417', '641700003', '417230101', true, '2023-01-09', 2, null),
('417', '641700004', '417230101', true, '2023-01-09', 2, true),
('417', '641700005', '417230101', true, '2023-01-09', 4, null),
('417', '641700006', '417230101', true, '2023-01-09', 2, null),
('418', '641800001', '418230101', true, '2023-10-25', 2, null),
('418', '641800002', '418230102', true, '2023-10-23', 2, null),
('418', '641800003', '418230103', true, '2023-10-23', 13, null);
INSERT INTO juror_mod.juror_pool (owner, juror_number, pool_number, is_active, next_date, status) VALUES
('400', '641600001', '416230101', true, '2023-01-23', 2),
('416', '641600002', '416230103', true, '2023-01-23', 13),
('417', '641700001', '417230101', true, '2023-01-09', 13),
('417', '641700002', '417230101', true, '2023-01-09', 7),
('417', '641700003', '417230101', true, '2023-01-09', 2),
('417', '641700004', '417230101', true, '2023-01-09', 2),
('417', '641700005', '417230101', true, '2023-01-09', 4),
('417', '641700006', '417230101', true, '2023-01-09', 2),
('418', '641800001', '418230101', true, '2023-10-25', 2),
('418', '641800002', '418230102', true, '2023-10-23', 2),
('418', '641800003', '418230103', true, '2023-10-23', 13);


INSERT INTO juror_mod.appearance (attendance_date,juror_number,pool_number,loc_code,f_audit,time_in,time_out,travel_time,appearance_stage,non_attendance) VALUES
Expand Down
Loading

0 comments on commit 7238f4b

Please sign in to comment.