Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CME-116 update rd-commons-lib #1708

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ https://tools.hmcts.net/confluence/display/RTRD/Professional+Reference+Data

To run the project you will need to have the following installed:

* Java 17
* Java 21
* Docker (optional)

For information about the software versions used to build this API and a complete list of it's dependencies see build.gradle
Expand Down
223 changes: 55 additions & 168 deletions build.gradle

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
org.gradle.jvmargs=-Xmx1024m
org.gradle.parallel=true
org.gradle.jvmargs=-Xmx2048m
org.gradle.parallel=true
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.11.1-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,12 @@
import java.util.stream.Collectors;

import static java.util.Arrays.asList;
import static org.apache.commons.lang.RandomStringUtils.randomAlphanumeric;
import static org.apache.commons.lang3.RandomStringUtils.randomAlphabetic;
import static org.apache.commons.lang3.RandomStringUtils.randomAlphanumeric;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static uk.gov.hmcts.reform.professionalapi.controller.request.NewUserCreationRequest.aNewUserCreationRequest;
import static uk.gov.hmcts.reform.professionalapi.util.DateUtils.convertStringToLocalDate;
import static uk.gov.hmcts.reform.professionalapi.util.DateUtils.formatDateString;

Expand Down Expand Up @@ -204,14 +203,13 @@ protected NewUserCreationRequest createUserRequest(List<String> userRoles,
userAccessTypes.add(new UserAccessType("jurisdictionId" + random, "organisationProfileId" + random,
"accessTypeId" + random, false));
String userEmail = generateRandomEmail();
NewUserCreationRequest userCreationRequest = aNewUserCreationRequest()
return NewUserCreationRequest.aNewUserCreationRequest()
.firstName(firstName)
.lastName(lastName)
.email(userEmail)
.roles(userRoles)
.userAccessTypes(userAccessTypes)
.build();
return userCreationRequest;
}

