-
Notifications
You must be signed in to change notification settings - Fork 0
AMP-168 - added client for material service. #18
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
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
9ce2996
AMP-168 - added client for material service.
madhusudan-yasa fd43d1e
AMP-168 - addressed review comments.
madhusudan-yasa dabac60
AMP-168 - addressed review comments.
madhusudan-yasa c7992bf
AMP-168 - addressed review comments.
madhusudan-yasa File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| dependencyManagement { | ||
| imports { | ||
| mavenBom "org.springframework.cloud:spring-cloud-dependencies:2025.1.0" | ||
| } | ||
| } | ||
|
|
||
| dependencies { | ||
| implementation 'org.springframework.cloud:spring-cloud-starter-openfeign' | ||
|
|
||
| testImplementation 'org.wiremock.integrations:wiremock-spring-boot:3.2.0' | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
src/main/java/uk/gov/hmcts/cp/subscription/clients/MaterialClient.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| package uk.gov.hmcts.cp.subscription.clients; | ||
|
|
||
| import org.springframework.cloud.openfeign.FeignClient; | ||
| import org.springframework.web.bind.annotation.GetMapping; | ||
| import org.springframework.web.bind.annotation.PathVariable; | ||
| import uk.gov.hmcts.cp.subscription.clients.model.MaterialResponse; | ||
|
|
||
| import java.util.UUID; | ||
|
|
||
| @FeignClient( | ||
| name = "material-client", | ||
| url = "${material-client.url}" | ||
| ) | ||
| public interface MaterialClient { | ||
|
|
||
| @GetMapping("/material-query-api/query/api/rest/material/material/{materialId}/metadata") | ||
| MaterialResponse getByMaterialId(@PathVariable UUID materialId); | ||
| } | ||
29 changes: 29 additions & 0 deletions
29
src/main/java/uk/gov/hmcts/cp/subscription/clients/model/MaterialResponse.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| package uk.gov.hmcts.cp.subscription.clients.model; | ||
|
|
||
| import com.fasterxml.jackson.annotation.JsonFormat; | ||
| import jakarta.validation.constraints.NotNull; | ||
| import lombok.AllArgsConstructor; | ||
| import lombok.Getter; | ||
| import lombok.NoArgsConstructor; | ||
|
|
||
| import java.time.LocalDateTime; | ||
| import java.util.UUID; | ||
|
|
||
| @Getter | ||
| @NoArgsConstructor | ||
| @AllArgsConstructor | ||
| public class MaterialResponse { | ||
|
|
||
| @NotNull | ||
| private UUID materialId; | ||
|
|
||
| private UUID alfrescoAssetId; | ||
|
|
||
| private String fileName; | ||
|
|
||
| private String mimeType; | ||
|
|
||
| @JsonFormat(shape = JsonFormat.Shape.STRING) | ||
| private LocalDateTime materialAddedDate; | ||
| } | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
src/test/java/uk/gov/hmcts/cp/subscription/clients/MaterialClientIntegrationTest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| package uk.gov.hmcts.cp.subscription.clients; | ||
|
|
||
| import org.junit.jupiter.api.Test; | ||
| import org.springframework.beans.factory.annotation.Autowired; | ||
| import org.springframework.boot.test.context.SpringBootTest; | ||
| import org.springframework.test.context.ContextConfiguration; | ||
| import org.wiremock.spring.ConfigureWireMock; | ||
| import org.wiremock.spring.EnableWireMock; | ||
| import uk.gov.hmcts.cp.subscription.clients.model.MaterialResponse; | ||
| import uk.gov.hmcts.cp.subscription.config.TestContainersInitialise; | ||
|
|
||
| import java.util.UUID; | ||
|
|
||
| import static org.assertj.core.api.AssertionsForClassTypes.assertThat; | ||
| import static org.assertj.core.api.AssertionsForClassTypes.assertThatThrownBy; | ||
|
|
||
| @SpringBootTest | ||
| @ContextConfiguration(initializers = TestContainersInitialise.class) | ||
| @EnableWireMock({@ConfigureWireMock(name = "material-client", baseUrlProperties = "material-client.url")}) | ||
| class MaterialClientIntegrationTest { | ||
|
|
||
| @Autowired | ||
| private MaterialClient materialClient; | ||
|
|
||
| @Test | ||
| void should_return_material_by_id() { | ||
|
|
||
| final UUID materialId = UUID.fromString("6c198796-08bb-4803-b456-fa0c29ca6021"); | ||
| MaterialResponse response = materialClient.getByMaterialId(materialId); | ||
|
|
||
| assertThat(response).satisfies(resp -> { | ||
| assertThat(resp.getMaterialId()).isEqualTo(materialId); | ||
| assertThat(resp.getAlfrescoAssetId()).isEqualTo(UUID.fromString("82257b1b-571d-432e-8871-b0c5b4bd18b1")); | ||
| assertThat(resp.getMimeType()).isEqualTo("application/pdf"); | ||
| assertThat(resp.getFileName()).isEqualTo("PrisonCourtRegister_20251219083322.pdf"); | ||
| }); | ||
| } | ||
|
|
||
| @Test | ||
| void should_throw_not_found_when_material_does_not_exist() { | ||
| UUID materialId = UUID.fromString("6c198796-08bb-4803-b456-fa0c29ca6022"); | ||
| assertThatThrownBy(() -> materialClient.getByMaterialId(materialId)) | ||
| .isInstanceOf(feign.FeignException.NotFound.class); | ||
| } | ||
| } | ||
coling01 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| { | ||
coling01 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| "materialId": "6c198796-08bb-4803-b456-fa0c29ca6021", | ||
| "alfrescoAssetId": "82257b1b-571d-432e-8871-b0c5b4bd18b1", | ||
| "fileName": "PrisonCourtRegister_20251219083322.pdf", | ||
| "mimeType": "application/pdf", | ||
| "materialAddedDate": "2025-12-19T08:33:29.866Z" | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| { | ||
coling01 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| "request": { | ||
| "method": "GET", | ||
| "url": "/material-query-api/query/api/rest/material/material/6c198796-08bb-4803-b456-fa0c29ca6021/metadata" | ||
| }, | ||
| "response": { | ||
| "status": 200, | ||
| "headers": { | ||
| "Content-Type": "application/json" | ||
| }, | ||
| "bodyFileName": "material-response.json" | ||
| } | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.