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

DTSRD-2132.Update contactinformation for an organisation #1576

Open
wants to merge 56 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
4525006
Upgrading perftest branch to V16 and adding subnet_suffix
SabinaHMCTS Dec 11, 2023
3b99e90
Update contactinformation for an organisation adding test cases
SabinaHMCTS Feb 27, 2024
5b4b273
Merge branch 'master' into DTSRD-2132
SabinaHMCTS Mar 8, 2024
6c99bec
Merge branch 'master' into DTSRD-2132
SabinaHMCTS Apr 11, 2024
f5b99fa
Update name sra for an organisation adding test cases
SabinaHMCTS Apr 11, 2024
81d9552
Update contact information for an organisation adding test cases
SabinaHMCTS Apr 11, 2024
43944b9
Update contact information for an organisation adding test cases
SabinaHMCTS Apr 11, 2024
0f02825
Update contact information for an organisation adding test cases
SabinaHMCTS Apr 11, 2024
f7c651a
Update contact information for an organisation adding test cases
SabinaHMCTS Apr 11, 2024
9bd62ba
Update application.yml
SabinaHMCTS Apr 12, 2024
bd06ee9
Merge branch 'master' into DTSRD-2132
SabinaHMCTS Apr 19, 2024
d81e6b6
update contact information review comments
SabinaHMCTS May 3, 2024
bca596f
Merge branch 'master' into DTSRD-2132
SabinaHMCTS May 3, 2024
1c55b22
fixing review comments
SabinaHMCTS May 13, 2024
4df88af
fixing review comments
SabinaHMCTS May 13, 2024
daf82ea
fixing review comments
SabinaHMCTS May 13, 2024
7d04ffa
fixing review comments
SabinaHMCTS May 13, 2024
24ba34a
fixing review comments
SabinaHMCTS May 13, 2024
23f5dec
fixing review comments
SabinaHMCTS May 13, 2024
ba7b5af
fixing review comments
SabinaHMCTS May 13, 2024
954cf2b
fixing review comments
SabinaHMCTS May 13, 2024
257018e
fixing review comments
SabinaHMCTS May 13, 2024
384c1c0
fixing review comments
SabinaHMCTS May 13, 2024
a9edd55
fixing review comments
SabinaHMCTS May 13, 2024
f5ed946
fixing review comments
SabinaHMCTS May 14, 2024
50160db
fixing review comments
SabinaHMCTS May 14, 2024
3f9590f
fixing review comments
SabinaHMCTS May 14, 2024
cf00715
fixing review comments
SabinaHMCTS May 14, 2024
7fa4b61
Merge branch 'master' into DTSRD-2132
SabinaHMCTS May 29, 2024
507d4cb
checnged endpoint
SabinaHMCTS Jun 3, 2024
6223858
checnged endpoint
SabinaHMCTS Jun 3, 2024
dfcfad5
changes to logic
SabinaHMCTS Aug 28, 2024
8b650ac
Merge branch 'master' into DTSRD-2132
SabinaHMCTS Aug 28, 2024
eb08be7
changes to logic
SabinaHMCTS Aug 28, 2024
fb4444b
changes to logic adding test cases
SabinaHMCTS Aug 28, 2024
5dc59b9
changes to logic adding test cases
SabinaHMCTS Aug 29, 2024
ec9bf3d
changes to logic adding test cases
SabinaHMCTS Aug 29, 2024
96fffd8
changes to logic adding test cases
SabinaHMCTS Aug 29, 2024
0d7750a
changes to logic adding test cases
SabinaHMCTS Aug 29, 2024
be25b24
changes to logic adding test cases
SabinaHMCTS Aug 29, 2024
6123244
changes to logic adding test cases
SabinaHMCTS Aug 29, 2024
0a65900
changes to logic adding test cases
SabinaHMCTS Aug 29, 2024
a7e6b50
changes to logic adding test cases
SabinaHMCTS Aug 29, 2024
f8de665
changes to logic adding test cases
SabinaHMCTS Aug 29, 2024
ac9767e
changes to logic adding test cases
SabinaHMCTS Aug 29, 2024
9c70da3
Merge branch 'master' into DTSRD-2132
SabinaHMCTS Sep 9, 2024
cf20e99
Changes to fix review comments
SabinaHMCTS Sep 11, 2024
a27c993
Changes to fix review comments
SabinaHMCTS Sep 11, 2024
c5b36fc
Changes to fix review comments
SabinaHMCTS Sep 11, 2024
33361cd
Merge branch 'master' into DTSRD-2132
SabinaHMCTS Sep 17, 2024
2a5b0bf
Changes to fix review comments
SabinaHMCTS Sep 25, 2024
9fc04eb
fixing review comments according to DTSRD-2136
SabinaHMCTS Sep 26, 2024
af33d84
Merge branch 'master' into DTSRD-2132
SabinaHMCTS Sep 27, 2024
157cc57
changes to update contact information
SabinaHMCTS Sep 30, 2024
1175b6e
Merge branch 'master' into DTSRD-2132
SabinaHMCTS Oct 1, 2024
38c88bf
Merge branch 'master' into DTSRD-2132
SabinaHMCTS Nov 1, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import org.springframework.http.HttpStatus;
import uk.gov.hmcts.reform.lib.util.serenity5.SerenityTest;
import uk.gov.hmcts.reform.professionalapi.controller.constants.IdamStatus;
import uk.gov.hmcts.reform.professionalapi.controller.request.ContactInformationCreationRequest;
import uk.gov.hmcts.reform.professionalapi.controller.request.MfaUpdateRequest;
import uk.gov.hmcts.reform.professionalapi.controller.request.NewUserCreationRequest;
import uk.gov.hmcts.reform.professionalapi.controller.request.OrganisationCreationRequest;
Expand Down Expand Up @@ -54,6 +55,7 @@
import static org.springframework.http.HttpStatus.TOO_MANY_REQUESTS;
import static uk.gov.hmcts.reform.professionalapi.client.ProfessionalApiClient.createOrganisationRequest;
import static uk.gov.hmcts.reform.professionalapi.controller.constants.ProfessionalApiConstants.PBA_STATUS_MESSAGE_ACCEPTED;
import static uk.gov.hmcts.reform.professionalapi.controller.request.ContactInformationCreationRequest.aContactInformationCreationRequest;
import static uk.gov.hmcts.reform.professionalapi.controller.request.OrganisationCreationRequest.anOrganisationCreationRequest;
import static uk.gov.hmcts.reform.professionalapi.controller.request.UserCreationRequest.aUserCreationRequest;
import static uk.gov.hmcts.reform.professionalapi.domain.OrganisationStatus.REVIEW;
Expand Down Expand Up @@ -1231,4 +1233,61 @@ private static List<Map<String, Object>> sortByValue(final List<Map<String, Obje
.sorted(Comparator.comparing(map -> (String) map.get(key)))
.collect(Collectors.toList());
}

