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

Release1 #757

Merged
merged 20 commits into from
Sep 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
cb78276
Updated made on call a required field. (#755)
Ben-Edwards-cgi Aug 30, 2024
86cc912
Confirm attendance list is taking into account confirmed but returned…
Ben-Edwards-cgi Aug 30, 2024
6aa6056
History stating jury attendance confirmed when return but do not conf…
Ben-Edwards-cgi Aug 30, 2024
193633c
Added additional scheduler metrics (#575)
Ben-Edwards-cgi Aug 30, 2024
999b444
hotfix/JM-8102 fix for missing days (#756)
akikrahman1 Sep 2, 2024
727e929
hotfix/JM-7928 update to utilisation report query (#758)
akikrahman1 Sep 6, 2024
3043b43
Updated electronic police check report header (#759)
callum-r-young Sep 10, 2024
d25af80
Merge branch 'master' into release1
akikrahman1 Sep 11, 2024
ddbd24c
Update V2_30__util_report_update.sql
akikrahman1 Sep 11, 2024
c6f0540
Update V2_31__util_report_update.sql
akikrahman1 Sep 11, 2024
fa35775
renaming flyway migration to avoid sequence error on deployments
akikrahman1 Sep 11, 2024
6c2f80a
Merge branch 'release1' of https://github.com/hmcts/juror-api into re…
akikrahman1 Sep 11, 2024
47b36af
Feature/JM-8190 (#765)
akikrahman1 Sep 17, 2024
7ee3e9b
JM-8196 Amend PNC View (#767)
EPatterson1 Sep 17, 2024
35b018f
Feature/jm 8181 (#768)
EPatterson1 Sep 18, 2024
329a1d8
remove duplicate migration file
akikrahman1 Sep 18, 2024
9f48f8d
Task/JM-8188 Pre-mod userids preventing access to digital response re…
akikrahman1 Sep 19, 2024
408fae6
JM-8196 Amend PNC View remove spaces last_name (#770)
EPatterson1 Sep 19, 2024
9a30450
cleared empty space
akikrahman1 Sep 19, 2024
943c116
removing redundant spaces to make files same as interim1
akikrahman1 Sep 19, 2024
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
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