77import uk .gov .hmcts .cp .subscription .entities .ClientSubscriptionEntity ;
88import uk .gov .hmcts .cp .subscription .model .EntityEventType ;
99
10+ import java .time .OffsetDateTime ;
1011import java .time .format .DateTimeFormatter ;
1112import java .util .List ;
13+ import java .util .UUID ;
1214
15+ import static org .assertj .core .api .Assertions .assertThat ;
1316import static org .springframework .test .web .servlet .request .MockMvcRequestBuilders .put ;
1417import static org .springframework .test .web .servlet .result .MockMvcResultHandlers .print ;
1518import 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