protected NewUserCreationRequest createUserRequest(List<String> userRoles, boolean hasAccessTypes) {
Expand All @@ -227,15 +225,15 @@ protected NewUserCreationRequest createUserRequest(List<String> userRoles, boole
.add(new UserAccessType("testJurisdictionId",
"testOrganisationProfileId",
"testAccessTypeId", true));
userCreationRequest = aNewUserCreationRequest()
userCreationRequest = NewUserCreationRequest.aNewUserCreationRequest()
.firstName(firstName)
.lastName(lastName)
.email(userEmail)
.roles(userRoles)
.userAccessTypes(userAccessTypes)
.build();
} else {
userCreationRequest = aNewUserCreationRequest()
userCreationRequest = NewUserCreationRequest.aNewUserCreationRequest()
.firstName(firstName)
.lastName(lastName)
.email(userEmail)
Expand Down Expand Up @@ -404,9 +402,9 @@ public void validateAccessTypesInRetrievedUser(Map<String, Object> searchRespons
assertEquals(true, userAccessTypeList.get(0).get("enabled"));
}

HashMap userMap = professionalUsersResponses.get(0);
HashMap userMap = professionalUsersResponses.getFirst();
assertThat(userMap).isNotEmpty();
validateUserResponse(userMap, searchResponse);
validateUserResponse(userMap, searchResponse, expectedStatus);

if (rolesReturned) {
assertThat(userMap.get("roles")).isNotNull();
Expand All @@ -428,7 +426,7 @@ public void validateAccessTypesAndRolesInRetrievedUser(Map<String, Object> searc

HashMap userMap = professionalUsersResponses.get(0);
assertThat(userMap).isNotEmpty();
validateUserResponse(userMap, searchResponse);
validateUserResponse(userMap, searchResponse, "ACTIVE");
assertThat(userAccessTypeList).hasSize(2);

if (rolesReturned) {
Expand All @@ -439,7 +437,7 @@ public void validateAccessTypesAndRolesInRetrievedUser(Map<String, Object> searc
}
}

public void validateUserResponse(HashMap userMap, Map<String, Object> searchResponse) {
public void validateUserResponse(HashMap userMap, Map<String, Object> searchResponse, String expectedStatus) {
assertThat(searchResponse.get("users")).asList().isNotEmpty();
assertThat(searchResponse.get("organisationIdentifier")).isNotNull();
assertThat(searchResponse.get("organisationProfileIds")).isNotNull();
Expand All @@ -449,7 +447,7 @@ public void validateUserResponse(HashMap userMap, Map<String, Object> searchResp
assertThat(userMap.get("lastName")).isNotNull();
assertThat(userMap.get("email")).isNotNull();
assertThat(userMap.get("lastUpdated")).isNotNull();
assertThat(userMap.get("idamStatus").equals(IdamStatus.ACTIVE.name()));
assertThat(userMap.get("idamStatus")).isEqualTo(expectedStatus);
}

public UserProfileUpdatedData deleteRoleRequest(String role) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import io.restassured.parsing.Parser;
import io.restassured.response.Response;
import io.restassured.specification.RequestSpecification;
import net.serenitybdd.junit5.SerenityJUnit5Extension;
import net.serenitybdd.rest.SerenityRest;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.DisplayName;
Expand All @@ -14,8 +15,8 @@
import org.springframework.boot.test.web.server.LocalServerPort;
import org.springframework.http.HttpStatus;
import org.springframework.test.context.TestPropertySource;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import uk.gov.hmcts.reform.lib.client.response.S2sClient;
import uk.gov.hmcts.reform.lib.util.serenity5.SerenityTest;
import uk.gov.hmcts.reform.professionalapi.client.ProfessionalApiClient;
import uk.gov.hmcts.reform.professionalapi.config.TestConfigProperties;
import uk.gov.hmcts.reform.professionalapi.controller.request.BulkCustomerRequest;
Expand All @@ -29,7 +30,7 @@
import uk.gov.hmcts.reform.professionalapi.repository.BulkCustomerDetailsRepository;
import uk.gov.hmcts.reform.professionalapi.repository.OrganisationRepository;
import uk.gov.hmcts.reform.professionalapi.repository.PaymentAccountRepository;
import uk.gov.hmcts.reform.professionalapi.util.FeatureToggleConditionExtension;
import uk.gov.hmcts.reform.professionalapi.util.CustomSerenityJUnit5Extension;
import uk.gov.hmcts.reform.professionalapi.util.ToggleEnable;

import java.util.Map;
Expand All @@ -38,7 +39,7 @@
import static org.assertj.core.api.Assertions.assertThat;
import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE;

@SerenityTest
@ExtendWith({CustomSerenityJUnit5Extension.class, SerenityJUnit5Extension.class, SpringExtension.class})
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
@TestPropertySource({"classpath:application.yaml","classpath:application-functional-bulkcustomer.yaml"})
public class BulkCivilApiFunctionalTest {
Expand Down Expand Up @@ -274,7 +275,6 @@ void retrieveBulkCustomerDetailsWithEmptyBulkCustomerID() {
@Test
@ToggleEnable(mapKey = "BulkCustomerDetailsInternalController.retrieveOrganisationDetailsForBulkCustomer",
withFeature = false)
@ExtendWith(FeatureToggleConditionExtension.class)
void retrieveBulkCustomerDetailsWithLaunchDarklyFlagOff() {
BulkCustomerRequest bulkCustomerRequest = new BulkCustomerRequest();
bulkCustomerRequest.setBulkCustomerId("bulkCustomerId");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
package uk.gov.hmcts.reform.professionalapi;

import net.thucydides.core.annotations.WithTag;
import net.thucydides.core.annotations.WithTags;
import net.serenitybdd.annotations.WithTag;
import net.serenitybdd.annotations.WithTags;
import net.serenitybdd.junit5.SerenityJUnit5Extension;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ActiveProfiles;
import uk.gov.hmcts.reform.lib.util.serenity5.SerenityTest;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import uk.gov.hmcts.reform.professionalapi.util.CustomSerenityJUnit5Extension;

import static org.assertj.core.api.Assertions.assertThat;

@SerenityTest
@ExtendWith({CustomSerenityJUnit5Extension.class, SerenityJUnit5Extension.class, SpringExtension.class})
@SpringBootTest
@WithTags({@WithTag("testType:Functional")})
@ActiveProfiles("functional")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,17 @@


import lombok.extern.slf4j.Slf4j;
import net.thucydides.core.annotations.WithTag;
import net.thucydides.core.annotations.WithTags;
import net.serenitybdd.annotations.WithTag;
import net.serenitybdd.annotations.WithTags;
import net.serenitybdd.junit5.SerenityJUnit5Extension;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.boot.test.context.SpringBootTest;
import uk.gov.hmcts.reform.lib.util.serenity5.SerenityTest;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import uk.gov.hmcts.reform.professionalapi.controller.request.NewUserCreationRequest;
import uk.gov.hmcts.reform.professionalapi.controller.request.OrganisationOtherOrgsCreationRequest;
import uk.gov.hmcts.reform.professionalapi.util.FeatureToggleConditionExtension;
import uk.gov.hmcts.reform.professionalapi.util.CustomSerenityJUnit5Extension;
import uk.gov.hmcts.reform.professionalapi.util.ToggleEnable;

import java.util.ArrayList;
Expand All @@ -24,7 +25,7 @@
import static org.springframework.http.HttpStatus.OK;
import static uk.gov.hmcts.reform.professionalapi.client.ProfessionalApiClient.createOrganisationRequestForV2;

@SerenityTest
@ExtendWith({CustomSerenityJUnit5Extension.class, SerenityJUnit5Extension.class, SpringExtension.class})
@SpringBootTest
@WithTags({@WithTag("testType:Functional")})
@Slf4j
Expand Down Expand Up @@ -52,7 +53,6 @@ class ProfessionalExternalUserFunctionalForV2ApiTest extends AuthorizationFuncti
@DisplayName("PRD External Test Scenarios For V2 API")
@ToggleEnable(mapKey = "OrganisationExternalControllerV2"
+ ".createOrganisationUsingExternalController", withFeature = true)
@ExtendWith(FeatureToggleConditionExtension.class)
void testExternalUserScenario() {
setUpOrgTestData();
setUpUserBearerTokens(List.of(puiUserManager, puiCaseManager, puiOrgManager, puiFinanceManager, caseworker));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,26 @@

import io.restassured.specification.RequestSpecification;
import lombok.extern.slf4j.Slf4j;
import net.thucydides.core.annotations.WithTag;
import net.thucydides.core.annotations.WithTags;
import net.serenitybdd.annotations.WithTag;
import net.serenitybdd.annotations.WithTags;
import net.serenitybdd.junit5.SerenityJUnit5Extension;
import org.apache.commons.lang3.RandomStringUtils;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.http.HttpStatus;
import uk.gov.hmcts.reform.lib.util.serenity5.SerenityTest;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import uk.gov.hmcts.reform.professionalapi.controller.request.ContactInformationCreationRequest;
import uk.gov.hmcts.reform.professionalapi.controller.request.DeleteMultipleAddressRequest;
import uk.gov.hmcts.reform.professionalapi.controller.request.NewUserCreationRequest;
import uk.gov.hmcts.reform.professionalapi.controller.request.OrganisationCreationRequest;
import uk.gov.hmcts.reform.professionalapi.controller.request.PbaRequest;
import uk.gov.hmcts.reform.professionalapi.controller.request.UserCreationRequest;
import uk.gov.hmcts.reform.professionalapi.controller.response.OrganisationMinimalInfoResponse;
import uk.gov.hmcts.reform.professionalapi.domain.UserAccessType;
import uk.gov.hmcts.reform.professionalapi.domain.UserProfileUpdatedData;
import uk.gov.hmcts.reform.professionalapi.util.FeatureToggleConditionExtension;
import uk.gov.hmcts.reform.professionalapi.util.CustomSerenityJUnit5Extension;
import uk.gov.hmcts.reform.professionalapi.util.ToggleEnable;

import java.util.ArrayList;
Expand Down Expand Up @@ -50,14 +52,12 @@
import static uk.gov.hmcts.reform.professionalapi.controller.constants.ProfessionalApiConstants.ACTIVE;
import static uk.gov.hmcts.reform.professionalapi.controller.constants.ProfessionalApiConstants.FALSE;
import static uk.gov.hmcts.reform.professionalapi.controller.constants.ProfessionalApiConstants.TRUE;
import static uk.gov.hmcts.reform.professionalapi.controller.request.UserCreationRequest.aUserCreationRequest;

@SerenityTest
@ExtendWith({CustomSerenityJUnit5Extension.class, SerenityJUnit5Extension.class, SpringExtension.class})
@SpringBootTest
@WithTags({@WithTag("testType:Functional")})
@Slf4j
@SuppressWarnings("unchecked")

class ProfessionalExternalUserFunctionalTest extends AuthorizationFunctionalTest {

String pumBearerToken;
Expand Down Expand Up @@ -107,7 +107,7 @@ public void setUpOrgTestData() {
log.info("Setting up organization...");
superUserEmail = generateRandomEmail();
organisationCreationRequest = createOrganisationRequest()
.superUser(aUserCreationRequest()
.superUser(UserCreationRequest.aUserCreationRequest()
.firstName(firstName)
.lastName(lastName)
.email(superUserEmail)
Expand Down Expand Up @@ -256,8 +256,14 @@ public void inviteUserBySuperUserShouldBeSuccess() {
professionalApiClient.getMultipleAuthHeaders(idamOpenIdClient.getExternalOpenIdTokenWithRetry(
superUserRoles(), firstName, lastName, email));

UserCreationRequest superUserRequest = UserCreationRequest
.aUserCreationRequest()
.firstName(firstName)
.lastName(lastName)
.email(email)
.build();
OrganisationCreationRequest organisationCreationRequest = createOrganisationRequest()
.superUser(aUserCreationRequest().firstName(firstName).lastName(lastName).email(email).build())
.superUser(superUserRequest)
.status("ACTIVE").build();
createAndActivateOrganisationWithGivenRequest(organisationCreationRequest, hmctsAdmin);

Expand Down Expand Up @@ -345,7 +351,7 @@ public void findUsersBySystemAdminWithoutRolesRequiredShouldBeSuccess() {
public void findOrganisationUsersSorted() {
String superUserEmail = generateRandomEmail();
OrganisationCreationRequest organisationCreationRequest = createOrganisationRequest()
.superUser(aUserCreationRequest().firstName(firstName)
.superUser(UserCreationRequest.aUserCreationRequest().firstName(firstName)
.lastName(lastName).email(superUserEmail).build())
.status("ACTIVE").build();

Expand Down Expand Up @@ -655,7 +661,6 @@ public String inviteUser(String role,

@Test
@DisplayName("MFA Scenarios")
@ExtendWith(FeatureToggleConditionExtension.class)
@ToggleEnable(mapKey = "OrganisationMfaStatusController.retrieveMfaStatusByUserId", withFeature = true)
@SuppressWarnings("checkstyle:AbbreviationAsWordInName")
void findMFAScenario() {
Expand Down Expand Up @@ -687,7 +692,6 @@ public void findOrganisationPbaWithoutEmailByExternalUserShouldBeBadRequest() {

@Test
@ToggleEnable(mapKey = "OrganisationExternalController.deletePaymentAccountsOfOrganisation", withFeature = false)
@ExtendWith(FeatureToggleConditionExtension.class)
@SuppressWarnings("checkstyle:AbbreviationAsWordInName")
void deletePbaOfExistingOrganisationShouldBeForbiddenWhenLDOff() {
log.info("deletePbaOfExistingOrganisationShouldBeForbiddenWhenLDOff :: STARTED");
Expand All @@ -706,7 +710,6 @@ void deletePbaOfExistingOrganisationShouldBeForbiddenWhenLDOff() {

@Test
@ToggleEnable(mapKey = "OrganisationExternalController.deletePaymentAccountsOfOrganisation", withFeature = true)
@ExtendWith(FeatureToggleConditionExtension.class)
void deletePbaOfExistingOrganisationShouldBeSuccess() {
log.info("deletePbaOfExistingOrganisationShouldBeSuccess :: STARTED");

Expand All @@ -729,7 +732,6 @@ void deletePbaOfExistingOrganisationShouldBeSuccess() {

@Test
@ToggleEnable(mapKey = "OrganisationExternalController.addPaymentAccountsToOrganisation", withFeature = false)
@ExtendWith(FeatureToggleConditionExtension.class)
@SuppressWarnings("checkstyle:AbbreviationAsWordInName")
void addPbaOfExistingOrganisationShouldBeForbiddenWhenLDOff() {
log.info("addPbaOfExistingOrganisationShouldBeForbiddenWhenLDOff :: STARTED");
Expand All @@ -748,7 +750,6 @@ void addPbaOfExistingOrganisationShouldBeForbiddenWhenLDOff() {

@Test
@ToggleEnable(mapKey = "OrganisationExternalController.addPaymentAccountsToOrganisation", withFeature = true)
@ExtendWith(FeatureToggleConditionExtension.class)
void addPbaOfExistingOrganisationShouldBeSuccess() {
log.info("addPaymentAccountsToOrganisation :: STARTED");

Expand Down Expand Up @@ -782,7 +783,6 @@ void addPbaOfExistingOrganisationShouldBeSuccess() {

@Test
@ToggleEnable(mapKey = "OrganisationExternalController.addContactInformationsToOrganisation", withFeature = false)
@ExtendWith(FeatureToggleConditionExtension.class)
@SuppressWarnings("checkstyle:AbbreviationAsWordInName")
void testAddContactsInformationsToOrganisationScenariosShouldBeForbiddenWhenLDOff() {
setUpOrgTestData();
Expand All @@ -804,7 +804,6 @@ void testAddContactsInformationsToOrganisationScenariosShouldBeForbiddenWhenLDOf
@Test
@DisplayName("Add Contact informations to organisations Test Scenarios")
@ToggleEnable(mapKey = "OrganisationExternalController.addContactInformationsToOrganisation", withFeature = true)
@ExtendWith(FeatureToggleConditionExtension.class)
@SuppressWarnings("checkstyle:AbbreviationAsWordInName")
void testAddContactsInformationsToOrganisationScenariosShouldBeSuccessWhenLDON() {
setUpOrgTestData();
Expand Down Expand Up @@ -863,7 +862,6 @@ public void suspendUserByPuiOrgManagerShouldBeSuccess() {

@Test
@ToggleEnable(mapKey = "OrganisationExternalController.deleteMultipleAddressesOfOrganisation", withFeature = false)
@ExtendWith(FeatureToggleConditionExtension.class)
@SuppressWarnings("checkstyle:AbbreviationAsWordInName")
void deleteMultipleAddressesOfOrganisationShouldBeForbiddenWhenLDOff() {
log.info("deleteMultipleAddressesOfOrganisationShouldBeForbiddenWhenLDOff :: STARTED");
Expand All @@ -884,7 +882,6 @@ void deleteMultipleAddressesOfOrganisationShouldBeForbiddenWhenLDOff() {

@Test
@ToggleEnable(mapKey = "OrganisationExternalController.deleteMultipleAddressesOfOrganisation", withFeature = true)
@ExtendWith(FeatureToggleConditionExtension.class)
void deleteMultipleAddressesOfOrganisationShouldBe404Failure() {
log.info("deleteMultipleAddressesOfOrganisationShouldBeSuccess :: STARTED");
setUpOrgTestData();
Expand All @@ -904,7 +901,6 @@ void deleteMultipleAddressesOfOrganisationShouldBe404Failure() {

@Test
@ToggleEnable(mapKey = "OrganisationExternalController.deleteMultipleAddressesOfOrganisation", withFeature = true)
@ExtendWith(FeatureToggleConditionExtension.class)
void deleteMultipleAddressesOfOrganisationShouldBeSuccess() {
log.info("deleteMultipleAddressesOfOrganisationShouldBeSuccess :: STARTED");
setUpOrgTestData();
Expand Down
Loading