From a002ec3a16c2b0fefa666767c0e7d2324cb90c86 Mon Sep 17 00:00:00 2001 From: ishratt Date: Wed, 22 Mar 2023 06:56:35 +0000 Subject: [PATCH] added pact test for fetch profile endpoint --- .../StaffReferenceDataProviderTest.java | 21 ++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/src/contractTest/java/uk/gov/hmcts/reform/cwrdapi/StaffReferenceDataProviderTest.java b/src/contractTest/java/uk/gov/hmcts/reform/cwrdapi/StaffReferenceDataProviderTest.java index 58509520a..c10678b00 100644 --- a/src/contractTest/java/uk/gov/hmcts/reform/cwrdapi/StaffReferenceDataProviderTest.java +++ b/src/contractTest/java/uk/gov/hmcts/reform/cwrdapi/StaffReferenceDataProviderTest.java @@ -72,6 +72,7 @@ import java.util.HashMap; import java.util.HashSet; import java.util.List; +import java.util.Optional; import java.util.Set; import java.util.UUID; @@ -305,7 +306,7 @@ CaseWorkerProfile buildCaseWorkerProfile() { caseWorkerProfile.setCreatedDate(LocalDateTime.now()); caseWorkerProfile.setLastUpdate(LocalDateTime.now()); - caseWorkerProfile.setCaseWorkerId("27fbd198-552e-4c32-9caf-37be1545caaf"); + caseWorkerProfile.setCaseWorkerId("CWID1"); caseWorkerProfile.setCaseWorkerRoles(singletonList(caseWorkerRole)); caseWorkerProfile.setCaseWorkerLocations(singletonList(caseWorkerLocation)); CaseWorkerSkill caseWorkerSkill = getCaseWorkerSkill(); @@ -586,6 +587,24 @@ private StaffProfileCreationRequest getStaffProfileUpdateRequest() { .skills(singletonList(skillsRequest)) .build(); } + + @State({"A staff profile by caseworker id"}) + public void fetchStaffProfileById() throws JsonProcessingException { + ObjectMapper mapper = new ObjectMapper(); + + UserProfileResponse userProfileResponse = new UserProfileResponse(); + userProfileResponse.setIdamId("12345678"); + userProfileResponse.setIdamStatus(STATUS_ACTIVE); + String body = mapper.writeValueAsString(List.of(userProfileResponse)); + + when(userProfileFeignClient.getUserProfile(any())) + .thenReturn(Response.builder() + .request(mock(Request.class)).body(body, defaultCharset()).status(200).build()); + + CaseWorkerProfile caseWorkerProfile = buildCaseWorkerProfile(); + + doReturn(Optional.of(caseWorkerProfile)).when(caseWorkerProfileRepo).findByCaseWorkerId(anyString()); + } }