Skip to content

Commit

Permalink
Pass Business Unit Id to/from FE
Browse files Browse the repository at this point in the history
  • Loading branch information
RustyHMCTS committed Mar 7, 2024
1 parent a2455f5 commit 77a443d
Show file tree
Hide file tree
Showing 10 changed files with 15 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Feature: tests for changes to postedBy and postedByAAD
And the add notes response contains
| associatedRecordId | 500000010 |
| noteText | test postedBy and PostedByAAD Opal user1 |
| postedBy | L070KG |
| postedBy | L017KG |
| postedByAAD | gl.userfour |

Given I am testing as the "[email protected]" user
Expand Down Expand Up @@ -39,5 +39,5 @@ Feature: tests for changes to postedBy and postedByAAD
And the add notes response contains
| associatedRecordId | 500000010 |
| noteText | test postedBy and PostedByAAD Opal user4 |
| postedBy | L096GH |
| postedBy | L095GH |
| postedByAAD | humber.usertwo |
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public void testHandleOauthCode() throws Exception {
.userName("name")
.userId("123")
.roles(Set.of(Role.builder()
.businessUnit("B123")
.businessUnitId((short)123)
.businessUserId("BU123")
.permissions(Set.of(
Permission.builder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public class Role {
String businessUserId;

@NonNull
String businessUnit;
Short businessUnitId;

@EqualsAndHashCode.Exclude
@NonNull
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public ResponseEntity<DefendantAccountEntity> putDefendantAccount(

@GetMapping(value = "/{defendantAccountId}")
@Operation(summary = "Get defendant account details by providing the defendant account summary")
public ResponseEntity<AccountDetailsDto> getAccountDetailsByAccountSummary(@PathVariable Long defendantAccountId) {
public ResponseEntity<AccountDetailsDto> getAccountDetails(@PathVariable Long defendantAccountId) {

AccountDetailsDto response = defendantAccountService.getAccountDetailsByDefendantAccountId(defendantAccountId);

Expand Down
5 changes: 4 additions & 1 deletion src/main/java/uk/gov/hmcts/opal/dto/AccountDetailsDto.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,12 @@ public class AccountDetailsDto implements ToJsonString {
// parties.surname, parties,initials, parties.forenames, parties.title
private String fullName;

// business_units.business_unit_type
// business_units.business_unit_name
private String accountCT;

// business_units.business_unit_id
private Short businessUnitId;

//parties.address_line_(*)
private String address;

Expand Down
1 change: 1 addition & 0 deletions src/main/java/uk/gov/hmcts/opal/dto/AddNoteDto.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,6 @@
@Jacksonized
public class AddNoteDto implements ToJsonString {
private String associatedRecordId;
private Short businessUnitId;
private String noteText;
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public Set<Role> getAuthorisationRolesByUserId(String userId) {

return buuList.stream().map(buu -> Role.builder()
.businessUserId(buu.getBusinessUnitUserId())
.businessUnit(buu.getBusinessUnit().getBusinessUnitId().toString())
.businessUnitId(buu.getBusinessUnit().getBusinessUnitId())
.permissions(userEntitlementService.getPermissionsByBusinessUnitUserId(buu.getBusinessUnitUserId()))
.build()).collect(Collectors.toSet());

Expand All @@ -65,7 +65,7 @@ public Set<Role> getLimitedRolesByUserId(String userId) {

return buuList.stream().map(buu -> Role.builder()
.businessUserId(buu.getBusinessUnitUserId())
.businessUnit(buu.getBusinessUnit().getBusinessUnitId().toString())
.businessUnitId(buu.getBusinessUnit().getBusinessUnitId())
.permissions(Collections.emptySet()) // We are assuming that Permissions exist for this Role.
.build()).collect(Collectors.toSet());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ public AccountDetailsDto getAccountDetailsByDefendantAccountId(Long defendantAcc
? partyEntity.getFullName()
: partyEntity.getOrganisationName())
.accountCT(defendantAccountEntity.getBusinessUnit().getBusinessUnitName())
.businessUnitId(defendantAccountEntity.getBusinessUnit().getBusinessUnitId())
.address(fullAddress)
.postCode(partyEntity.getPostcode())
.dob(partyEntity.getDateOfBirth())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public Optional<UserState> getUserStateByUsername(String username) {
.userName(u.getUsername())
.roles(businessUnitUsers.stream().map(buu -> Role.builder()
.businessUserId(buu.getBusinessUnitUserId())
.businessUnit(buu.getBusinessUnit().getBusinessUnitId().toString())
.businessUnitId(buu.getBusinessUnit().getBusinessUnitId())
.permissions(toPermissions(entitlementsMap.get(buu.getBusinessUnitUserId())))
.build()).collect(toSet()))
.build());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public void testGetDefendantAccountDetails_Success() {

// Act
ResponseEntity<AccountDetailsDto> responseEntity = defendantAccountController
.getAccountDetailsByAccountSummary(1L);
.getAccountDetails(1L);

// Assert
assertEquals(HttpStatus.OK, responseEntity.getStatusCode());
Expand Down

0 comments on commit 77a443d

Please sign in to comment.