Skip to content
Merged
Show file tree
Hide file tree
Changes from 18 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
74eb626
Notification Changes
srivanimuddineni Feb 2, 2026
54812a1
Refactor Subscriber class with Lombok annotations
srivanimuddineni Feb 2, 2026
3c79368
Test case fix
srivanimuddineni Feb 2, 2026
8ae9b01
removed unnecessary comments
srivanimuddineni Feb 2, 2026
2f6baa4
Resolved review comments
srivanimuddineni Feb 2, 2026
5315962
Reverted docker file to original
srivanimuddineni Feb 2, 2026
f8e4490
pmd issues fix
srivanimuddineni Feb 2, 2026
4de50cb
Notification Changes for AMP-167 & 168(sync) and AMP-169 - Incorporte…
srivanimuddineni Feb 3, 2026
3213590
Notification Changes for AMP-167 & 168(sync) and AMP-169 - Incorporte…
srivanimuddineni Feb 3, 2026
68d5b2b
Notification Changes for AMP-167 & 168(sync) and AMP-169 - Incorporte…
srivanimuddineni Feb 3, 2026
9d6c599
Notification Changes for AMP-167 & 168(sync) and AMP-169 - Resolved …
srivanimuddineni Feb 3, 2026
c00f7c1
Notification Changes for AMP-167 & 168(sync) & AMP-169 Impl of RestT…
srivanimuddineni Feb 4, 2026
8a140ab
Notification Changes for AMP-167 & 168(sync) & AMP-169 Impl of RestT…
srivanimuddineni Feb 4, 2026
5770001
feature: amp-167 notification changes
coling01 Feb 4, 2026
a1584f5
feature: amp-167 notification changes
coling01 Feb 4, 2026
7502171
feature: amp-167 notification changes
coling01 Feb 4, 2026
1f70708
Merge pull request #32 from hmcts/feature/colin-notification-changes
srivanimuddineni Feb 4, 2026
cdb5b41
Notification Changes for AMP-167 & 168(sync) & AMP-169 moved subscrip…
srivanimuddineni Feb 4, 2026
bfedef3
Notification Changes for AMP-167 & 168(sync) & AMP-169 moved subscrip…
srivanimuddineni Feb 4, 2026
b84fe48
Notification Changes for AMP-167 & 168(sync) & AMP-169 removed readyOnly
srivanimuddineni Feb 4, 2026
0d2397e
Notification Changes for AMP-167 & 168(sync) & AMP-169 Added Manager …
srivanimuddineni Feb 4, 2026
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
@@ -1,28 +1,22 @@
package uk.gov.hmcts.cp.subscription.http;

import org.junit.jupiter.api.Test;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.client.RestTemplate;
import org.springframework.web.client.RestClient;

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

