Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ apply {
}

dependencies {
implementation(group: 'uk.gov.hmcts.cp', name: 'api-cp-crime-hearing-case-event-subscription', version: '1.0.0')
implementation(group: 'uk.gov.hmcts.cp', name: 'api-cp-crime-hearing-case-event-subscription', version: '1.0.0-cc7de31')

// This is proving to be a real puzzle. This is actually included in the api published pom
// ( though with scope of "runtime" )
Expand Down
1 change: 1 addition & 0 deletions gradle/dependencies/spring-core.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ dependencies {
implementation "org.springframework.boot:spring-boot-starter-web"
implementation "org.springframework.boot:spring-boot-starter-aspectj"
implementation "org.springframework.boot:spring-boot-starter-actuator"
implementation "org.springframework.boot:spring-boot-starter-validation"

testImplementation "org.springframework.boot:spring-boot-starter-webmvc-test"
testImplementation "org.springframework.boot:spring-boot-starter-test"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import uk.gov.hmcts.cp.openapi.model.EventType;
import uk.gov.hmcts.cp.openapi.model.NotificationEndpoint;

import java.net.URI;
import java.util.List;

import static java.util.stream.Collectors.toList;
Expand All @@ -38,7 +37,6 @@ static String mapFromNotificationEndpoint(final NotificationEndpoint notificatio
}

static NotificationEndpoint mapToNotificationEndpoint(final String endpointUrl) {
final URI uri = URI.create(endpointUrl);
return NotificationEndpoint.builder().webhookUrl(uri).build();
return NotificationEndpoint.builder().webhookUrl(endpointUrl).build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import uk.gov.hmcts.cp.openapi.model.NotificationEndpoint;
import uk.gov.hmcts.cp.repositories.SubscriptionRepository;

import java.net.URI;
import java.util.List;

import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
Expand All @@ -24,7 +23,7 @@ class SubscriptionControllerValidationTest extends IntegrationTestBase {
SubscriptionRepository subscriptionRepository;

NotificationEndpoint notificationEndpoint = NotificationEndpoint.builder()
.webhookUrl(URI.create("https://my-callback-url"))
.webhookUrl("https://my-callback-url")
.build();
ClientSubscriptionRequest request = ClientSubscriptionRequest.builder()
.notificationEndpoint(notificationEndpoint)
Expand All @@ -42,10 +41,8 @@ void bad_event_type_should_return_400() throws Exception {
.andExpect(content().string(""));
}

// TODO - decide how to best validate the incoming url and enable this test once done
@Test
@Disabled
void bad_url_should_return_400() throws Exception {
void webhook_bad_url_should_return_400() throws Exception {
String body = new ObjectMapper().writeValueAsString(request)
.replace("https://my-callback-url", "not-a-url");
mockMvc.perform(post("/client-subscriptions")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import uk.gov.hmcts.cp.openapi.model.NotificationEndpoint;
import uk.gov.hmcts.cp.repositories.SubscriptionRepository;

import java.net.URI;
import java.util.List;
import java.util.UUID;

Expand All @@ -27,7 +26,7 @@ class SubscriptionGetControllerIntegrationTest extends IntegrationTestBase {
SubscriptionRepository subscriptionRepository;

NotificationEndpoint notificationEndpoint = NotificationEndpoint.builder()
.webhookUrl(URI.create("https://my-callback-url"))
.webhookUrl("https://my-callback-url")
.build();
ClientSubscriptionRequest request = ClientSubscriptionRequest.builder()
.notificationEndpoint(notificationEndpoint)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,9 @@
import uk.gov.hmcts.cp.openapi.model.NotificationEndpoint;
import uk.gov.hmcts.cp.repositories.SubscriptionRepository;

import java.net.URI;
import java.util.List;

import static org.assertj.core.api.Assertions.assertThat;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
Expand All @@ -29,7 +27,7 @@ class SubscriptionSaveControllerIntegrationTest extends IntegrationTestBase {
SubscriptionRepository subscriptionRepository;

NotificationEndpoint notificationEndpoint = NotificationEndpoint.builder()
.webhookUrl(URI.create("https://my-callback-url"))
.webhookUrl("https://my-callback-url")
.build();
ClientSubscriptionRequest request = ClientSubscriptionRequest.builder()
.notificationEndpoint(notificationEndpoint)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import uk.gov.hmcts.cp.openapi.model.ClientSubscriptionRequest;
import uk.gov.hmcts.cp.openapi.model.NotificationEndpoint;

import java.net.URI;
import java.time.OffsetDateTime;
import java.util.List;
import java.util.UUID;
Expand All @@ -22,7 +21,7 @@ class SubscriptionMapperTest {

UUID clientNotificationId = UUID.fromString("d730c6e1-66ba-4ef0-a3dd-0b9928faa76d");
NotificationEndpoint notificationEndpoint = NotificationEndpoint.builder()
.webhookUrl(URI.create("https://example.com"))
.webhookUrl("https://example.com")
.build();
OffsetDateTime createdAt = OffsetDateTime.now().minusDays(2);
OffsetDateTime updatedAt = OffsetDateTime.now().minusHours(2);
Expand Down
Loading