void expectTemplateIsUpdatedIfNewContent()

in ddm-notification-service/src/it/java/com/epam/digital/data/platform/notification/service/SaveDiiaNotificationTemplateServiceTest.java [135:173]


  void expectTemplateIsUpdatedIfNewContent() {
    var prepopulatedEntity =
        notificationTemplateRepository.save(createTemplate(NAME_2, CONTENT,
            "b873ee130819ed542ec8ce28ea74a5830ad17756c55557e5f21e30efbcf57785"));
    var inputDto =
        SaveNotificationTemplateInputDto.builder()
            .title(TITLE)
            .content("Updated content")
            .build();

    diiaWireMock.
        stubFor(post(urlEqualTo("/api/v1/notification/template"))
            .willReturn(aResponse()
                .withStatus(200)
                .withHeader("Content-Type", MediaType.APPLICATION_JSON_VALUE)
                .withBody("{\"templateId\":\"5555\"}")
            ));

    service.save(CHANNEL, NAME_2, inputDto);

    var templateTableContent = notificationTemplateRepository
        .findByNameAndChannel(NAME_2, CHANNEL).get();
    assertThat(templateTableContent).isNotNull();
    assertThat(templateTableContent.getId()).isEqualTo(prepopulatedEntity.getId());
    assertThat(templateTableContent.getChannel()).isEqualTo(CHANNEL);
    assertThat(templateTableContent.getName()).isEqualTo(NAME_2);
    assertThat(templateTableContent.getTitle()).isEqualTo(TITLE);
    assertThat(templateTableContent.getContent()).isEqualTo("Updated content");
    assertThat(templateTableContent.getChecksum())
        .isEqualTo("0f590c85b54774764456994cd1db7f87c58671cd2039f5735cd40d823bc8c68f");
    assertThat(templateTableContent.getCreatedAt()).isNotNull();
    assertThat(templateTableContent.getUpdatedAt()).isNotNull();
    assertThat(templateTableContent.getExtTemplateId()).isEqualTo("5555");
    assertThat(templateTableContent.getExtPublishedAt()).isNotNull();

    var attributesTableContent =
        notificationTemplateAttributeRepository.findByTemplateId(templateTableContent.getId());
    assertThat(attributesTableContent).isEmpty();
  }