in ddm-notification-service/src/it/java/com/epam/digital/data/platform/notification/service/SaveDefaultNotificationTemplateServiceTest.java [154:209]
void expectTemplateAttributesUpdated() {
var prepopulatedTemplate =
notificationTemplateRepository.save(createTemplate("<html><h1>Hello</h1></html>"));
notificationTemplateAttributeRepository.saveAll(
List.of(
NotificationTemplateAttribute.builder()
.templateId(prepopulatedTemplate.getId())
.name("name1")
.value("value1")
.build(),
NotificationTemplateAttribute.builder()
.templateId(prepopulatedTemplate.getId())
.name("name2")
.value("value2")
.build()));
var inputDto =
SaveNotificationTemplateInputDto.builder()
.title(TITLE)
.content("<html><h1>Hello</h1></html>")
.attributes(
List.of(
new NotificationTemplateAttributeDto("name1", "newValue"),
new NotificationTemplateAttributeDto("name3", "value3")))
.build();
service.save(CHANNEL, NAME, inputDto);
var templateTableContent =
notificationTemplateRepository.findByNameAndChannel(NAME, CHANNEL).get();
assertThat(templateTableContent).isNotNull();
assertThat(templateTableContent.getId()).isEqualTo(prepopulatedTemplate.getId());
assertThat(templateTableContent.getChannel()).isEqualTo(CHANNEL);
assertThat(templateTableContent.getName()).isEqualTo(NAME);
assertThat(templateTableContent.getTitle()).isEqualTo(TITLE);
assertThat(templateTableContent.getContent()).isEqualTo("<html><h1>Hello</h1></html>");
assertThat(templateTableContent.getChecksum())
.isEqualTo("40c6d08f4bbd1fe4ac7f66239a7ca777dc7b0c449d4b459c523ad9eefab54abc");
assertThat(templateTableContent.getCreatedAt()).isNotNull();
assertThat(templateTableContent.getUpdatedAt()).isNotNull();
assertThat(templateTableContent.getExtTemplateId()).isNull();
assertThat(templateTableContent.getExtPublishedAt()).isNull();
var attributesTableContent =
notificationTemplateAttributeRepository.findByTemplateId(templateTableContent.getId());
assertThat(attributesTableContent).hasSize(2);
assertThat(attributesTableContent.get(0).getId()).isNotNull();
assertThat(attributesTableContent.get(0).getTemplateId())
.isEqualTo(prepopulatedTemplate.getId());
assertThat(attributesTableContent.get(0).getName()).isEqualTo("name1");
assertThat(attributesTableContent.get(0).getValue()).isEqualTo("newValue");
assertThat(attributesTableContent.get(1).getId()).isNotNull();
assertThat(attributesTableContent.get(1).getTemplateId())
.isEqualTo(prepopulatedTemplate.getId());
assertThat(attributesTableContent.get(1).getName()).isEqualTo("name3");
assertThat(attributesTableContent.get(1).getValue()).isEqualTo("value3");
}