@Test
void updateContactInformationForOrganisationShouldReturnSuccess() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add another 2 tests

  1. to update dx address details alone and assert updated data
  2. to update address details without dx address details and assert updated data

log.info("updateContactInformationForOrganisationShouldReturnSuccess :: STARTED");

Map<String, Object> response = professionalApiClient.createOrganisation();
String organisationIdentifier = (String) response.get("organisationIdentifier");

assertThat(organisationIdentifier).isNotEmpty();
JsonPath orgResponse = professionalApiClient.retrieveOrganisationDetails(
organisationIdentifier, hmctsAdmin,OK);
assertNotNull(orgResponse);
List<HashMap> existingContactInformationList = (List) orgResponse.get("contactInformation");

assertThat(existingContactInformationList).isNotEmpty()
.hasSizeGreaterThan(0);

List<ContactInformationCreationRequest> contactInformationCreationRequestList =
professionalApiClient.createContactInformationCreationRequests();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

both existing addresses and new addresses are same, create new addresses with different values and assert.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed CI data to save.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

still new and existing contact addresses and DX are same

assertThat(contactInformationCreationRequestList).isNotEmpty()
.hasSizeGreaterThan(0);
ContactInformationCreationRequest contactInformationCreationRequest =
contactInformationCreationRequestList.get(0);

