diff --git a/src/functionalTest/resources/features/F-007/F-007.feature b/src/functionalTest/resources/features/F-007/F-007.feature index c534cb9e6..ebcdae361 100644 --- a/src/functionalTest/resources/features/F-007/F-007.feature +++ b/src/functionalTest/resources/features/F-007/F-007.feature @@ -18,7 +18,7 @@ Feature: F-007 :Create Role Assignments for CIVIL Caseworker and Judicial Users And a successful call [to delete existing role assignments corresponding to the test actorId] as in [S-061_DeleteDataForRoleAssignments]. @S-062 - @FeatureToggle(DB:civil_wa_1_6=on) @FeatureToggle(EV:CASEWORKER_FTA_ENABLED=on) + @FeatureToggle(DB:civil_wa_2_1=on) @FeatureToggle(EV:CASEWORKER_FTA_ENABLED=on) Scenario: must successfully create org role mapping for Hearing Centre Team Leader and Hearing Centre Administrator Given a user with [an active IDAM profile with full permissions], And a successful call [to delete existing role assignments corresponding to the test actorId] as in [S-062_DeleteDataForRoleAssignments], diff --git a/src/functionalTest/resources/features/F-007/S-062.td.json b/src/functionalTest/resources/features/F-007/S-062.td.json index 6d26759fc..e95baad0f 100644 --- a/src/functionalTest/resources/features/F-007/S-062.td.json +++ b/src/functionalTest/resources/features/F-007/S-062.td.json @@ -41,7 +41,7 @@ "primaryLocation": "[[ANYTHING_PRESENT]]", "jurisdiction": "CIVIL", "region": "2", - "workTypes": "hearing_work,routine_work" + "workTypes": "hearing_work,multi_track_hearing_work,intermediate_track_hearing_work,routine_work" } }, { @@ -60,7 +60,7 @@ "primaryLocation": "[[ANYTHING_PRESENT]]", "jurisdiction": "CIVIL", "region": "2", - "workTypes": "hearing_work,access_requests,routine_work" + "workTypes": "hearing_work,access_requests" } }, { diff --git a/src/main/java/uk/gov/hmcts/reform/orgrolemapping/domain/model/enums/FeatureFlagEnum.java b/src/main/java/uk/gov/hmcts/reform/orgrolemapping/domain/model/enums/FeatureFlagEnum.java index 562a4369e..44b945338 100644 --- a/src/main/java/uk/gov/hmcts/reform/orgrolemapping/domain/model/enums/FeatureFlagEnum.java +++ b/src/main/java/uk/gov/hmcts/reform/orgrolemapping/domain/model/enums/FeatureFlagEnum.java @@ -36,6 +36,7 @@ public enum FeatureFlagEnum { CIVIL_WA_1_8("civil_wa_1_8"), CIVIL_WA_1_9("civil_wa_1_9"), CIVIL_WA_2_0("civil_wa_2_0"), + CIVIL_WA_2_1("civil_wa_2_1"), PUBLICLAW_WA_1_3("publiclaw_wa_1_3"), PUBLICLAW_WA_1_4("publiclaw_wa_1_4"), IAC_JRD_1_1("iac_jrd_1_1"), diff --git a/src/main/resources/db/migration/V20241025_906__COT-906_CIVIL_WA_2_1_base_flag_addition.sql b/src/main/resources/db/migration/V20241025_906__COT-906_CIVIL_WA_2_1_base_flag_addition.sql new file mode 100644 index 000000000..889e356ce --- /dev/null +++ b/src/main/resources/db/migration/V20241025_906__COT-906_CIVIL_WA_2_1_base_flag_addition.sql @@ -0,0 +1,8 @@ +-- COT-906: insert civil_wa_2_1 base flag into flag_config table +INSERT INTO flag_config (flag_name, env, service_name, status) VALUES ('civil_wa_2_1', 'local', 'civil', 'true'); +INSERT INTO flag_config (flag_name, env, service_name, status) VALUES ('civil_wa_2_1', 'pr', 'civil', 'true'); +INSERT INTO flag_config (flag_name, env, service_name, status) VALUES ('civil_wa_2_1', 'aat', 'civil', 'false'); +INSERT INTO flag_config (flag_name, env, service_name, status) VALUES ('civil_wa_2_1', 'demo', 'civil', 'false'); +INSERT INTO flag_config (flag_name, env, service_name, status) VALUES ('civil_wa_2_1', 'perftest', 'civil', 'false'); +INSERT INTO flag_config (flag_name, env, service_name, status) VALUES ('civil_wa_2_1', 'ithc', 'civil', 'false'); +INSERT INTO flag_config (flag_name, env, service_name, status) VALUES ('civil_wa_2_1', 'prod', 'civil', 'false'); \ No newline at end of file diff --git a/src/main/resources/validationrules/civil/civil-admin-mapping.drl b/src/main/resources/validationrules/civil/civil-admin-mapping.drl index 9b94e25a3..39df1de68 100644 --- a/src/main/resources/validationrules/civil/civil-admin-mapping.drl +++ b/src/main/resources/validationrules/civil/civil-admin-mapping.drl @@ -234,11 +234,14 @@ end; /* * CIVIL admin "hearing-centre-team-leader" Org role mapping. v1.6 + * Made obsolete in COT-906 - disabled by CIVIL_WA_2_1 flag. + * To be removed in DTSAM-591. */ rule "v1_6_civil_hearing_centre_team_leader_org_role" when $f: FeatureFlag(status && flagName == FeatureFlagEnum.CIVIL_WA_1_6.getValue()) + $f2: FeatureFlag(status == false && flagName == FeatureFlagEnum.CIVIL_WA_2_1.getValue()) $cap: CaseWorkerAccessProfile(roleId in ("3"), serviceCode in ("AAA6", "AAA7"), !suspended) then Map attribute = new HashMap<>(); @@ -262,13 +265,46 @@ then logMsg("Rule : v1_6_civil_hearing_centre_team_leader_org_role"); end; +/* + * CIVIL admin "hearing-centre-team-leader" Org role mapping. v2.1 + */ + +rule "v2_1_civil_hearing_centre_team_leader_org_role" +when + $f: FeatureFlag(status && flagName == FeatureFlagEnum.CIVIL_WA_2_1.getValue()) + $cap: CaseWorkerAccessProfile(roleId in ("3"), serviceCode in ("AAA6", "AAA7"), !suspended) +then + Map attribute = new HashMap<>(); + attribute.put("jurisdiction", JacksonUtils.convertObjectIntoJsonNode("CIVIL")); + attribute.put("primaryLocation", JacksonUtils.convertObjectIntoJsonNode($cap.getPrimaryLocationId())); + attribute.put("workTypes", JacksonUtils.convertObjectIntoJsonNode("hearing_work,access_requests")); + attribute.put("region", JacksonUtils.convertObjectIntoJsonNode($cap.getRegionId())); + insert( + RoleAssignment.builder() + .actorIdType(ActorIdType.IDAM) + .actorId($cap.getId()) + .roleCategory(RoleCategory.ADMIN) + .roleType(RoleType.ORGANISATION) + .roleName("hearing-centre-team-leader") + .grantType(GrantType.STANDARD) + .classification(Classification.PUBLIC) + .readOnly(false) + .attributes(attribute) + .authorisations($cap.getSkillCodes()) + .build()); + logMsg("Rule : v2_1_civil_hearing_centre_team_leader_org_role"); +end; + /* * CIVIL admin "hearing-centre-admin" Org role mapping. v1.6 + * Made obsolete in COT-906 - disabled by CIVIL_WA_2_1 flag. + * To be removed in DTSAM-591. */ rule "v1_6_civil_hearing_centre_admin_org_role" when $f: FeatureFlag(status && flagName == FeatureFlagEnum.CIVIL_WA_1_6.getValue()) + $f2: FeatureFlag(status == false && flagName == FeatureFlagEnum.CIVIL_WA_2_1.getValue()) $cap: CaseWorkerAccessProfile(roleId in ("3", "4"), serviceCode in ("AAA6", "AAA7"), !suspended) then Map attribute = new HashMap<>(); @@ -292,6 +328,37 @@ then logMsg("Rule : v1_6_civil_hearing_centre_admin_org_role"); end; +/* + * CIVIL admin "hearing-centre-admin" Org role mapping. v2.1 + */ + +rule "v2_1_civil_hearing_centre_admin_org_role" +when + $f: FeatureFlag(status && flagName == FeatureFlagEnum.CIVIL_WA_2_1.getValue()) + $cap: CaseWorkerAccessProfile(roleId in ("3", "4"), serviceCode in ("AAA6", "AAA7"), !suspended) +then + Map attribute = new HashMap<>(); + attribute.put("jurisdiction", JacksonUtils.convertObjectIntoJsonNode("CIVIL")); + attribute.put("primaryLocation", JacksonUtils.convertObjectIntoJsonNode($cap.getPrimaryLocationId())); + attribute.put("workTypes", JacksonUtils.convertObjectIntoJsonNode("hearing_work,multi_track_hearing_work," + + "intermediate_track_hearing_work,routine_work")); + attribute.put("region", JacksonUtils.convertObjectIntoJsonNode($cap.getRegionId())); + insert( + RoleAssignment.builder() + .actorIdType(ActorIdType.IDAM) + .actorId($cap.getId()) + .roleCategory(RoleCategory.ADMIN) + .roleType(RoleType.ORGANISATION) + .roleName("hearing-centre-admin") + .grantType(GrantType.STANDARD) + .classification(Classification.PUBLIC) + .readOnly(false) + .attributes(attribute) + .authorisations($cap.getSkillCodes()) + .build()); + logMsg("Rule : v2_1_civil_hearing_centre_admin_org_role"); +end; + /* * CIVIL admin "task-supervisor" Org role mapping. */ diff --git a/src/test/java/uk/gov/hmcts/reform/orgrolemapping/domain/service/DroolCivilStaffOrgRolesTest.java b/src/test/java/uk/gov/hmcts/reform/orgrolemapping/domain/service/DroolCivilStaffOrgRolesTest.java index a40a3219c..4eb91724b 100644 --- a/src/test/java/uk/gov/hmcts/reform/orgrolemapping/domain/service/DroolCivilStaffOrgRolesTest.java +++ b/src/test/java/uk/gov/hmcts/reform/orgrolemapping/domain/service/DroolCivilStaffOrgRolesTest.java @@ -41,11 +41,12 @@ class DroolCivilStaffOrgRolesTest extends DroolBase { static { expectedRoleNameWorkTypesMap.put("hmcts-admin", null); - expectedRoleNameWorkTypesMap.put("hearing-centre-team-leader", "hearing_work,access_requests,routine_work"); + expectedRoleNameWorkTypesMap.put("hearing-centre-team-leader", "hearing_work,access_requests"); expectedRoleNameWorkTypesMap.put("hmcts-ctsc", null); expectedRoleNameWorkTypesMap.put("ctsc", "routine_work"); expectedRoleNameWorkTypesMap.put("ctsc-team-leader", "routine_work,access_requests"); - expectedRoleNameWorkTypesMap.put("hearing-centre-admin", "hearing_work,routine_work"); + expectedRoleNameWorkTypesMap.put("hearing-centre-admin", + "hearing_work,multi_track_hearing_work,intermediate_track_hearing_work,routine_work"); expectedRoleNameWorkTypesMap.put("senior-tribunal-caseworker", "decision_making_work,access_requests"); expectedRoleNameWorkTypesMap.put("tribunal-caseworker", "decision_making_work"); expectedRoleNameWorkTypesMap.put("hmcts-legal-operations", null);