in ddm-rrm/src/it/java/com/epam/digital/data/platform/management/MasterVersionFormsControllerIT.java [545:589]
void updateForm_noFormsToUpdate() {
// define expected form content to create
final var expectedFormContent = context.getResourceContent(
"/versions/master/forms/{formName}/PUT/valid-form-version-candidate.json");
// perform query
mockMvc.perform(
put("/versions/master/forms/{formName}","valid-form")
.contentType(MediaType.APPLICATION_JSON)
.content(expectedFormContent)
.accept(MediaType.APPLICATION_JSON)
).andExpectAll(
status().isOk(),
content().contentType(MediaType.APPLICATION_JSON),
jsonPath("$.name", is("valid-form")),
jsonPath("$.title", is("Valid form Version Candidate"))
);
// assert that actual content and expected have no differences except for created and updated dates
final var actualFormContent = mockMvc.perform(
get("/versions/master/forms/{formName}","valid-form")
).andExpectAll(
status().isOk(),
content().contentType(MediaType.APPLICATION_JSON),
jsonPath("$.name", is("valid-form")),
jsonPath("$.title", is("Valid form Version Candidate"))
).andReturn().getResponse().getContentAsString();
JSONAssert.assertEquals(expectedFormContent, actualFormContent,
new CustomComparator(JSONCompareMode.LENIENT,
new Customization("created", (o1, o2) -> true),
new Customization("modified", (o1, o2) -> true)
));
// assert that form dates are close to current date
var form = JsonParser.parseString(actualFormContent).getAsJsonObject();
final var created = LocalDateTime.parse(form.get("created").getAsString(),
JacksonConfig.DATE_TIME_FORMATTER).format(JacksonConfig.DATE_TIME_FORMATTER);
final var updated = LocalDateTime.parse(form.get("modified").getAsString(),
JacksonConfig.DATE_TIME_FORMATTER).format(JacksonConfig.DATE_TIME_FORMATTER);
Assertions.assertThat(LocalDateTime.parse(created, JacksonConfig.DATE_TIME_FORMATTER))
.isCloseTo(LocalDateTime.now(), within(1, ChronoUnit.MINUTES));
Assertions.assertThat(LocalDateTime.parse(updated, JacksonConfig.DATE_TIME_FORMATTER))
.isCloseTo(LocalDateTime.now(), within(1, ChronoUnit.MINUTES));
}