Skip to content

Commit

Permalink
Merge branch 'master' into AM-2920_Reenable_Tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mikebrownccd authored Jan 15, 2024
2 parents 8834c9c + c0b1a64 commit 6613a4e
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 27 deletions.
8 changes: 4 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ buildscript {

plugins {
id 'application'
id 'uk.gov.hmcts.java' version '0.12.47'
id 'uk.gov.hmcts.java' version '0.12.54'
id 'pmd'
id 'jacoco'
id 'io.spring.dependency-management' version '1.1.4'
Expand Down Expand Up @@ -344,7 +344,7 @@ dependencies {
implementation group: 'org.springframework.security', name:'spring-security-oauth2-core', version: versions.springSecurity
implementation group: 'org.springframework.security', name:'spring-security-oauth2-jose', version: versions.springSecurity
implementation group: 'org.springframework.security', name:'spring-security-oauth2-resource-server', version: versions.springSecurity
implementation group: 'org.springframework.retry', name: 'spring-retry', version: '2.0.4'
implementation group: 'org.springframework.retry', name: 'spring-retry', version: '2.0.5'
implementation group: 'org.springframework.cloud', name: 'spring-cloud-starter-netflix-hystrix', version: '2.2.10.RELEASE'
implementation group: 'org.springframework.cloud', name: 'spring-cloud-starter-bootstrap', version: '3.1.7'
implementation group: 'org.springframework.hateoas', name: 'spring-hateoas', version: '1.5.6'
Expand All @@ -367,7 +367,7 @@ dependencies {
implementation group: 'com.github.hmcts', name:'properties-volume-spring-boot-starter', version:'0.1.1'
implementation group: 'commons-beanutils', name: 'commons-beanutils', version: '1.9.4'
implementation group: 'commons-fileupload', name: 'commons-fileupload', version: '1.5'
implementation group: 'org.json', name: 'json', version: '20230227'
implementation group: 'org.json', name: 'json', version: '20231013'
implementation group: 'javax.inject', name: 'javax.inject', version: '1'

implementation group: 'com.microsoft.azure', name: 'applicationinsights-spring-boot-starter', version: '2.6.4'
Expand Down Expand Up @@ -425,7 +425,7 @@ dependencies {

implementation group: 'org.apache.poi', name: 'poi', version: '5.2.5'
implementation group: 'org.apache.poi', name: 'poi-ooxml', version: '5.2.5'
implementation group: 'org.apache.poi', name: 'poi-scratchpad', version: '5.2.4'
implementation group: 'org.apache.poi', name: 'poi-scratchpad', version: '5.2.5'

//Dependent on drools Jar. Can be removed CVE-2021-26291
implementation group: 'org.apache.maven', name: 'maven-core', version: '3.8.7'
Expand Down
4 changes: 0 additions & 4 deletions config/owasp/suppressions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,6 @@
<notes>https://tools.hmcts.net/jira/browse/AM-2952 plexus</notes>
<cve>CVE-2022-4245</cve>
</suppress>
<suppress>
<notes>https://tools.hmcts.net/jira/browse/AM-3002 json-java</notes>
<cve>CVE-2023-5072</cve>
</suppress>
<suppress>
<notes>https://tools.hmcts.net/jira/browse/AM-3065 azure</notes>
<cve>CVE-2023-36052</cve>
Expand Down
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 6613a4e

Please sign in to comment.