existingContactInformationList.forEach(existingContactInfo -> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do you need to loop existing addresses to update with new addresses ?


assertThat(existingContactInfo.get("addressLine1")).isNotNull();
assertThat(existingContactInfo.get("addressLine2")).isNotNull();
assertThat(existingContactInfo.get("addressLine3")).isNotNull();
assertThat(existingContactInfo.get("uprn")).isNotNull();
assertThat(existingContactInfo.get("country")).isNotNull();
assertThat(existingContactInfo.get("townCity")).isNotNull();
assertThat(existingContactInfo.get("country")).isNotNull();
assertThat(existingContactInfo.get("postCode")).isNotNull();

Response result =
professionalApiClient.updateContactInformationsToOrganisation(aContactInformationCreationRequest()
.uprn(contactInformationCreationRequest.getUprn())
.addressLine1(contactInformationCreationRequest.getAddressLine1())
.addressLine2(contactInformationCreationRequest.getAddressLine2())
.addressLine3(contactInformationCreationRequest.getAddressLine3())
.country(contactInformationCreationRequest.getCountry())
.county(contactInformationCreationRequest.getCounty())
.townCity(contactInformationCreationRequest.getTownCity())
.postCode(contactInformationCreationRequest.getPostCode())
.dxAddress(contactInformationCreationRequest.getDxAddress())
.build(),
OK,organisationIdentifier);

assertNotNull(result);
assertThat(result.getBody()).isNotNull();
assertThat(result.statusCode()).isEqualTo(200);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add assertions to verify new address details are updated for each UPRN (if uprn is use ) or for each address id

});

log.info("updateContactInformationForOrganisationShouldReturnSuccess :: END");
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -1752,4 +1752,28 @@ public void deleteMultipleAddressesOfOrganisation(List<DeleteMultipleAddressRequ
log.info("{}:: Delete Multiple Addresses of an organisation status response: {}",
loggingComponentName, response.getStatusCode());
}

