Skip to content

Commit

Permalink
Merge branch 'master' into COT-484_Civil_DJ_SiR_correct_appt_name
Browse files Browse the repository at this point in the history
  • Loading branch information
mattnayler authored Nov 6, 2023
2 parents d669d16 + 9a49f5c commit 1df67d7
Show file tree
Hide file tree
Showing 6 changed files with 162 additions and 22 deletions.
2 changes: 1 addition & 1 deletion Jenkinsfile_CNP
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def secrets = [
]

// Configure branches to sync with master branch
def branchesToSync = ['demo', 'perftest', 'ithc']
def branchesToSync = ['demo']

// Vars needed for functional and smoke tests run against AKS
env.IDAM_URL = "https://idam-api.aat.platform.hmcts.net"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ public enum FeatureFlagEnum {
PRIVATELAW_WA_1_2("privatelaw_wa_1_2"),
ST_CIC_WA_1_0("st_cic_wa_1_0"),
PUBLICLAW_WA_1_1("publiclaw_wa_1_1"),
CIVIL_WA_1_2("civil_wa_1_2");
CIVIL_WA_1_2("civil_wa_1_2"),
PRIVATELAW_WA_1_3("privatelaw_wa_1_3");

private final String value;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
INSERT INTO flag_config (flag_name, env, service_name, status) VALUES ('privatelaw_wa_1_3', 'local', 'iac', 'true');
INSERT INTO flag_config (flag_name, env, service_name, status) VALUES ('privatelaw_wa_1_3', 'pr', 'iac', 'true');
INSERT INTO flag_config (flag_name, env, service_name, status) VALUES ('privatelaw_wa_1_3', 'aat', 'iac', 'false');
INSERT INTO flag_config (flag_name, env, service_name, status) VALUES ('privatelaw_wa_1_3', 'demo', 'iac', 'false');
INSERT INTO flag_config (flag_name, env, service_name, status) VALUES ('privatelaw_wa_1_3', 'perftest', 'iac', 'false');
INSERT INTO flag_config (flag_name, env, service_name, status) VALUES ('privatelaw_wa_1_3', 'ithc', 'iac', 'false');
INSERT INTO flag_config (flag_name, env, service_name, status) VALUES ('privatelaw_wa_1_3', 'prod', 'iac', 'false');
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
-- enable privatelaw_wa_1_3 flag in Prod for: AM-3018 / AM-3032
update flag_config set status='true' where flag_name='privatelaw_wa_1_3' and env in ('demo', 'aat', 'perftest', 'ithc', 'prod');
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import function uk.gov.hmcts.reform.orgrolemapping.domain.service.RequestMapping
rule "privatelaw_judge_org_role"
when
$f: FeatureFlag(status && flagName == FeatureFlagEnum.PRIVATELAW_WA_1_0.getValue())
$f2: FeatureFlag(status == false, flagName == FeatureFlagEnum.PRIVATELAW_WA_1_3.getValue())
$joh: JudicialOfficeHolder(office in ( "PRIVATELAW District Judge-Salaried", "PRIVATELAW Presiding Judge-Salaried",
"PRIVATELAW Resident Judge-Salaried", "PRIVATELAW Designated Family Judge-Salaried",
"PRIVATELAW District Judge (MC)-Salaried"))
Expand Down Expand Up @@ -52,6 +53,41 @@ then
logMsg("Rule : privatelaw_judge_org_role");
end;

/*
* PRIVATELAW "judge" Org role mapping.
*/
rule "privatelaw_judge_org_role_v13"
when
$f: FeatureFlag(status && flagName == FeatureFlagEnum.PRIVATELAW_WA_1_3.getValue())
$joh: JudicialOfficeHolder(office in ( "PRIVATELAW District Judge-Salaried", "PRIVATELAW Presiding Judge-Salaried",
"PRIVATELAW Resident Judge-Salaried", "PRIVATELAW Designated Family Judge-Salaried",
"PRIVATELAW District Judge (MC)-Salaried", "PRIVATELAW Circuit Judge-Salaried",
"PRIVATELAW High Court Judge-Salaried"))
then
Map<String,JsonNode> attribute = new HashMap<>();
attribute.put("contractType", JacksonUtils.convertObjectIntoJsonNode("Salaried"));
attribute.put("jurisdiction", JacksonUtils.convertObjectIntoJsonNode("PRIVATELAW"));
attribute.put("primaryLocation", JacksonUtils.convertObjectIntoJsonNode($joh.getPrimaryLocation()));
attribute.put("region", JacksonUtils.convertObjectIntoJsonNode($joh.getRegionId()));
attribute.put("workTypes", JacksonUtils.convertObjectIntoJsonNode("hearing_work,decision_making_work,applications"));
insert(
RoleAssignment.builder()
.actorIdType(ActorIdType.IDAM)
.actorId($joh.getUserId())
.roleCategory(RoleCategory.JUDICIAL)
.roleType(RoleType.ORGANISATION)
.roleName("judge")
.grantType(GrantType.STANDARD)
.classification(Classification.PUBLIC)
.readOnly(false)
.beginTime($joh.getBeginTime())
.endTime($joh.getEndTime() !=null ? $joh.getEndTime().plusDays(1):null)
.attributes(attribute)
.authorisations($joh.getTicketCodes())
.build());
logMsg("Rule : privatelaw_judge_org_role_v13");
end;

/*
* PRIVATELAW "leadership-judge" Org role mapping.
*/
Expand Down Expand Up @@ -338,6 +374,7 @@ end;
rule "privatelaw_judge_org_role_for_fee_paid_judge"
when
$f: FeatureFlag(status && flagName == FeatureFlagEnum.PRIVATELAW_WA_1_0.getValue())
$f2: FeatureFlag(status == false, flagName == FeatureFlagEnum.PRIVATELAW_WA_1_3.getValue())
$joh: JudicialOfficeHolder(office in ("PRIVATELAW Deputy District Judge-Fee-Paid",
"PRIVATELAW Recorder-Fee-Paid",
"PRIVATELAW Deputy District Judge - Sitting in Retirement-Fee-Paid",
Expand Down Expand Up @@ -375,6 +412,52 @@ then
logMsg("Rule : privatelaw_judge_org_role_for_fee_paid_judge");
end;


/*
* PRIVATELAW "judge" org role can be created by any existing judicial office holder having
* "PRIVATELAW Deputy Judge-Fee-Paid, PRIVATELAW Recorder-Fee-Paid,PRIVATELAW Deputy District Judge - Sitting in Retirement-Fee-Paid" business role.
*/
rule "privatelaw_judge_org_role_for_fee_paid_judge_v13"
when
$f: FeatureFlag(status && flagName == FeatureFlagEnum.PRIVATELAW_WA_1_3.getValue())
$joh: JudicialOfficeHolder(office in ("PRIVATELAW Deputy District Judge-Fee-Paid",
"PRIVATELAW Recorder-Fee-Paid",
"PRIVATELAW Deputy District Judge - Sitting in Retirement-Fee-Paid",
"PRIVATELAW Deputy District Judge – PRFD-Fee-Paid",
"PRIVATELAW Deputy District Judge – (MC)-Fee-Paid",
"PRIVATELAW Deputy District Judge – (MC)-Sitting in Retirement-Fee-Paid",
"PRIVATELAW Deputy High Court Judge-Fee-Paid",
"PRIVATELAW High Court Judge - Sitting in Retirement-Fee-Paid",
"PRIVATELAW Deputy Circuit Judge-Fee-Paid"))
$bk: JudicialBooking(userId == $joh.userId)
then
Map<String,JsonNode> attribute = new HashMap<>();
attribute.put("jurisdiction", JacksonUtils.convertObjectIntoJsonNode("PRIVATELAW"));
attribute.put("primaryLocation", JacksonUtils.convertObjectIntoJsonNode($bk.getLocationId() != null ?
$bk.getLocationId():$joh.getPrimaryLocation()));
attribute.put("baseLocation", JacksonUtils.convertObjectIntoJsonNode($bk.getLocationId()));
attribute.put("region", JacksonUtils.convertObjectIntoJsonNode($bk.getRegionId()));
attribute.put("contractType", JacksonUtils.convertObjectIntoJsonNode("Fee-Paid"));
attribute.put("workTypes", JacksonUtils.convertObjectIntoJsonNode("hearing_work,decision_making_work,applications"));

insert(
RoleAssignment.builder()
.actorIdType(ActorIdType.IDAM)
.actorId($joh.getUserId())
.roleCategory(RoleCategory.JUDICIAL)
.roleType(RoleType.ORGANISATION)
.roleName("judge")
.grantType(GrantType.STANDARD)
.classification(Classification.PUBLIC)
.readOnly(false)
.beginTime($bk.getBeginTime())
.endTime($bk.getEndTime())
.attributes(attribute)
.authorisations($joh.getTicketCodes())
.build());
logMsg("Rule : privatelaw_judge_org_role_for_fee_paid_judge_v13");
end;

/*
* PRIVATELAW "magistrate" Org role mapping.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import org.junit.runner.RunWith;
import org.mockito.junit.MockitoJUnitRunner;
import uk.gov.hmcts.reform.orgrolemapping.domain.model.Authorisation;
import uk.gov.hmcts.reform.orgrolemapping.domain.model.FeatureFlag;
import uk.gov.hmcts.reform.orgrolemapping.domain.model.JudicialAccessProfile;
import uk.gov.hmcts.reform.orgrolemapping.domain.model.JudicialBooking;
import uk.gov.hmcts.reform.orgrolemapping.domain.model.RoleAssignment;
Expand Down Expand Up @@ -40,83 +41,128 @@ class DroolPrivateLawJudicialRoleMappingTest extends DroolBase {
"Deputy Circuit Judge");

static Stream<Arguments> endToEndData() {
// Parameters String appointment, String appointmentType, List<String> assignedRoles,
// List<String> expectedRoleNames boolean privateLawV13IsEnabled
return Stream.of(
Arguments.of("Circuit Judge",
"Salaried",
List.of(""),
List.of("circuit-judge", "hmcts-judiciary")),
List.of("circuit-judge", "hmcts-judiciary"),
false),
Arguments.of("Circuit Judge",
"Salaried",
List.of(""),
List.of("judge", "circuit-judge", "hmcts-judiciary"),
true),
Arguments.of("Circuit Judge",
"SPTW",
List.of(""),
List.of("circuit-judge", "hmcts-judiciary"),
false),
Arguments.of("Circuit Judge",
"SPTW",
List.of(""),
List.of("judge", "circuit-judge", "hmcts-judiciary"),
true),
Arguments.of("Deputy Circuit Judge",
"Fee Paid",
List.of(""),
List.of("circuit-judge", "fee-paid-judge", "hmcts-judiciary"),
false),
Arguments.of("Deputy Circuit Judge",
"Fee Paid",
List.of(""),
List.of("circuit-judge", "fee-paid-judge", "hmcts-judiciary")),
List.of("judge","circuit-judge", "fee-paid-judge", "hmcts-judiciary"),
true),
Arguments.of("Deputy District Judge - PRFD",
"Fee Paid",
List.of("Deputy District Judge"),
List.of("judge", "fee-paid-judge", "hmcts-judiciary")),
List.of("judge", "fee-paid-judge", "hmcts-judiciary"),
true),
Arguments.of("Deputy District Judge (MC)- Fee paid",
"Fee Paid",
List.of("Deputy District Judge"),
List.of("judge", "fee-paid-judge", "hmcts-judiciary")),
List.of("judge", "fee-paid-judge", "hmcts-judiciary"),
true),
Arguments.of("Deputy District Judge (MC)- Sitting in Retirement",
"Fee Paid",
List.of("Deputy District Judge"),
List.of("judge", "fee-paid-judge", "hmcts-judiciary")),
List.of("judge", "fee-paid-judge", "hmcts-judiciary"),
true),
Arguments.of("Deputy District Judge- Fee-Paid",
"Fee Paid",
List.of(""),
List.of("judge", "fee-paid-judge", "hmcts-judiciary")),
List.of("judge", "fee-paid-judge", "hmcts-judiciary"),
true),
Arguments.of("Deputy District Judge- Sitting in Retirement",
"Fee Paid",
List.of(""),
List.of("judge", "fee-paid-judge", "hmcts-judiciary")),
List.of("judge", "fee-paid-judge", "hmcts-judiciary"),
true),
Arguments.of("Deputy High Court Judge",
"Fee Paid",
List.of("Deputy High Court Judge"),
List.of("judge","fee-paid-judge","hmcts-judiciary")),
List.of("judge","fee-paid-judge","hmcts-judiciary"),
true),
Arguments.of("District Judge",
"Salaried",
List.of(""),
List.of("judge", "hmcts-judiciary")),
List.of("judge", "hmcts-judiciary"),
true),
Arguments.of("District Judge (MC)",
"SPTW",
List.of("District Judge"),
List.of("judge","hmcts-judiciary")),
List.of("judge","hmcts-judiciary"),
true),
Arguments.of("High Court Judge",
"Salaried",
List.of(""),
List.of("circuit-judge", "hmcts-judiciary")),
List.of("circuit-judge", "hmcts-judiciary"),
false),
Arguments.of("High Court Judge",
"Salaried",
List.of(""),
List.of("judge", "circuit-judge", "hmcts-judiciary"),
true),
Arguments.of("High Court Judge- Sitting in Retirement",
"Fee Paid",
List.of("High Court Judge"),
List.of("judge", "fee-paid-judge", "hmcts-judiciary")),
List.of("judge", "fee-paid-judge", "hmcts-judiciary"),
true),
Arguments.of("Recorder",
"Fee Paid",
List.of(""),
List.of("judge", "fee-paid-judge", "hmcts-judiciary")),
List.of("judge", "fee-paid-judge", "hmcts-judiciary"),
true),
Arguments.of("",
"",
List.of("Designated Family Judge"),
List.of("leadership-judge","judge","task-supervisor","hmcts-judiciary","case-allocator",
"specific-access-approver-judiciary")),
"specific-access-approver-judiciary"),
true),
Arguments.of("",
"",
List.of("Family Division Liaison Judge"),
List.of("judge", "hmcts-judiciary")),
List.of("judge", "hmcts-judiciary"),
true),
Arguments.of("",
"",
List.of("Senior Family Liaison Judge"),
List.of("judge", "hmcts-judiciary")),
List.of("judge", "hmcts-judiciary"),
true),
Arguments.of("Magistrate", "Voluntary",
List.of("Magistrates-Voluntary"),
List.of("magistrate")
List.of("magistrate"),
true
)
);
}

@ParameterizedTest
@MethodSource("endToEndData")
void shouldTakeJudicialAccessProfileConvertToJudicialOfficeHolderThenReturnRoleAssignments(
String appointment, String appointmentType, List<String> assignedRoles, List<String> expectedRoleNames) {
String appointment, String appointmentType, List<String> assignedRoles, List<String> expectedRoleNames,
boolean privateLawV13IsEnabled) {

judicialAccessProfiles.clear();
judicialOfficeHolders.clear();
Expand All @@ -142,8 +188,9 @@ void shouldTakeJudicialAccessProfileConvertToJudicialOfficeHolderThenReturnRoleA
);

//Execute Kie session
List<RoleAssignment> roleAssignments =
buildExecuteKieSession(getFeatureFlags("privatelaw_wa_1_0", true));
List<RoleAssignment> roleAssignments = buildExecuteKieSession(List.of(
FeatureFlag.builder().flagName("privatelaw_wa_1_0").status(true).build(),
FeatureFlag.builder().flagName("privatelaw_wa_1_3").status(privateLawV13IsEnabled).build()));

//assertions
assertFalse(roleAssignments.isEmpty());
Expand Down

0 comments on commit 1df67d7

Please sign in to comment.