Skip to content

Commit

Permalink
Release5 (#808)
Browse files Browse the repository at this point in the history
* task/JS-121 Put multiple jurors on call at the same time (#806)

* task/JS-121 Put multiple jurors on call at the same time

* Update JurorRecordServiceImpl.java

* task/JS-125 Don't move jurors to responded when there is no DOB (#807)

* Task/js 121 (#809)

* task/JS-121 Put multiple jurors on call at the same time

* Update JurorRecordServiceImpl.java

* added endpoint to get simple juror details

* added integration tests

* task/JS-137 (#810)

* JS-13 update nextDate on deleteDeferral

* JS-13 update ManageDeferralsServiceTest

* Task/JS-123  Reassign jurors from one trial to another (#811)

* task/JS-123 Reassign jurors to another panel

* updated tests

* updated tests

* updating tests

* Update TrialServiceImplTest.java

* adding attendance checks

* updated tests

* Update TrialServiceImpl.java (#817)

* task/JS-122  I want to be able to filter on the deferral list report (#818)

* task/JS-122  I want to be able to filter on the deferral list report

updated the by date report

* updates for by court

* update for PMD issue, false positive

* address failing test due to ordering issues

* updating failed unit test

* JS-143 Dismiss Pools (#819)

* JS-143 Dismiss Pools

* refactored and using a new postgres function

* Added integration test

* addressing checkStyle issues

* Update RequestPoolController.java

---------

Co-authored-by: akikrahman1 <[email protected]>

* JS-29 change sort order by court (#820)

---------

Co-authored-by: EPatterson1 <[email protected]>
  • Loading branch information
akikrahman1 and EPatterson1 authored Dec 5, 2024
1 parent 87ec170 commit 62f3ec4
Show file tree
Hide file tree
Showing 44 changed files with 1,343 additions and 102 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -499,6 +499,55 @@ public void excusalRequest_paperResponse_doesNotExist() throws Exception {
});
}

@Test
@Sql({"/db/mod/truncate.sql", "/db/ExcusalResponse_initPaperResponse.sql"})
public void excusalRequestRefuseExcusalSummonedJurorHasDob() throws Exception {
final String jurorNumber = "333333333";
final String login = "BUREAU_USER";
final String bureauJwt = createJwt(login, "400");
final URI uri = URI.create("/api/v1/moj/excusal-response/juror/" + jurorNumber);

httpHeaders.set(HttpHeaders.AUTHORIZATION, bureauJwt);

ExcusalDecisionDto excusalDecisionDto = createExcusalDecisionDto();

RequestEntity<ExcusalDecisionDto> requestEntity = new RequestEntity<>(excusalDecisionDto, httpHeaders,
HttpMethod.PUT, uri);
ResponseEntity<String> response = template.exchange(requestEntity, String.class);
assertThat(response.getStatusCode()).isEqualTo(HttpStatus.OK);
executeInTransaction(() -> {
JurorPool jurorPool = jurorPoolRepository
.findByPoolCourtLocationLocCodeAndJurorJurorNumberAndIsActiveTrue("415", jurorNumber);
validateExcusal(jurorPool, excusalDecisionDto, login);
validateExcusalLetter(excusalDecisionDto.getExcusalReasonCode());
});
}

@Test
@Sql({"/db/mod/truncate.sql", "/db/ExcusalResponse_initPaperResponse.sql"})
public void excusalRequestRefuseExcusalSummonedJurorHasNoDob() throws Exception {
final String jurorNumber = "444444444";
final String login = "BUREAU_USER";
final String bureauJwt = createJwt(login, "400");
final URI uri = URI.create("/api/v1/moj/excusal-response/juror/" + jurorNumber);

httpHeaders.set(HttpHeaders.AUTHORIZATION, bureauJwt);

ExcusalDecisionDto excusalDecisionDto = createExcusalDecisionDto();

RequestEntity<ExcusalDecisionDto> requestEntity = new RequestEntity<>(excusalDecisionDto, httpHeaders,
HttpMethod.PUT, uri);
ResponseEntity<String> response = template.exchange(requestEntity, String.class);
assertThat(response.getStatusCode()).isEqualTo(HttpStatus.OK);
executeInTransaction(() -> {
JurorPool jurorPool = jurorPoolRepository
.findByPoolCourtLocationLocCodeAndJurorJurorNumberAndIsActiveTrue("415", jurorNumber);
assertThat(jurorPool.getStatus().getStatus()).as("Juror should be in summoned status")
.isEqualTo(IJurorStatus.SUMMONED);
validateExcusalLetter(excusalDecisionDto.getExcusalReasonCode());
});
}

private void validatePaperResponseExcusal(PaperResponse jurorPaperResponse, String login) {
assertThat(jurorPaperResponse.getProcessingStatus())
.as("Paper response should be marked as closed")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
import uk.gov.hmcts.juror.api.moj.controller.request.JurorNumberAndPoolNumberDto;
import uk.gov.hmcts.juror.api.moj.controller.request.JurorOpticRefRequestDto;
import uk.gov.hmcts.juror.api.moj.controller.request.JurorRecordFilterRequestQuery;
import uk.gov.hmcts.juror.api.moj.controller.request.JurorSimpleDetailsRequestDto;
import uk.gov.hmcts.juror.api.moj.controller.request.PoliceCheckStatusDto;
import uk.gov.hmcts.juror.api.moj.controller.request.ProcessNameChangeRequestDto;
import uk.gov.hmcts.juror.api.moj.controller.request.ProcessPendingJurorRequestDto;
Expand All @@ -56,6 +57,7 @@
import uk.gov.hmcts.juror.api.moj.controller.response.JurorOverviewResponseDto;
import uk.gov.hmcts.juror.api.moj.controller.response.JurorPoolDetailsDto;
import uk.gov.hmcts.juror.api.moj.controller.response.JurorRecordSearchDto;
import uk.gov.hmcts.juror.api.moj.controller.response.JurorSimpleDetailsResponseDto;
import uk.gov.hmcts.juror.api.moj.controller.response.JurorSummonsReplyResponseDto;
import uk.gov.hmcts.juror.api.moj.controller.response.NameDetails;
import uk.gov.hmcts.juror.api.moj.controller.response.PaymentDetails;
Expand Down Expand Up @@ -92,6 +94,7 @@
import uk.gov.hmcts.juror.api.moj.enumeration.IdCheckCodeEnum;
import uk.gov.hmcts.juror.api.moj.enumeration.PendingJurorStatusEnum;
import uk.gov.hmcts.juror.api.moj.enumeration.ReplyMethod;
import uk.gov.hmcts.juror.api.moj.enumeration.jurormanagement.JurorStatusEnum;
import uk.gov.hmcts.juror.api.moj.exception.MojException;
import uk.gov.hmcts.juror.api.moj.exception.RestResponseEntityExceptionHandler;
import uk.gov.hmcts.juror.api.moj.repository.BulkPrintDataRepository;
Expand Down Expand Up @@ -4847,15 +4850,38 @@ void updateAttendanceHappyPathPlaceOnCall() throws Exception {

UpdateAttendanceRequestDto dto = new UpdateAttendanceRequestDto();
dto.setOnCall(true);
dto.setJurorNumber("121212121");
dto.setJurorNumbers(Collections.singletonList("121212121"));
dto.setNextDate(null);

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

ResponseEntity<?> response =
restTemplate.exchange(new RequestEntity<>(dto, httpHeaders, HttpMethod.PATCH,
URI.create(url + "?juror_number=121212121")), String.class);
URI.create(url)), String.class);

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


@Test
@Sql({"/db/mod/truncate.sql", "/db/JurorRecordController_updateAttendance.sql"})
void updateAttendanceHappyPathPlaceOnCallMultiple() throws Exception {
final String url = BASE_URL + "/update-attendance";

UpdateAttendanceRequestDto dto = new UpdateAttendanceRequestDto();
dto.setOnCall(true);
dto.setJurorNumbers(Arrays.asList("121212121", "131313131"));
dto.setNextDate(null);

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

ResponseEntity<?> response =
restTemplate.exchange(new RequestEntity<>(dto, httpHeaders, HttpMethod.PATCH,
URI.create(url)), String.class);

assertThat(response.getStatusCode())
.as("Expect the HTTP POST request to be ACCEPTED")
Expand All @@ -4869,15 +4895,15 @@ void updateAttendanceHappyPathUpdateNextDate() throws Exception {

UpdateAttendanceRequestDto dto = new UpdateAttendanceRequestDto();
dto.setOnCall(false);
dto.setJurorNumber("121212121");
dto.setJurorNumbers(Collections.singletonList("121212121"));
dto.setNextDate(LocalDate.now().plusWeeks(4));

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

ResponseEntity<?> response =
restTemplate.exchange(new RequestEntity<>(dto, httpHeaders, HttpMethod.PATCH,
URI.create(url + "?juror_number=121212121")), String.class);
URI.create(url)), String.class);

assertThat(response.getStatusCode())
.as("Expect the HTTP POST request to be ACCEPTED")
Expand All @@ -4891,15 +4917,15 @@ void updateAttendanceNoJurorPoolWithJurorNumber() throws Exception {

UpdateAttendanceRequestDto dto = new UpdateAttendanceRequestDto();
dto.setOnCall(true);
dto.setJurorNumber("111111111");
dto.setJurorNumbers(Collections.singletonList("111111111"));
dto.setNextDate(null);

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

ResponseEntity<?> response =
restTemplate.exchange(new RequestEntity<>(dto, httpHeaders, HttpMethod.PATCH,
URI.create(url + "?juror_number=111111111")), String.class);
URI.create(url)), String.class);

assertThat(response.getStatusCode())
.as("Expect the HTTP POST request to be NOT_FOUND")
Expand All @@ -4913,15 +4939,15 @@ void updateAttendanceAlreadyOnCall() throws Exception {

UpdateAttendanceRequestDto dto = new UpdateAttendanceRequestDto();
dto.setOnCall(true);
dto.setJurorNumber("641600096");
dto.setJurorNumbers(Collections.singletonList("641600096"));
dto.setNextDate(null);

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

ResponseEntity<?> response =
restTemplate.exchange(new RequestEntity<>(dto, httpHeaders, HttpMethod.PATCH,
URI.create(url + "?juror_number=641600096")), String.class);
URI.create(url)), String.class);

assertThat(response.getStatusCode())
.as("Expect the HTTP POST request to be NOT_FOUND")
Expand All @@ -4936,12 +4962,12 @@ void updateAttendanceInvalidAccess() {

UpdateAttendanceRequestDto dto = new UpdateAttendanceRequestDto();
dto.setOnCall(true);
dto.setJurorNumber("641600096");
dto.setJurorNumbers(Collections.singletonList("641600096"));
dto.setNextDate(null);

ResponseEntity<?> response =
restTemplate.exchange(new RequestEntity<>(dto, httpHeaders, HttpMethod.PATCH,
URI.create(url + "?juror_number=641600096")), String.class);
URI.create(url)), String.class);

assertThat(response.getStatusCode())
.as("Expect the HTTP POST request to be NOT_FOUND")
Expand Down Expand Up @@ -5905,6 +5931,106 @@ private void validateSearchResultByName(PaginatedList<FilterJurorRecord> respons

}

@Nested
@Sql({"/db/mod/truncate.sql", "/db/JurorRecordController_searchForJurorRecords.sql"})
class GetJurorSimpleDetails {

@Test
void getJurorSimpleDetailsHappy() {

String jurorNumber = "641500101";
String url = BASE_URL + "/simple-details";

JurorSimpleDetailsRequestDto requestDto = new JurorSimpleDetailsRequestDto();
requestDto.setJurorNumbers(Collections.singletonList(jurorNumber));
requestDto.setLocationCode("767");

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

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

JurorSimpleDetailsResponseDto responseBody = response.getBody();
assertThat(responseBody).isNotNull();
assertThat(responseBody.getJurorDetails()).hasSize(1);
JurorSimpleDetailsResponseDto.SimpleDetails jurorDetails = responseBody.getJurorDetails().get(0);
assertThat(jurorDetails.getJurorNumber()).isEqualTo(jurorNumber);
assertThat(jurorDetails.getFirstName()).isEqualTo("Fnamenineten");
assertThat(jurorDetails.getLastName()).isEqualTo("Lnamenineten");
assertThat(jurorDetails.getStatus()).isEqualTo(JurorStatusEnum.RESPONDED);

}

@Test
void getJurorSimpleDetailsMultipleHappy() {
String bureauJwt = createBureauJwt("Court_User", "415", "415");
httpHeaders.set(HttpHeaders.AUTHORIZATION, bureauJwt);

String url = BASE_URL + "/simple-details";

JurorSimpleDetailsRequestDto requestDto = new JurorSimpleDetailsRequestDto();
requestDto.setJurorNumbers(Arrays.asList("641500091","641500092","641500093","641500094","641500095"));
requestDto.setLocationCode("415");

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

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

JurorSimpleDetailsResponseDto responseBody = response.getBody();
assertThat(responseBody).isNotNull();
assertThat(responseBody.getJurorDetails()).hasSize(5);
}

@Test
void jurorNotFound() {
// "123456789" is not a valid juror number

String bureauJwt = createBureauJwt("Court_User", "415", "415");
httpHeaders.set(HttpHeaders.AUTHORIZATION, bureauJwt);

String url = BASE_URL + "/simple-details";

JurorSimpleDetailsRequestDto requestDto = new JurorSimpleDetailsRequestDto();
requestDto.setJurorNumbers(Arrays.asList("641500091","123456789","641500093","641500094","641500095"));
requestDto.setLocationCode("415");

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

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

}

@Test
void noPermissions() {
String jurorNumber = "641500091";
String url = BASE_URL + "/simple-details";

JurorSimpleDetailsRequestDto requestDto = new JurorSimpleDetailsRequestDto();
requestDto.setJurorNumbers(Collections.singletonList(jurorNumber));
requestDto.setLocationCode("415");

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

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

}
}

private void verifyBulkPrintData(String jurorNumber, String formCode) {
List<BulkPrintData> bulkPrintData = bulkPrintDataRepository.findByJurorNo(jurorNumber);
assertThat(bulkPrintData).hasSize(1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2307,6 +2307,75 @@ public void testGetPoolsAtCourtLocationByCourtOneOnCallOnlyNoneInAttendance() th

}

@Test
@Sql({"/db/mod/truncate.sql", "/db/RequestPoolController_allPoolsAtCourtLocation.sql"})
public void testGetAllPoolsAtCourtLocationByCourtUserMultiple() throws Exception {

String locCode = "418";

httpHeaders.set(HttpHeaders.AUTHORIZATION, getSatelliteCourtJwt("418", "418"));

String requestUrl = "/api/v1/moj/pool-request/active-pools-by-court?locCode=" + locCode;

ResponseEntity<PoolsAtCourtLocationListDto> response =
restTemplate.exchange(new RequestEntity<Void>(httpHeaders,
HttpMethod.GET, URI.create(requestUrl)), PoolsAtCourtLocationListDto.class);

assertThat(response.getStatusCode())
.as("Expect the get request to be successful")
.isEqualTo(OK);

PoolsAtCourtLocationListDto poolsAtCourtLocationListDto = response.getBody();
assertThat(poolsAtCourtLocationListDto).isNotNull();
List<PoolsAtCourtLocationListDto.PoolsAtCourtLocationDataDto> poolsAtCourtLocationDataDtosUnsorted
= poolsAtCourtLocationListDto.getData();
assertThat(poolsAtCourtLocationDataDtosUnsorted.size())
.as("Expect the active pools list to have three entries")
.isEqualTo(4);

// sort the list of pools by pool number or else the order is not guaranteed
List<PoolsAtCourtLocationListDto.PoolsAtCourtLocationDataDto> poolsAtCourtLocationDataDtos =
poolsAtCourtLocationDataDtosUnsorted.stream().sorted(Comparator.comparing(PoolsAtCourtLocationListDto
.PoolsAtCourtLocationDataDto::getPoolNumber)).collect(Collectors.toList());

PoolsAtCourtLocationListDto.PoolsAtCourtLocationDataDto poolsAtCourtLocationDataDto
= poolsAtCourtLocationDataDtos.get(0);
LocalDate serviceStartDate = LocalDate.now().minusDays(10);

assertThat(poolsAtCourtLocationDataDto.getPoolNumber()).as("Expect the pool number to be 418230101")
.isEqualTo("418230101");
validatePoolData(poolsAtCourtLocationDataDto, serviceStartDate);
assertThat(poolsAtCourtLocationDataDto.getJurorsOnTrials()).as("Expect there to be 0 juror(s) in trials")
.isEqualTo(0);

poolsAtCourtLocationDataDto
= poolsAtCourtLocationDataDtos.get(1);
assertThat(poolsAtCourtLocationDataDto.getPoolNumber()).as("Expect the pool number to be 418230102")
.isEqualTo("418230102");
validatePoolData(poolsAtCourtLocationDataDto, serviceStartDate);
assertThat(poolsAtCourtLocationDataDto.getJurorsOnTrials()).as("Expect there to be 1 juror(s) in trials")
.isEqualTo(1);

poolsAtCourtLocationDataDto
= poolsAtCourtLocationDataDtos.get(2);
assertThat(poolsAtCourtLocationDataDto.getPoolNumber()).as("Expect the pool number to be 418230103")
.isEqualTo("418230103");
validatePoolData(poolsAtCourtLocationDataDto, serviceStartDate);
assertThat(poolsAtCourtLocationDataDto.getJurorsOnTrials()).as("Expect there to be 1 juror(s) in trials")
.isEqualTo(1);

poolsAtCourtLocationDataDto
= poolsAtCourtLocationDataDtos.get(3);
assertThat(poolsAtCourtLocationDataDto.getPoolNumber()).as("Expect the pool number to be 418230103")
.isEqualTo("418230104");
assertThat(poolsAtCourtLocationDataDto.getServiceStartDate()).as("Expect the pool start date to be "
+ " 3 days in the future")
.isEqualTo(LocalDate.now().plusDays(3));
assertThat(poolsAtCourtLocationDataDto.getJurorsOnTrials()).as("Expect there to be no juror(s) in trials")
.isEqualTo(0);

}

private static void validatePoolData(
PoolsAtCourtLocationListDto.PoolsAtCourtLocationDataDto poolsAtCourtLocationDataDto,
LocalDate serviceStartDate) {
Expand Down
Loading

0 comments on commit 62f3ec4

Please sign in to comment.