@SuppressWarnings("unchecked")
public Response updateContactInformationsToOrganisation(

ContactInformationCreationRequest
contactInformationCreationRequest,
HttpStatus expectedStatus,
String organisationId) {

Response response = getMultipleAuthHeadersInternal()
.body(contactInformationCreationRequest)
.put("/refdata/internal/v1/organisations/contactInformation/" + organisationId)
.andReturn();

response.then()
.assertThat()
.statusCode(expectedStatus.value());

log.info("{}:: Update organisation contact information response: {}",
loggingComponentName, response.getStatusCode());

return response;

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
package uk.gov.hmcts.reform.professionalapi;

import org.junit.jupiter.api.Test;
import uk.gov.hmcts.reform.professionalapi.controller.request.ContactInformationCreationRequest;
import uk.gov.hmcts.reform.professionalapi.util.AuthorizationEnabledIntegrationTest;

import java.util.Map;

import static org.assertj.core.api.Assertions.assertThat;
import static uk.gov.hmcts.reform.professionalapi.helper.OrganisationFixtures.createContactInformationRequest;
import static uk.gov.hmcts.reform.professionalapi.helper.OrganisationFixtures.organisationRequestWithAllFieldsAreUpdated;
import static uk.gov.hmcts.reform.professionalapi.helper.OrganisationFixtures.organisationRequestWithMultipleAddressAllFields;

class UpdateOrgContactInformationIntegrationTest extends AuthorizationEnabledIntegrationTest {

@Test
void update_addressline1_for_organisation_with_prd_admin_role_should_return_200() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this test is to update addressLine1 only ? but test updating other fields as well !

ContactInformationCreationRequest contactInformationCreationRequest =
createContactInformationRequest().build();

Map<String, Object> updateResponse = professionalReferenceDataClient
.updateOrgContactInformation(contactInformationCreationRequest,
hmctsAdmin,createOrganisationRequest());

assertThat(updateResponse).containsEntry("http_status", 200);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add assertions to verify updated address details

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added asserts

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you updated contact information with below details, but assertions verifying different data and dx address verification is missing. Add prefix "updated" to each new field so that it is easy to identify what is updated data.

.addressLine1("addLine1")
.addressLine2("addLine2")
.addressLine3("addLine3")
.country("country")
.county("county")
.townCity("town-city")
.uprn("uprn1")
.postCode("post-code")
.dxAddress(Arrays.asList(dxAddressCreationRequest()
.dxNumber("DX 1234567890")
.dxExchange("dxExchange").build()));

}

@Test
void update_contact_with_bad_request_should_return_400() {
Map<String, Object> updateResponse = professionalReferenceDataClient
.updateOrgContactInformation(null, hmctsAdmin,createOrganisationRequest());

assertThat(updateResponse).containsEntry("http_status", "400");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

assert error message

}

@Test
void update_contact_information_invalid_addressline1_should_return_400() {
ContactInformationCreationRequest contactInformationCreationRequest =
createContactInformationRequest().addressLine1(null).build();

Map<String, Object> updateResponse = professionalReferenceDataClient
.updateOrgContactInformation(contactInformationCreationRequest,
hmctsAdmin,createOrganisationRequest());

assertThat(updateResponse).containsEntry("http_status", "400");
assertThat(updateResponse.get("response_body").toString()).contains(
"Field error in object 'contactInformationCreationRequest' on field 'addressLine1'");
}

@Test
void update_contact_information_multiple_requests_existing_for_org_should_return_200() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

test case updating only one address details but method name indicates multiple requests , correct the method name .


ContactInformationCreationRequest contactInformationCreationRequest =
createContactInformationRequest().build();

java.util.Map<String, Object> responseForOrganisationCreation = professionalReferenceDataClient
.createOrganisation(organisationRequestWithMultipleAddressAllFields().build());


Map<String, Object> updateResponse = professionalReferenceDataClient
.updateOrgContactInformation(contactInformationCreationRequest,
hmctsAdmin,(String)responseForOrganisationCreation.get(ORG_IDENTIFIER));

assertThat(updateResponse).containsEntry("http_status", 200);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

assert updated address details

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added asserts

}

@Test
void update_contact_information_single_requests_existing_for_org_should_return_200() {

ContactInformationCreationRequest contactInformationCreationRequest =
createContactInformationRequest().build();


java.util.Map<String, Object> responseForOrganisationCreation = professionalReferenceDataClient
.createOrganisation(organisationRequestWithAllFieldsAreUpdated().build());


Map<String, Object> updateResponse = professionalReferenceDataClient
.updateOrgContactInformation(contactInformationCreationRequest,
hmctsAdmin,(String)responseForOrganisationCreation.get(ORG_IDENTIFIER));

assertThat(updateResponse).containsEntry("http_status", 200);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

assert updated address details

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added asserts

}

@Test
void update_contact_information_for_non_existing_organisation_should_return_400() {
ContactInformationCreationRequest contactInformationCreationRequest =
createContactInformationRequest().build();

Map<String, Object> updateResponse = professionalReferenceDataClient
.updateOrgContactInformation(contactInformationCreationRequest, hmctsAdmin,"ABCDEF7");

assertThat(updateResponse).containsEntry("http_status", "404");
assertThat(updateResponse.get("response_body").toString())
.contains("errorMessage\":\"4 : Resource not found\",\"errorDescription\":\"Organisation does not exist");

}

