From 4f2464281fca8610707b62e6eb640845c50ffcf2 Mon Sep 17 00:00:00 2001 From: Anthony Dummer Date: Thu, 4 Jan 2024 14:06:12 +0000 Subject: [PATCH 1/8] COT-694 check in of changes. --- .../orgrolemapping/domain/model/JudicialAccessProfile.java | 1 + .../orgrolemapping/domain/model/JudicialOfficeHolder.java | 5 +++-- .../orgrolemapping/helper/AssignmentRequestBuilder.java | 2 ++ .../sscs/sscs-judicial-office-holder-mapping.drl | 1 + .../validationrules/sscs/sscs-judicial-org-role-mapping.drl | 1 - 5 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/main/java/uk/gov/hmcts/reform/orgrolemapping/domain/model/JudicialAccessProfile.java b/src/main/java/uk/gov/hmcts/reform/orgrolemapping/domain/model/JudicialAccessProfile.java index f8c9dcb8c..94ecd8d5d 100644 --- a/src/main/java/uk/gov/hmcts/reform/orgrolemapping/domain/model/JudicialAccessProfile.java +++ b/src/main/java/uk/gov/hmcts/reform/orgrolemapping/domain/model/JudicialAccessProfile.java @@ -28,6 +28,7 @@ public class JudicialAccessProfile implements Serializable, UserAccessProfile { */ @Deprecated(forRemoval = true) private String cftRegionIdV1; + private String cftRegion; private String baseLocationId; private String contractTypeId; private String appointment; diff --git a/src/main/java/uk/gov/hmcts/reform/orgrolemapping/domain/model/JudicialOfficeHolder.java b/src/main/java/uk/gov/hmcts/reform/orgrolemapping/domain/model/JudicialOfficeHolder.java index bb5efe520..182d490a2 100644 --- a/src/main/java/uk/gov/hmcts/reform/orgrolemapping/domain/model/JudicialOfficeHolder.java +++ b/src/main/java/uk/gov/hmcts/reform/orgrolemapping/domain/model/JudicialOfficeHolder.java @@ -26,8 +26,9 @@ 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 region; // location from appointment + 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; } \ No newline at end of file diff --git a/src/main/java/uk/gov/hmcts/reform/orgrolemapping/helper/AssignmentRequestBuilder.java b/src/main/java/uk/gov/hmcts/reform/orgrolemapping/helper/AssignmentRequestBuilder.java index 9e1fca2ac..41e503155 100644 --- a/src/main/java/uk/gov/hmcts/reform/orgrolemapping/helper/AssignmentRequestBuilder.java +++ b/src/main/java/uk/gov/hmcts/reform/orgrolemapping/helper/AssignmentRequestBuilder.java @@ -190,6 +190,7 @@ public static Set convertProfileToJudicialAccessProfile(Judic .atStartOfDay(ZoneId.of("UTC")) : null); judicialAccessProfile.setRegionId(appointment.getLocationId()); judicialAccessProfile.setCftRegionIdV1(appointment.getCftRegionID()); + judicialAccessProfile.setCftRegion(appointment.getCftRegion()); // change from epimmsid to base location as part of SSCS judicialAccessProfile.setBaseLocationId(appointment.getBaseLocationId()); judicialAccessProfile.setTicketCodes(List.copyOf(ticketCodes)); @@ -241,6 +242,7 @@ public static Set convertProfileToJudicialAccessProfileV2( .endTime(localDateToZonedDateTime(appointment.getEndDate())) .regionId(appointment.getCftRegionID()) .cftRegionIdV1(appointment.getCftRegionID()) + .cftRegion(appointment.getCftRegion()) .baseLocationId(appointment.getBaseLocationId()) .ticketCodes(stringListToDistinctList(ticketCodes)) .appointment(appointment.getAppointment()) diff --git a/src/main/resources/validationrules/sscs/sscs-judicial-office-holder-mapping.drl b/src/main/resources/validationrules/sscs/sscs-judicial-office-holder-mapping.drl index e7870b5e3..efeb5d208 100644 --- a/src/main/resources/validationrules/sscs/sscs-judicial-office-holder-mapping.drl +++ b/src/main/resources/validationrules/sscs/sscs-judicial-office-holder-mapping.drl @@ -72,6 +72,7 @@ then .beginTime($jap.getBeginTime()) .endTime($jap.getEndTime()) .regionId($jap.getCftRegionIdV1()) + .region($jap.getCftRegion()) .baseLocationId($jap.getBaseLocationId()) .primaryLocation($jap.getPrimaryLocationId()) .contractType($jap.getAppointmentType()) diff --git a/src/main/resources/validationrules/sscs/sscs-judicial-org-role-mapping.drl b/src/main/resources/validationrules/sscs/sscs-judicial-org-role-mapping.drl index 99d4116ad..a5e606c4b 100644 --- a/src/main/resources/validationrules/sscs/sscs-judicial-org-role-mapping.drl +++ b/src/main/resources/validationrules/sscs/sscs-judicial-org-role-mapping.drl @@ -209,7 +209,6 @@ 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())); insert( RoleAssignment.builder() .actorIdType(ActorIdType.IDAM) From 14d72ff724672fcc6426af307865e29a53142a6b Mon Sep 17 00:00:00 2001 From: Anthony Dummer Date: Mon, 8 Jan 2024 12:41:43 +0000 Subject: [PATCH 2/8] COT-694 check in of changes. --- .../sscs-judicial-office-holder-mapping.drl | 1 + .../sscs/sscs-judicial-org-role-mapping.drl | 6 +++++- .../DroolSscsJudicialRoleMappingTest.java | 19 ++++++++++++------- 3 files changed, 18 insertions(+), 8 deletions(-) diff --git a/src/main/resources/validationrules/sscs/sscs-judicial-office-holder-mapping.drl b/src/main/resources/validationrules/sscs/sscs-judicial-office-holder-mapping.drl index efeb5d208..6c47d7784 100644 --- a/src/main/resources/validationrules/sscs/sscs-judicial-office-holder-mapping.drl +++ b/src/main/resources/validationrules/sscs/sscs-judicial-office-holder-mapping.drl @@ -131,6 +131,7 @@ then .beginTime($jap.getBeginTime()) .endTime($jap.getEndTime()) .regionId($jap.getCftRegionIdV1()) + .region($jap.getCftRegion()) .baseLocationId($jap.getBaseLocationId()) .primaryLocation($jap.getPrimaryLocationId()) .contractType($jap.getAppointmentType()) diff --git a/src/main/resources/validationrules/sscs/sscs-judicial-org-role-mapping.drl b/src/main/resources/validationrules/sscs/sscs-judicial-org-role-mapping.drl index a5e606c4b..5ed74aec2 100644 --- a/src/main/resources/validationrules/sscs/sscs-judicial-org-role-mapping.drl +++ b/src/main/resources/validationrules/sscs/sscs-judicial-org-role-mapping.drl @@ -107,7 +107,7 @@ 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($joh.getRegion())); insert( RoleAssignment.builder() .actorIdType(ActorIdType.IDAM) @@ -209,6 +209,10 @@ then attribute.put("primaryLocation", JacksonUtils.convertObjectIntoJsonNode($joh.getPrimaryLocation())); attribute.put("contractType", JacksonUtils.convertObjectIntoJsonNode("Salaried")); attribute.put("workTypes", JacksonUtils.convertObjectIntoJsonNode("access_requests")); + if (!$joh.getOffice().equalsIgnoreCase("SSCS President of Tribunal-Salaried")) { + attribute.put("region", JacksonUtils.convertObjectIntoJsonNode($joh.getRegionId())); + } + insert( RoleAssignment.builder() .actorIdType(ActorIdType.IDAM) diff --git a/src/test/java/uk/gov/hmcts/reform/orgrolemapping/domain/service/DroolSscsJudicialRoleMappingTest.java b/src/test/java/uk/gov/hmcts/reform/orgrolemapping/domain/service/DroolSscsJudicialRoleMappingTest.java index 06c98ac7b..7201a2585 100644 --- a/src/test/java/uk/gov/hmcts/reform/orgrolemapping/domain/service/DroolSscsJudicialRoleMappingTest.java +++ b/src/test/java/uk/gov/hmcts/reform/orgrolemapping/domain/service/DroolSscsJudicialRoleMappingTest.java @@ -50,7 +50,7 @@ class DroolSscsJudicialRoleMappingTest extends DroolBase { expectedRoleNameWorkTypesMap.put("fee-paid-financial", "hearing_work,priority"); } - static void assertCommonRoleAssignmentAttributes(RoleAssignment r, String regionId, String office) { + static void assertCommonRoleAssignmentAttributes(RoleAssignment r, String regionId, String region, String office) { assertEquals(ActorIdType.IDAM, r.getActorIdType()); assertEquals(RoleType.ORGANISATION, r.getRoleType()); assertEquals(RoleCategory.JUDICIAL, r.getRoleCategory()); @@ -78,11 +78,15 @@ static void assertCommonRoleAssignmentAttributes(RoleAssignment r, String region //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()); + if (r.getRoleName().equals("judge") + && office.equals("SSCS Tribunal Judge-Fee Paid")){ + assertEquals(region, r.getAttributes().get("region").asText()); + }else { + assertEquals(regionId, r.getAttributes().get("region").asText()); + } } String expectedWorkTypes = expectedRoleNameWorkTypesMap.get(r.getRoleName()); @@ -119,7 +123,7 @@ void shouldReturnSalariedRoles(String setOffice, String expectedRoles) { String regionId = allProfiles.iterator().next().getRegionId(); roleAssignments.forEach(r -> { assertEquals("Salaried", r.getAttributes().get("contractType").asText()); - assertCommonRoleAssignmentAttributes(r, regionId, setOffice); + assertCommonRoleAssignmentAttributes(r, regionId, null, setOffice); }); } @@ -138,10 +142,11 @@ void shouldReturnSalariedRoles(String setOffice, String expectedRoles) { "SSCS Tribunal Member Financially Qualified,'fee-paid-financial,hmcts-judiciary',false" }) void shouldReturnFeePaidRoles(String setOffice, String expectedRoles, boolean withBooking) throws IOException { - + String region = "Edinburgh"; judicialOfficeHolders.forEach(joh -> { joh.setOffice(setOffice); joh.setTicketCodes(List.of("368")); + joh.setRegion(region); }); if (withBooking) { @@ -161,7 +166,7 @@ void shouldReturnFeePaidRoles(String setOffice, String expectedRoles, boolean wi String regionId = allProfiles.iterator().next().getRegionId(); roleAssignments.forEach(r -> { assertEquals("Fee-Paid", r.getAttributes().get("contractType").asText()); - assertCommonRoleAssignmentAttributes(r, regionId, setOffice); + assertCommonRoleAssignmentAttributes(r, regionId, region, setOffice); }); } From 63e86813e3cbb3b953115ab93cad84fd1de55460 Mon Sep 17 00:00:00 2001 From: Anthony Dummer Date: Mon, 8 Jan 2024 12:49:15 +0000 Subject: [PATCH 3/8] COT-694 check in of changes. --- .../validationrules/sscs/sscs-judicial-office-holder-mapping.drl | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/resources/validationrules/sscs/sscs-judicial-office-holder-mapping.drl b/src/main/resources/validationrules/sscs/sscs-judicial-office-holder-mapping.drl index 6c47d7784..3072f6930 100644 --- a/src/main/resources/validationrules/sscs/sscs-judicial-office-holder-mapping.drl +++ b/src/main/resources/validationrules/sscs/sscs-judicial-office-holder-mapping.drl @@ -72,7 +72,6 @@ then .beginTime($jap.getBeginTime()) .endTime($jap.getEndTime()) .regionId($jap.getCftRegionIdV1()) - .region($jap.getCftRegion()) .baseLocationId($jap.getBaseLocationId()) .primaryLocation($jap.getPrimaryLocationId()) .contractType($jap.getAppointmentType()) From 0dc835cade9446fbe5a203b6a31d091bfbd0145c Mon Sep 17 00:00:00 2001 From: Anthony Dummer Date: Mon, 8 Jan 2024 14:44:29 +0000 Subject: [PATCH 4/8] COT-694 Resolving checkstyle finding in test module. --- .../domain/service/DroolSscsJudicialRoleMappingTest.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/test/java/uk/gov/hmcts/reform/orgrolemapping/domain/service/DroolSscsJudicialRoleMappingTest.java b/src/test/java/uk/gov/hmcts/reform/orgrolemapping/domain/service/DroolSscsJudicialRoleMappingTest.java index 7201a2585..335364985 100644 --- a/src/test/java/uk/gov/hmcts/reform/orgrolemapping/domain/service/DroolSscsJudicialRoleMappingTest.java +++ b/src/test/java/uk/gov/hmcts/reform/orgrolemapping/domain/service/DroolSscsJudicialRoleMappingTest.java @@ -82,9 +82,9 @@ static void assertCommonRoleAssignmentAttributes(RoleAssignment r, String region assertNull(r.getAttributes().get("region")); } else { if (r.getRoleName().equals("judge") - && office.equals("SSCS Tribunal Judge-Fee Paid")){ + && office.equals("SSCS Tribunal Judge-Fee Paid")) { assertEquals(region, r.getAttributes().get("region").asText()); - }else { + } else { assertEquals(regionId, r.getAttributes().get("region").asText()); } } From 4c78d3dc6db25a2c6404e57aefe5569a948f85d5 Mon Sep 17 00:00:00 2001 From: Anthony Dummer Date: Mon, 8 Jan 2024 18:45:27 +0000 Subject: [PATCH 5/8] COT-694 Resolving review findings to use values from the judicialBooking. --- .../domain/model/JudicialAccessProfile.java | 1 - .../domain/model/JudicialOfficeHolder.java | 1 - .../helper/AssignmentRequestBuilder.java | 2 -- .../sscs-judicial-office-holder-mapping.drl | 1 - .../sscs/sscs-judicial-org-role-mapping.drl | 2 +- .../DroolSscsJudicialRoleMappingTest.java | 34 ++++++++++++------- 6 files changed, 22 insertions(+), 19 deletions(-) diff --git a/src/main/java/uk/gov/hmcts/reform/orgrolemapping/domain/model/JudicialAccessProfile.java b/src/main/java/uk/gov/hmcts/reform/orgrolemapping/domain/model/JudicialAccessProfile.java index 94ecd8d5d..f8c9dcb8c 100644 --- a/src/main/java/uk/gov/hmcts/reform/orgrolemapping/domain/model/JudicialAccessProfile.java +++ b/src/main/java/uk/gov/hmcts/reform/orgrolemapping/domain/model/JudicialAccessProfile.java @@ -28,7 +28,6 @@ public class JudicialAccessProfile implements Serializable, UserAccessProfile { */ @Deprecated(forRemoval = true) private String cftRegionIdV1; - private String cftRegion; private String baseLocationId; private String contractTypeId; private String appointment; diff --git a/src/main/java/uk/gov/hmcts/reform/orgrolemapping/domain/model/JudicialOfficeHolder.java b/src/main/java/uk/gov/hmcts/reform/orgrolemapping/domain/model/JudicialOfficeHolder.java index 182d490a2..c6e5a5b0f 100644 --- a/src/main/java/uk/gov/hmcts/reform/orgrolemapping/domain/model/JudicialOfficeHolder.java +++ b/src/main/java/uk/gov/hmcts/reform/orgrolemapping/domain/model/JudicialOfficeHolder.java @@ -26,7 +26,6 @@ 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 region; // location from appointment private String baseLocationId; // epims id private String primaryLocation; //epims id where isPrimary is true private String contractType; //appointment type from JRD diff --git a/src/main/java/uk/gov/hmcts/reform/orgrolemapping/helper/AssignmentRequestBuilder.java b/src/main/java/uk/gov/hmcts/reform/orgrolemapping/helper/AssignmentRequestBuilder.java index 41e503155..9e1fca2ac 100644 --- a/src/main/java/uk/gov/hmcts/reform/orgrolemapping/helper/AssignmentRequestBuilder.java +++ b/src/main/java/uk/gov/hmcts/reform/orgrolemapping/helper/AssignmentRequestBuilder.java @@ -190,7 +190,6 @@ public static Set convertProfileToJudicialAccessProfile(Judic .atStartOfDay(ZoneId.of("UTC")) : null); judicialAccessProfile.setRegionId(appointment.getLocationId()); judicialAccessProfile.setCftRegionIdV1(appointment.getCftRegionID()); - judicialAccessProfile.setCftRegion(appointment.getCftRegion()); // change from epimmsid to base location as part of SSCS judicialAccessProfile.setBaseLocationId(appointment.getBaseLocationId()); judicialAccessProfile.setTicketCodes(List.copyOf(ticketCodes)); @@ -242,7 +241,6 @@ public static Set convertProfileToJudicialAccessProfileV2( .endTime(localDateToZonedDateTime(appointment.getEndDate())) .regionId(appointment.getCftRegionID()) .cftRegionIdV1(appointment.getCftRegionID()) - .cftRegion(appointment.getCftRegion()) .baseLocationId(appointment.getBaseLocationId()) .ticketCodes(stringListToDistinctList(ticketCodes)) .appointment(appointment.getAppointment()) diff --git a/src/main/resources/validationrules/sscs/sscs-judicial-office-holder-mapping.drl b/src/main/resources/validationrules/sscs/sscs-judicial-office-holder-mapping.drl index 3072f6930..e7870b5e3 100644 --- a/src/main/resources/validationrules/sscs/sscs-judicial-office-holder-mapping.drl +++ b/src/main/resources/validationrules/sscs/sscs-judicial-office-holder-mapping.drl @@ -130,7 +130,6 @@ then .beginTime($jap.getBeginTime()) .endTime($jap.getEndTime()) .regionId($jap.getCftRegionIdV1()) - .region($jap.getCftRegion()) .baseLocationId($jap.getBaseLocationId()) .primaryLocation($jap.getPrimaryLocationId()) .contractType($jap.getAppointmentType()) diff --git a/src/main/resources/validationrules/sscs/sscs-judicial-org-role-mapping.drl b/src/main/resources/validationrules/sscs/sscs-judicial-org-role-mapping.drl index 5ed74aec2..96daf06f8 100644 --- a/src/main/resources/validationrules/sscs/sscs-judicial-org-role-mapping.drl +++ b/src/main/resources/validationrules/sscs/sscs-judicial-org-role-mapping.drl @@ -107,7 +107,7 @@ 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.getRegion())); + attribute.put("region", JacksonUtils.convertObjectIntoJsonNode($bk.getRegionId())); insert( RoleAssignment.builder() .actorIdType(ActorIdType.IDAM) diff --git a/src/test/java/uk/gov/hmcts/reform/orgrolemapping/domain/service/DroolSscsJudicialRoleMappingTest.java b/src/test/java/uk/gov/hmcts/reform/orgrolemapping/domain/service/DroolSscsJudicialRoleMappingTest.java index 335364985..b86a4c1c3 100644 --- a/src/test/java/uk/gov/hmcts/reform/orgrolemapping/domain/service/DroolSscsJudicialRoleMappingTest.java +++ b/src/test/java/uk/gov/hmcts/reform/orgrolemapping/domain/service/DroolSscsJudicialRoleMappingTest.java @@ -50,7 +50,7 @@ class DroolSscsJudicialRoleMappingTest extends DroolBase { expectedRoleNameWorkTypesMap.put("fee-paid-financial", "hearing_work,priority"); } - static void assertCommonRoleAssignmentAttributes(RoleAssignment r, String regionId, String region, String office) { + static void assertCommonRoleAssignmentAttributes(RoleAssignment r, String regionId, String office) { assertEquals(ActorIdType.IDAM, r.getActorIdType()); assertEquals(RoleType.ORGANISATION, r.getRoleType()); assertEquals(RoleCategory.JUDICIAL, r.getRoleCategory()); @@ -75,18 +75,12 @@ static void assertCommonRoleAssignmentAttributes(RoleAssignment r, String region assertFalse(r.isReadOnly()); assertEquals("2", primaryLocation); } - //region assertions if (r.getRoleName().equals("hmcts-judiciary") || office.contains("President of Tribunal")) { assertNull(r.getAttributes().get("region")); } else { - if (r.getRoleName().equals("judge") - && office.equals("SSCS Tribunal Judge-Fee Paid")) { - assertEquals(region, r.getAttributes().get("region").asText()); - } else { - assertEquals(regionId, r.getAttributes().get("region").asText()); - } + assertEquals(regionId, r.getAttributes().get("region").asText()); } String expectedWorkTypes = expectedRoleNameWorkTypesMap.get(r.getRoleName()); @@ -123,7 +117,7 @@ void shouldReturnSalariedRoles(String setOffice, String expectedRoles) { String regionId = allProfiles.iterator().next().getRegionId(); roleAssignments.forEach(r -> { assertEquals("Salaried", r.getAttributes().get("contractType").asText()); - assertCommonRoleAssignmentAttributes(r, regionId, null, setOffice); + assertCommonRoleAssignmentAttributes(r, regionId, setOffice); }); } @@ -142,11 +136,9 @@ void shouldReturnSalariedRoles(String setOffice, String expectedRoles) { "SSCS Tribunal Member Financially Qualified,'fee-paid-financial,hmcts-judiciary',false" }) void shouldReturnFeePaidRoles(String setOffice, String expectedRoles, boolean withBooking) throws IOException { - String region = "Edinburgh"; judicialOfficeHolders.forEach(joh -> { joh.setOffice(setOffice); joh.setTicketCodes(List.of("368")); - joh.setRegion(region); }); if (withBooking) { @@ -163,13 +155,28 @@ 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,r); assertEquals("Fee-Paid", r.getAttributes().get("contractType").asText()); - assertCommonRoleAssignmentAttributes(r, regionId, region, setOffice); + assertCommonRoleAssignmentAttributes(r, regionId, setOffice); }); } + private String setExpectedRegionId(String setOffice, boolean withBooking, RoleAssignment roleAssignment) { + if (setOffice.equals("SSCS Tribunal Judge-Fee Paid") && withBooking + && roleAssignment.getRoleName().equals("judge")) { + if (!judicialBookings.isEmpty()) { + return 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(); @@ -177,5 +184,6 @@ void createBooking(String setOffice) throws IOException { .orElse(JudicialOfficeHolder.builder().build()).getUserId()); judicialBooking.setLocationId("2"); judicialBookings = Set.of(judicialBooking); + ; } } From 85eadd49ef62f10878828ddff1ec36979c31d805 Mon Sep 17 00:00:00 2001 From: Anthony Dummer Date: Mon, 8 Jan 2024 18:47:02 +0000 Subject: [PATCH 6/8] COT-694 Resolving review findings to use values from the judicialBooking. --- .../domain/service/DroolSscsJudicialRoleMappingTest.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/test/java/uk/gov/hmcts/reform/orgrolemapping/domain/service/DroolSscsJudicialRoleMappingTest.java b/src/test/java/uk/gov/hmcts/reform/orgrolemapping/domain/service/DroolSscsJudicialRoleMappingTest.java index b86a4c1c3..46fc1914e 100644 --- a/src/test/java/uk/gov/hmcts/reform/orgrolemapping/domain/service/DroolSscsJudicialRoleMappingTest.java +++ b/src/test/java/uk/gov/hmcts/reform/orgrolemapping/domain/service/DroolSscsJudicialRoleMappingTest.java @@ -184,6 +184,5 @@ void createBooking(String setOffice) throws IOException { .orElse(JudicialOfficeHolder.builder().build()).getUserId()); judicialBooking.setLocationId("2"); judicialBookings = Set.of(judicialBooking); - ; } } From 2a994ce2a3a0ccd28779be930eb31c38bfc33cd6 Mon Sep 17 00:00:00 2001 From: Anthony Dummer Date: Wed, 10 Jan 2024 15:55:17 +0000 Subject: [PATCH 7/8] COT-694 region to be handeled in the same was as primary location if not present in booking, use joh value. --- .../validationrules/sscs/sscs-judicial-org-role-mapping.drl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/resources/validationrules/sscs/sscs-judicial-org-role-mapping.drl b/src/main/resources/validationrules/sscs/sscs-judicial-org-role-mapping.drl index 96daf06f8..f16411023 100644 --- a/src/main/resources/validationrules/sscs/sscs-judicial-org-role-mapping.drl +++ b/src/main/resources/validationrules/sscs/sscs-judicial-org-role-mapping.drl @@ -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($bk.getRegionId())); + attribute.put("region", JacksonUtils.convertObjectIntoJsonNode($bk.getRegionId() != null ? + $bk.getRegionId():$joh.getRegionId())); insert( RoleAssignment.builder() .actorIdType(ActorIdType.IDAM) From 76d045619214645021de47a5efb91ad53f417420 Mon Sep 17 00:00:00 2001 From: Anthony Dummer Date: Thu, 11 Jan 2024 11:09:09 +0000 Subject: [PATCH 8/8] COT-694 unit test added to test joh fallback of data for location and region. --- .../DroolSscsJudicialRoleMappingTest.java | 36 ++++++++++++------- 1 file changed, 23 insertions(+), 13 deletions(-) diff --git a/src/test/java/uk/gov/hmcts/reform/orgrolemapping/domain/service/DroolSscsJudicialRoleMappingTest.java b/src/test/java/uk/gov/hmcts/reform/orgrolemapping/domain/service/DroolSscsJudicialRoleMappingTest.java index 46fc1914e..19729ec55 100644 --- a/src/test/java/uk/gov/hmcts/reform/orgrolemapping/domain/service/DroolSscsJudicialRoleMappingTest.java +++ b/src/test/java/uk/gov/hmcts/reform/orgrolemapping/domain/service/DroolSscsJudicialRoleMappingTest.java @@ -123,19 +123,21 @@ 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")); @@ -143,6 +145,12 @@ void shouldReturnFeePaidRoles(String setOffice, String expectedRoles, boolean wi if (withBooking) { createBooking(setOffice); + if (johFallback) { + judicialBookings.forEach(jb -> { + jb.setRegionId(null); + jb.setLocationId(null); + }); + } } //Execute Kie session @@ -157,17 +165,19 @@ void shouldReturnFeePaidRoles(String setOffice, String expectedRoles, boolean wi assertEquals(expectedRoles.split(",").length, roleAssignments.size()); roleAssignments.forEach(r -> { - String regionId = setExpectedRegionId(setOffice,withBooking,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, RoleAssignment roleAssignment) { + 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 judicialBookings.iterator().next().getRegionId(); + return (johFallback ? judicialOfficeHolders.iterator().next().getRegionId() : + judicialBookings.iterator().next().getRegionId()); } else { return allProfiles.iterator().next().getRegionId(); }