Skip to content

Commit 3a8202f

Browse files
committed
fix: integration test expecting createdAt resolution to match up with expected
1 parent 14c53e2 commit 3a8202f

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/test/java/uk/gov/hmcts/cp/subscription/integration/SubscriptionUpdateControllerIntegrationTest.java

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,12 @@
77
import uk.gov.hmcts.cp.subscription.entities.ClientSubscriptionEntity;
88
import uk.gov.hmcts.cp.subscription.model.EntityEventType;
99

10+
import java.time.OffsetDateTime;
1011
import java.time.format.DateTimeFormatter;
1112
import java.util.List;
13+
import java.util.UUID;
1214

15+
import static org.assertj.core.api.Assertions.assertThat;
1316
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.put;
1417
import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print;
1518
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
@@ -25,7 +28,6 @@ void beforeEach() {
2528
@Test
2629
void update_client_subscription_should_update_subscription() throws Exception {
2730
ClientSubscriptionEntity existing = insertSubscription("https://oldendpoint", List.of(EntityEventType.PCR));
28-
String existingCreatedAt = existing.getCreatedAt().format(DateTimeFormatter.ISO_LOCAL_DATE_TIME);
2931
String body = new ObjectMapper().writeValueAsString(request);
3032
mockMvc.perform(put("/client-subscriptions/{id}", existing.getId())
3133
.contentType(MediaType.APPLICATION_JSON)
@@ -36,7 +38,11 @@ void update_client_subscription_should_update_subscription() throws Exception {
3638
.andExpect(jsonPath("$.clientSubscriptionId").value(existing.getId().toString()))
3739
.andExpect(jsonPath("$.eventTypes.[0]").value("CUSTODIAL_RESULT"))
3840
.andExpect(jsonPath("$.eventTypes.[1]").value("PCR"))
39-
.andExpect(jsonPath("$.notificationEndpoint.webhookUrl").value("https://my-callback-url"))
40-
.andExpect(jsonPath("$.createdAt").value(existingCreatedAt + "Z"));
41+
.andExpect(jsonPath("$.notificationEndpoint.webhookUrl").value("https://my-callback-url"));
42+
verifyCreatedAtIsUnchanged(existing.getId(), existing.getCreatedAt());
43+
}
44+
45+
void verifyCreatedAtIsUnchanged(UUID subscriptionId, OffsetDateTime expectedCreatedAt) {
46+
assertThat(subscriptionRepository.findById(subscriptionId).get().getCreatedAt()).isEqualTo(expectedCreatedAt);
4147
}
4248
}

0 commit comments

Comments
 (0)