@Test
void update_contact_information_invalid_request_should_return_400() {

Map<String, Object> updateResponse = professionalReferenceDataClient
.updateOrgContactInformation(new ContactInformationCreationRequest(null,null,
null,null,null,null,null,
null,null), hmctsAdmin,createOrganisationRequest());

assertThat(updateResponse).containsEntry("http_status", "400");
assertThat(updateResponse.get("response_body").toString())
.contains("validation on an argument failed");

}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add test case to update single address details without dx address, AddressLine3 and assert updated address details

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added shouldReturn200WhenUpdateSingleAddressWithoutDxAddress with asserts


Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add test case for missing dxAddressUpdateRequired query param to update dx address and assert bad request with error message "dxAddressUpdateRequired value is required"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added shoudlReturn400ForMissingDxAddress

}
rajkatla-hmcts marked this conversation as resolved.
Show resolved Hide resolved
rajkatla-hmcts marked this conversation as resolved.
Show resolved Hide resolved
rajkatla-hmcts marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -1039,4 +1039,30 @@ public Map<String, Object> retrieveUsersInOrganisationsByOrganisationIdentifiers
String uriPath = sb.toString();
return postRequest(uriPath, request, null, null);
}

public Map<String, Object> updateOrgContactInformation(
ContactInformationCreationRequest contactInformationCreationRequest,
String role, String organisationIdentifier) {

ResponseEntity<Map> responseEntity = null;
String urlPath = "http://localhost:" + prdApiPort + APP_INT_BASE_PATH
+ "/contactInformation/" + organisationIdentifier;
try {
HttpEntity<ContactInformationCreationRequest> requestEntity =
new HttpEntity<>(contactInformationCreationRequest,
getMultipleAuthHeaders(role));
responseEntity = restTemplate.exchange(urlPath, HttpMethod.PUT, requestEntity, Map.class);
} catch (RestClientResponseException ex) {
HashMap<String, Object> statusAndBody = new HashMap<>(2);
statusAndBody.put("http_status", String.valueOf(ex.getRawStatusCode()));
statusAndBody.put("response_body", ex.getResponseBodyAsString());
return statusAndBody;
}

Map<String, Object> contactInformationResponse = new HashMap<>();
contactInformationResponse.put("http_status", responseEntity.getStatusCodeValue());
return contactInformationResponse;
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ private ProfessionalApiConstants() {
public static final String EMAIL_REGEX = "^[A-Za-z0-9]+[\\w!#$%&'’.*+/=?`{|}~^-]+(?:\\.[\\w!#$%&’*+/=?`{|}~^-]+)*@"
+ "[A-Za-z0-9]+(?:[a-zA-Z0-9-]+\\.)+[a-zA-Z]{2,6}$";

public static final String NO_CONTACT_FOUND_FOR_GIVEN_ORG
= "No Contact Information was found with the given organisationIdentifier ";

public static final int LENGTH_OF_UUID = 36;
public static final int LENGTH_OF_ORGANISATION_IDENTIFIER = 7;
public static final String ORG_ID_VALIDATION_ERROR_MESSAGE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
import uk.gov.hmcts.reform.professionalapi.configuration.resolver.UserId;
import uk.gov.hmcts.reform.professionalapi.controller.SuperController;
import uk.gov.hmcts.reform.professionalapi.controller.advice.ErrorResponse;
import uk.gov.hmcts.reform.professionalapi.controller.advice.ResourceNotFoundException;
import uk.gov.hmcts.reform.professionalapi.controller.request.ContactInformationCreationRequest;
import uk.gov.hmcts.reform.professionalapi.controller.request.InvalidRequest;
import uk.gov.hmcts.reform.professionalapi.controller.request.MfaUpdateRequest;
import uk.gov.hmcts.reform.professionalapi.controller.request.NewUserCreationRequest;
Expand All @@ -37,6 +39,7 @@
import uk.gov.hmcts.reform.professionalapi.controller.request.PbaRequest;
import uk.gov.hmcts.reform.professionalapi.controller.request.UpdatePbaRequest;
import uk.gov.hmcts.reform.professionalapi.controller.request.validator.impl.OrganisationByProfileIdsRequestValidator;
import uk.gov.hmcts.reform.professionalapi.controller.response.ContactInformationResponse;
import uk.gov.hmcts.reform.professionalapi.controller.response.DeleteOrganisationResponse;
import uk.gov.hmcts.reform.professionalapi.controller.response.MultipleOrganisationsResponse;
import uk.gov.hmcts.reform.professionalapi.controller.response.NewUserResponse;
Expand All @@ -49,6 +52,7 @@
import uk.gov.hmcts.reform.professionalapi.domain.Organisation;
import uk.gov.hmcts.reform.professionalapi.domain.PbaResponse;

import java.util.Arrays;
import java.util.Optional;
import java.util.UUID;
import javax.validation.Valid;
Expand Down Expand Up @@ -744,4 +748,71 @@ public ResponseEntity<Object> retrieveOrganisationsByProfileIds(
.status(HttpStatus.OK)
.body(response);
}


@Operation(
summary = "Updates contact informations(address details) to organisation",
description = "**IDAM Roles to access API** :<br> pui-organisation-manager",
security = {
@SecurityRequirement(name = "ServiceAuthorization"),
@SecurityRequirement(name = "Authorization")
}

)

@ApiResponse(
responseCode = "200",
description = "Updated Contact Information",
content = @Content
)
@ApiResponse(
responseCode = "400",
description = "An invalid request has been provided",
content = @Content
)
@ApiResponse(
responseCode = "401",
description = "Unauthorized Error : "
+ "The requested resource is restricted and requires authentication",
content = @Content
)

@ApiResponse(
responseCode = "403",
description = "Forbidden Error: Access denied",
content = @Content
)
@ApiResponse(
responseCode = "500",
description = "Internal Server Error",
content = @Content
)


@PutMapping(
path = "/contactInformation/{orgId}",
consumes = APPLICATION_JSON_VALUE,
produces = APPLICATION_JSON_VALUE
)
@ResponseStatus(value = HttpStatus.CREATED)
@ResponseBody
@Secured({"prd-admin"})
public ResponseEntity<ContactInformationResponse> updateContactInformationForOrganisation(
@io.swagger.v3.oas.annotations.parameters.RequestBody(description = "contactInformationCreationRequests")
@Valid @NotNull @RequestBody ContactInformationCreationRequest contactInformationCreationRequest,
@PathVariable("orgId") @NotBlank String organisationIdentifier) {

organisationCreationRequestValidator.validateContactInformations(Arrays
.asList(contactInformationCreationRequest));

var organisation = organisationService.getOrganisationByOrgIdentifier(organisationIdentifier);

if (organisation == null) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Duplicate organisation find call move this validation to service impl

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed null check moved to service

throw new ResourceNotFoundException("Organisation does not exist");
}

return organisationService.updateContactInformationForOrganisation(
contactInformationCreationRequest,organisationIdentifier);

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
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.response.BulkCustomerOrganisationsDetailResponse;
import uk.gov.hmcts.reform.professionalapi.controller.response.ContactInformationResponse;
import uk.gov.hmcts.reform.professionalapi.controller.response.DeleteOrganisationResponse;
import uk.gov.hmcts.reform.professionalapi.controller.response.MultipleOrganisationsResponse;
import uk.gov.hmcts.reform.professionalapi.controller.response.OrganisationEntityResponse;
Expand All @@ -32,6 +33,9 @@ public interface OrganisationService {
BulkCustomerOrganisationsDetailResponse retrieveOrganisationDetailsForBulkCustomer(String bulkCustId,
String idamId);

ResponseEntity<ContactInformationResponse> updateContactInformationForOrganisation(
ContactInformationCreationRequest contactInfo, String organisationIdentifier);

OrganisationsDetailResponseV2 retrieveAllOrganisationsForV2Api(LocalDateTime formattedSince, Pageable pageable);

OrganisationEntityResponseV2 retrieveOrganisationForV2Api(String organisationIdentifier,
Expand Down
Loading