Skip to content

Commit

Permalink
Merge pull request #1717 from hmcts/COT-694-sscs-updates
Browse files Browse the repository at this point in the history
COT-694 changes to SSCS
  • Loading branch information
mikebrownccd authored Jan 15, 2024
2 parents 4d133d5 + f11fb37 commit c0b1a64
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ public class JudicialOfficeHolder implements Serializable {
private ZonedDateTime beginTime; //from appointment data
private ZonedDateTime endTime; //from appointment data and add +1 day as per mapping rule by Jon
private String regionId; // locationId from appointment
private String baseLocationId; // epims id
private String baseLocationId; // epims id
private String primaryLocation; //epims id where isPrimary is true
private String contractType; //appointment type from JRD
private String contractType; //appointment type from JRD
private String status;
}
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,8 @@ then
attribute.put("contractType", JacksonUtils.convertObjectIntoJsonNode("Fee-Paid"));
attribute.put("workTypes", JacksonUtils.convertObjectIntoJsonNode("pre_hearing,hearing_work,post_hearing,"
+ "decision_making_work,routine_work,priority"));
attribute.put("region", JacksonUtils.convertObjectIntoJsonNode($joh.getRegionId()));
attribute.put("region", JacksonUtils.convertObjectIntoJsonNode($bk.getRegionId() != null ?
$bk.getRegionId():$joh.getRegionId()));
insert(
RoleAssignment.builder()
.actorIdType(ActorIdType.IDAM)
Expand Down Expand Up @@ -209,7 +210,10 @@ then
attribute.put("primaryLocation", JacksonUtils.convertObjectIntoJsonNode($joh.getPrimaryLocation()));
attribute.put("contractType", JacksonUtils.convertObjectIntoJsonNode("Salaried"));
attribute.put("workTypes", JacksonUtils.convertObjectIntoJsonNode("access_requests"));
attribute.put("region", JacksonUtils.convertObjectIntoJsonNode($joh.getRegionId()));
if (!$joh.getOffice().equalsIgnoreCase("SSCS President of Tribunal-Salaried")) {
attribute.put("region", JacksonUtils.convertObjectIntoJsonNode($joh.getRegionId()));
}

insert(
RoleAssignment.builder()
.actorIdType(ActorIdType.IDAM)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,9 @@ static void assertCommonRoleAssignmentAttributes(RoleAssignment r, String region
assertFalse(r.isReadOnly());
assertEquals("2", primaryLocation);
}

//region assertions
if (r.getRoleName().equals("hmcts-judiciary")
|| List.of("leadership-judge", "judge", "case-allocator", "task-supervisor").contains(r.getRoleName())
&& office.contains("President of Tribunal")) {
|| office.contains("President of Tribunal")) {
assertNull(r.getAttributes().get("region"));
} else {
assertEquals(regionId, r.getAttributes().get("region").asText());
Expand Down Expand Up @@ -125,27 +123,34 @@ void shouldReturnSalariedRoles(String setOffice, String expectedRoles) {

@ParameterizedTest
@CsvSource({
"SSCS Tribunal Judge-Fee Paid,'fee-paid-judge,judge,hmcts-judiciary',true",
"SSCS Tribunal Judge-Fee Paid,'fee-paid-judge,judge,hmcts-judiciary',true, true",
"SSCS Tribunal Judge-Fee Paid,'fee-paid-judge,judge,hmcts-judiciary',true, false",
// ^ judge RA will be created if a booking created
"SSCS Tribunal Judge-Fee Paid,'fee-paid-judge,hmcts-judiciary',false",
"SSCS Tribunal Judge-Fee Paid,'fee-paid-judge,hmcts-judiciary',false, false",
// ^ judge RA will not be created as there is no booking
"SSCS Tribunal Member Medical-Fee Paid,'fee-paid-medical,hmcts-judiciary',false",
"SSCS Tribunal Member Optometrist-Fee Paid,'fee-paid-medical,hmcts-judiciary',false",
"SSCS Tribunal Member Disability-Fee Paid,'fee-paid-disability,hmcts-judiciary',false",
"SSCS Tribunal Member-Fee Paid,'fee-paid-tribunal-member,hmcts-judiciary',false",
"SSCS Tribunal Member Lay-Fee Paid,'fee-paid-tribunal-member,hmcts-judiciary',false",
"SSCS Tribunal Member Service-Fee Paid,'fee-paid-tribunal-member,hmcts-judiciary',false",
"SSCS Tribunal Member Financially Qualified,'fee-paid-financial,hmcts-judiciary',false"
"SSCS Tribunal Member Medical-Fee Paid,'fee-paid-medical,hmcts-judiciary',false, false",
"SSCS Tribunal Member Optometrist-Fee Paid,'fee-paid-medical,hmcts-judiciary',false, false",
"SSCS Tribunal Member Disability-Fee Paid,'fee-paid-disability,hmcts-judiciary',false, false",
"SSCS Tribunal Member-Fee Paid,'fee-paid-tribunal-member,hmcts-judiciary',false, false",
"SSCS Tribunal Member Lay-Fee Paid,'fee-paid-tribunal-member,hmcts-judiciary',false, false",
"SSCS Tribunal Member Service-Fee Paid,'fee-paid-tribunal-member,hmcts-judiciary',false, false",
"SSCS Tribunal Member Financially Qualified,'fee-paid-financial,hmcts-judiciary',false, false"
})
void shouldReturnFeePaidRoles(String setOffice, String expectedRoles, boolean withBooking) throws IOException {

void shouldReturnFeePaidRoles(String setOffice, String expectedRoles, boolean withBooking,
boolean johFallback) throws IOException {
judicialOfficeHolders.forEach(joh -> {
joh.setOffice(setOffice);
joh.setTicketCodes(List.of("368"));
});

if (withBooking) {
createBooking(setOffice);
if (johFallback) {
judicialBookings.forEach(jb -> {
jb.setRegionId(null);
jb.setLocationId(null);
});
}
}

//Execute Kie session
Expand All @@ -158,13 +163,30 @@ void shouldReturnFeePaidRoles(String setOffice, String expectedRoles, boolean wi
assertThat(roleAssignments.stream().map(RoleAssignment::getRoleName).collect(Collectors.toList()),
containsInAnyOrder(expectedRoles.split(",")));
assertEquals(expectedRoles.split(",").length, roleAssignments.size());
String regionId = allProfiles.iterator().next().getRegionId();

roleAssignments.forEach(r -> {
String regionId = setExpectedRegionId(setOffice,withBooking,johFallback,r);
assertEquals("Fee-Paid", r.getAttributes().get("contractType").asText());
assertCommonRoleAssignmentAttributes(r, regionId, setOffice);
});
}

private String setExpectedRegionId(String setOffice, boolean withBooking,
boolean johFallback, RoleAssignment roleAssignment) {
if (setOffice.equals("SSCS Tribunal Judge-Fee Paid") && withBooking
&& roleAssignment.getRoleName().equals("judge")) {
if (!judicialBookings.isEmpty()) {
return (johFallback ? judicialOfficeHolders.iterator().next().getRegionId() :
judicialBookings.iterator().next().getRegionId());
} else {
return allProfiles.iterator().next().getRegionId();
}
} else {
return allProfiles.iterator().next().getRegionId();
}
}


void createBooking(String setOffice) throws IOException {
judicialOfficeHolders.forEach(joh -> joh.setOffice(setOffice));
JudicialBooking judicialBooking = TestDataBuilder.buildJudicialBooking();
Expand Down

0 comments on commit c0b1a64

Please sign in to comment.