class ActuatorApiTest {

private final String baseUrl = System.getProperty("app.baseUrl", "http://localhost:8082");
// TODO remove this client and use FeignClient/RestClient
private final RestTemplate http = new RestTemplate();
private final RestClient http = RestClient.create();

@Test
void health_endpoint_should_be_up() {
final ResponseEntity<String> res = http.exchange(
baseUrl + "/actuator/health", HttpMethod.GET,
new HttpEntity<>(new HttpHeaders()),
String.class
);
final var res = http.get()
.uri(baseUrl + "/actuator/health")
.retrieve()
.toEntity(String.class);
assertThat(res.getStatusCode()).isEqualTo(HttpStatus.OK);
assertThat(res.getBody()).contains("\"status\":\"UP\"");
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,27 +1,22 @@
package uk.gov.hmcts.cp.subscription.http;

import org.junit.jupiter.api.Test;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.client.RestTemplate;
import org.springframework.web.client.RestClient;

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

class RootApiTest {

private final String baseUrl = System.getProperty("app.baseUrl", "http://localhost:8082");
private final RestTemplate http = new RestTemplate();
private final RestClient http = RestClient.create();

@Test
void root_endpoint_should_be_ok() throws InterruptedException {
final ResponseEntity<String> res = http.exchange(
baseUrl + "/", HttpMethod.GET,
new HttpEntity<>(new HttpHeaders()),
String.class
);
final var res = http.get()
.uri(baseUrl + "/")
.retrieve()
.toEntity(String.class);
assertThat(res.getStatusCode()).isEqualTo(HttpStatus.OK);
assertThat(res.getBody()).contains("DEPRECATED root endpoint");
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
package uk.gov.hmcts.cp.subscription.http;

import org.junit.jupiter.api.Test;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.client.RestTemplate;
import org.springframework.web.client.RestClient;

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

Expand All @@ -20,34 +16,30 @@
*/
class SubscriptionApiTest {
private final String baseUrl = System.getProperty("app.baseUrl", "http://localhost:8082");
private final RestTemplate http = new RestTemplate();
private final RestClient http = RestClient.create();

@Test
void round_trip_subscription_should_work_ok() throws InterruptedException {
final String callbackUrl = "https://my-callback-url";
final String postUrl = String.format("%s/client-subscriptions?callbackUrl=%s", baseUrl, callbackUrl);
final HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_JSON);
final String body = "{\"eventTypes\":[\"PRISON_COURT_REGISTER_GENERATED\",\"CUSTODIAL_RESULT\"]}";
final ResponseEntity<String> postResult = http.exchange(
postUrl,
HttpMethod.POST,
new HttpEntity<>(body, headers),
String.class
);
final var postResult = http.post()
.uri(postUrl)
.contentType(MediaType.APPLICATION_JSON)
.body(body)
.retrieve()
.toEntity(String.class);
assertThat(postResult.getStatusCode()).isEqualTo(HttpStatus.CREATED);
assertThat(postResult.getBody()).contains("clientSubscriptionId");
final String subscriptionId = postResult.getBody()
.replaceAll(".*clientSubscriptionId\":\"", "")
.replaceAll("\".*$", "");

final String getUrl = String.format("%s/client-subscriptions/%s", baseUrl, subscriptionId);
final ResponseEntity<String> getResult = http.exchange(
getUrl,
HttpMethod.GET,
new HttpEntity<>(new HttpHeaders()),
String.class
);
final var getResult = http.get()
.uri(getUrl)
.retrieve()
.toEntity(String.class);
assertThat(getResult.getStatusCode()).isEqualTo(HttpStatus.OK);
assertThat(getResult.getBody()).contains("clientSubscriptionId\":\"" + subscriptionId);
}
Expand Down
3 changes: 2 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ plugins {
id 'java'
id 'org.springframework.boot' version '4.0.1'
id 'io.spring.dependency-management' version '1.1.7'
id 'org.openapi.generator' version '7.19.0'
id 'jacoco'
id 'maven-publish'
id 'com.github.ben-manes.versions' version '0.53.0'
Expand All @@ -17,7 +18,7 @@ apply {
from("$rootDir/gradle/dependencies/java-core.gradle")
from("$rootDir/gradle/dependencies/spring-core.gradle")
from("$rootDir/gradle/dependencies/spring-db.gradle")
from("$rootDir/gradle/dependencies/spring-cloud.gradle")
from("$rootDir/gradle/dependencies/openapi-material.gradle")

from("$rootDir/gradle/github/repositories.gradle")
from("$rootDir/gradle/github/java.gradle")
Expand Down
25 changes: 0 additions & 25 deletions docs/debugging.md

This file was deleted.

37 changes: 37 additions & 0 deletions gradle/dependencies/openapi-material.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// Material API OpenAPI client generation
tasks.named('compileJava') {
dependsOn(tasks.openApiGenerate)
}

def materialClientOutputDir = "${layout.buildDirectory.get().asFile.absolutePath}/generated"

openApiGenerate {
inputSpec = "$rootDir/src/main/resources/openapi/material-api-spec.yml"
outputDir = materialClientOutputDir
generatorName = 'java'
library = 'resttemplate'
apiPackage = 'uk.gov.hmcts.cp.material.openapi.api'
modelPackage = 'uk.gov.hmcts.cp.material.openapi.model'
invokerPackage = 'uk.gov.hmcts.cp.material.openapi'
typeMappings = ['OffsetDateTime': 'Instant']
importMappings = ['java.time.OffsetDateTime': 'java.time.Instant']
configOptions = [
useSpringBoot4 : 'true',
useJakartaEe : 'true',
useTags : 'true',
openApiNullable : 'false'
]
}

sourceSets {
main {
java {
srcDir "${materialClientOutputDir}/src/main/java"
}
}
}

dependencies {
implementation 'com.fasterxml.jackson.datatype:jackson-datatype-jsr310'
implementation 'javax.annotation:javax.annotation-api:1.3.2'
}
3 changes: 0 additions & 3 deletions gradle/dependencies/spring-cloud.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@ dependencyManagement {
}

dependencies {
implementation 'org.springframework.cloud:spring-cloud-starter-openfeign'
testImplementation 'org.wiremock.integrations:wiremock-spring-boot:3.2.0'
testImplementation 'org.wiremock:wiremock-standalone:3.3.1'


}
1 change: 1 addition & 0 deletions gradle/dependencies/spring-core.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ dependencies {
implementation "org.springframework.boot:spring-boot-starter-aspectj"
implementation "org.springframework.boot:spring-boot-starter-actuator"
implementation "org.springframework.boot:spring-boot-starter-validation"
implementation "org.springframework.retry:spring-retry"

testImplementation "org.springframework.boot:spring-boot-starter-webmvc-test"
testImplementation "org.springframework.boot:spring-boot-starter-test"
Expand Down
2 changes: 0 additions & 2 deletions src/main/java/uk/gov/hmcts/cp/subscription/Application.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.openfeign.EnableFeignClients;

@EnableFeignClients
@SpringBootApplication
public class Application {

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package uk.gov.hmcts.cp.subscription.clients;

import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;
import uk.gov.hmcts.cp.subscription.model.PcrOutboundPayload;

import static org.springframework.http.HttpMethod.POST;

@Service
@AllArgsConstructor
@Slf4j
public class CallbackClient {

private RestTemplate restTemplate;

public void sendNotification(final String url, final PcrOutboundPayload subscriberOutboundPayload) {
log.info("Sending notification to {}", url);
final HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_JSON);
final HttpEntity<PcrOutboundPayload> req = new HttpEntity<>(subscriberOutboundPayload, headers);
restTemplate.exchange(url, POST, req, String.class);
}
}
Original file line number Diff line number Diff line change
@@ -1,21 +1,29 @@
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 lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;
import uk.gov.hmcts.cp.subscription.model.PcrOutboundPayload;

import java.util.UUID;
import static org.springframework.http.HttpMethod.GET;

@FeignClient(
name = "material-client",
url = "${material-client.url}"
)
public interface MaterialClient {
@Service
@AllArgsConstructor
@Slf4j
public class MaterialClient {

@GetMapping("/material-query-api/query/api/rest/material/material/{materialId}/metadata")
MaterialResponse getMetadataById(@PathVariable UUID materialId);
private RestTemplate restTemplate;

@GetMapping("/material-query-api/query/api/rest/material/material/{materialId}/content")
byte[] getContentById(@PathVariable UUID materialId);
}
public ResponseEntity<byte[]> getMaterialDocument(final String url) {
log.info("Getting material document from {}", url);
final HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_JSON);
final HttpEntity<PcrOutboundPayload> req = new HttpEntity<>(headers);
return restTemplate.exchange(url, GET, req, byte[].class);
}
}

This file was deleted.

Loading
Loading