Skip to content

Commit

Permalink
DTSAM-584 Expand Civil Drool test coverage of service code AAA7 (#2138)
Browse files Browse the repository at this point in the history
* DTSAM-584 Expand Civil Drool test coverage of service code AAA7

* SERVICE_CODE_2 corrected to AAA7
  • Loading branch information
mikebrownccd authored Oct 29, 2024
1 parent 48135e9 commit 2deaa72
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,17 @@ static Stream<Arguments> endToEndData() {
void shouldTakeJudicialAccessProfileConvertToJudicialOfficeHolderThenReturnRoleAssignments(
String appointment, String appointmentType, boolean addBooking,
List<String> assignedRoles, List<String> expectedRoleNames) {
// As CIVIL has 2 service codes AAA6 and AAA7 and the JudicialAccessProfile has only one service code we run
// the test method twice, once with each service code
shouldTakeJudicialAccessProfileConvertToJudicialOfficeHolderThenReturnRoleAssignments(
appointment, appointmentType, addBooking, assignedRoles, expectedRoleNames, "AAA6");
shouldTakeJudicialAccessProfileConvertToJudicialOfficeHolderThenReturnRoleAssignments(
appointment, appointmentType, addBooking, assignedRoles, expectedRoleNames, "AAA7");
}

void shouldTakeJudicialAccessProfileConvertToJudicialOfficeHolderThenReturnRoleAssignments(
String appointment, String appointmentType, boolean addBooking,
List<String> assignedRoles, List<String> expectedRoleNames, String serviceCode) {

allProfiles.clear();
judicialAccessProfiles.clear();
Expand All @@ -157,10 +168,10 @@ void shouldTakeJudicialAccessProfileConvertToJudicialOfficeHolderThenReturnRoleA
.roles(assignedRoles)
.regionId("LDN")
.primaryLocationId("London")
.ticketCodes(List.of("AAA6"))
.ticketCodes(List.of(serviceCode))
.authorisations(List.of(
Authorisation.builder()
.serviceCodes(List.of("AAA6"))
.serviceCodes(List.of(serviceCode))
.jurisdiction("CIVIL")
.endDate(LocalDateTime.now().plusYears(1L))
.build()
Expand All @@ -183,7 +194,7 @@ void shouldTakeJudicialAccessProfileConvertToJudicialOfficeHolderThenReturnRoleA
if (!r.getRoleName().contains("hmcts-judiciary")) {
assertEquals(Classification.PUBLIC, r.getClassification());
assertEquals(GrantType.STANDARD, r.getGrantType());
assertEquals("AAA6", r.getAuthorisations().get(0));
assertEquals(serviceCode, r.getAuthorisations().get(0));
if (!addBooking) {
assertEquals("London", r.getAttributes().get("primaryLocation").asText());
}
Expand All @@ -204,7 +215,7 @@ void shouldTakeJudicialAccessProfileConvertToJudicialOfficeHolderThenReturnRoleA
if (r.getRoleName().contains("magistrate")) {
assertEquals(Classification.PUBLIC, r.getClassification());
assertEquals(GrantType.STANDARD, r.getGrantType());
assertEquals("AAA6", r.getAuthorisations().get(0));
assertEquals(serviceCode, r.getAuthorisations().get(0));
assertEquals("LDN", r.getAttributes().get("region").asText());
assertEquals("London", r.getAttributes().get("primaryLocation").asText());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@
@RunWith(MockitoJUnitRunner.class)
class DroolCivilStaffOrgRolesTest extends DroolBase {

static final String SERVICE_CODE = "AAA6";
static final String SERVICE_CODE_1 = "AAA6";
static final String SERVICE_CODE_2 = "AAA7";
static final String REGION_ID = "region1";
static final String JURISDICTION = "CIVIL";
static final String ROLE_TYPE = "ORGANISATION";
Expand Down Expand Up @@ -142,14 +143,29 @@ void shouldReturnCivilAdminMappings_v14(String roleId,
RoleCategory expectedRoleCategory,
String taskSupervisorFlag,
String taskAllocatorFlag) {
// As CIVIL has 2 service codes AAA6 and AAA7 and the CaseWorkerAccessProfile has one service code we run
// the test method twice, once with each service code
shouldReturnCivilAdminMappings_v14(roleId, roleNames, roleCount, expectedRoleCategory, taskSupervisorFlag,
taskAllocatorFlag, SERVICE_CODE_1);
shouldReturnCivilAdminMappings_v14(roleId, roleNames, roleCount, expectedRoleCategory, taskSupervisorFlag,
taskAllocatorFlag, SERVICE_CODE_2);
}

void shouldReturnCivilAdminMappings_v14(String roleId,
List<String> roleNames,
int roleCount,
RoleCategory expectedRoleCategory,
String taskSupervisorFlag,
String taskAllocatorFlag,
String serviceCode) {

judicialAccessProfiles.clear();
judicialOfficeHolders.clear();

CaseWorkerAccessProfile cap = UserAccessProfileBuilder.buildUserAccessProfileForRoleId3();
List<String> skillCodes = List.of("civil", "test", "ctsc");
cap.setRoleId(roleId);
cap.setServiceCode(SERVICE_CODE);
cap.setServiceCode(serviceCode);
cap.setSuspended(false);
cap.setRegionId(REGION_ID);
cap.setSkillCodes(skillCodes);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,11 @@ void shouldReturnHearingJudicialRoles(String serviceCode, String jurisdiction) {

@ParameterizedTest
@CsvSource({
"BBA3",
"ABA5",
"AAA6",
"BFA1"
"BBA3", // SSCS
"ABA5", // PRIVATELAW
"AAA6", // CIVIL
"AAA7", // CIVIL
"BFA1" // IA
})
void shouldReturnEmptyRoles_expiredAuthorisation(String serviceCode) {

Expand All @@ -76,10 +77,11 @@ void shouldReturnEmptyRoles_expiredAuthorisation(String serviceCode) {

@ParameterizedTest
@CsvSource({
"BBA3",
"ABA5",
"AAA6",
"BFA1"
"BBA3", // SSCS
"ABA5", // PRIVATELAW
"AAA6", // CIVIL
"AAA7", // CIVIL
"BFA1" // IA
})
void shouldReturnEmptyRoles_expiredAppointment(String serviceCode) {

Expand Down Expand Up @@ -124,6 +126,7 @@ void shouldReturnEmptyRoles(boolean ldFlag, String serviceCode) {
"'3,4',ABA3,PUBLICLAW",
"'3,4',ABA5,PRIVATELAW",
"'3,4,6,11',AAA6,CIVIL",
"'3,4,6,11',AAA7,CIVIL",
"'3,4,5,12,13',BHA1,EMPLOYMENT",
"'3,4,5,6,7,8',BFA1,IA"
})
Expand Down Expand Up @@ -154,6 +157,7 @@ void shouldReturnHearingManagerAndViewerCaseWorker_Admin(String roleId, String s
"'9,10',ABA5,PRIVATELAW",
"'9,10',ABA3,PUBLICLAW",
"'9,10',AAA6,CIVIL",
"'9,10',AAA7,CIVIL",
"'9,10',BHA1,EMPLOYMENT",
"'9,10',BFA1,IA",
"'9,10',BBA3,SSCS"
Expand Down Expand Up @@ -195,6 +199,8 @@ void shouldReturnHearingManagerAndViewerCaseWorker_Ctsc(String roleId, String se
"1,ABA5,PRIVATELAW",
"1,AAA6,CIVIL",
"2,AAA6,CIVIL",
"1,AAA7,CIVIL",
"2,AAA7,CIVIL",
"1,BHA1,EMPLOYMENT",
"2,BHA1,EMPLOYMENT",
"1,BFA1,IA",
Expand Down

0 comments on commit 2deaa72

Please sign in to comment.