Skip to content

Commit

Permalink
[SELC-4587] Feat: Added sorted in user's institutions list (#410)
Browse files Browse the repository at this point in the history
  • Loading branch information
flaminiaScarciofolo committed Apr 15, 2024
1 parent 9134100 commit 87923a8
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ public List<InstitutionBase> getUserInstitutions(String userId) {

List<InstitutionBase> result = userInfoResponse.getInstitutions().stream()
.map(institutionMapper::toInstitutionBase)
.sorted(Comparator.comparing(InstitutionBase::getName))
.toList();
log.debug("getUserProducts result = {}", result);
log.trace("getUserProducts end");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,21 +77,35 @@ void getUserProductsFound() {
when(userApiRestClient._usersUserIdInstitutionsGet("userID", null,
List.of(ACTIVE.name(), PENDING.name(), TOBEVALIDATED.name()))).thenReturn(ResponseEntity.ok(userProductsResponse));
List<InstitutionBase> result = userConnector.getUserInstitutions("userID");
Assertions.assertEquals(1, result.size());
Assertions.assertEquals(3, result.size());
Assertions.assertEquals(ACTIVE.name(), result.get(0).getStatus());
Assertions.assertEquals("institutionId", result.get(0).getId());
Assertions.assertEquals("institutionName", result.get(0).getName());
Assertions.assertEquals("a", result.get(0).getName());
Assertions.assertEquals("b", result.get(1).getName());
Assertions.assertEquals("c", result.get(2).getName());
}

private static UserInfoResponse getUserProductsResponse() {
UserInfoResponse userProductsResponse = new UserInfoResponse();
userProductsResponse.setUserId("userId");
UserInstitutionRoleResponse institutionProducts = new UserInstitutionRoleResponse();
institutionProducts.setInstitutionId("institutionId");
institutionProducts.setInstitutionName("institutionName");
institutionProducts.setInstitutionName("c");
institutionProducts.setStatus(OnboardedProductState.ACTIVE);
institutionProducts.setRole(PartyRole.MANAGER);
userProductsResponse.setInstitutions(List.of(institutionProducts));

UserInstitutionRoleResponse institutionProducts2 = new UserInstitutionRoleResponse();
institutionProducts2.setInstitutionId("institutionId2");
institutionProducts2.setInstitutionName("b");
institutionProducts2.setStatus(OnboardedProductState.ACTIVE);
institutionProducts2.setRole(PartyRole.MANAGER);

UserInstitutionRoleResponse institutionProducts3 = new UserInstitutionRoleResponse();
institutionProducts3.setInstitutionId("institutionId3");
institutionProducts3.setInstitutionName("a");
institutionProducts3.setStatus(OnboardedProductState.ACTIVE);
institutionProducts3.setRole(PartyRole.MANAGER);

userProductsResponse.setInstitutions(List.of(institutionProducts, institutionProducts2,institutionProducts3));
return userProductsResponse;
}

Expand Down

0 comments on commit 87923a8

Please sign in to comment.