From 1a4ce93e0ac32a2b7ab8a99b163dac152d54aec7 Mon Sep 17 00:00:00 2001 From: Raja Kolli Date: Mon, 6 Nov 2023 05:22:44 +0000 Subject: [PATCH] fix : add correct Integrationtest --- .../awsspring/common/LocalStackConfig.java | 4 +--- .../NotificationServiceIntegrationTest.java | 20 +++++++++---------- 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/aws-ses-project/src/test/java/com/example/awsspring/common/LocalStackConfig.java b/aws-ses-project/src/test/java/com/example/awsspring/common/LocalStackConfig.java index 810ca34d..13c7cf17 100644 --- a/aws-ses-project/src/test/java/com/example/awsspring/common/LocalStackConfig.java +++ b/aws-ses-project/src/test/java/com/example/awsspring/common/LocalStackConfig.java @@ -1,7 +1,5 @@ package com.example.awsspring.common; -import static org.testcontainers.containers.localstack.LocalStackContainer.Service.SES; - import lombok.extern.slf4j.Slf4j; import org.springframework.test.context.DynamicPropertyRegistry; import org.springframework.test.context.DynamicPropertySource; @@ -31,6 +29,6 @@ static void setDynamicProperties(DynamicPropertyRegistry dynamicPropertyRegistry dynamicPropertyRegistry.add( "spring.cloud.aws.region.static", localStackContainer::getRegion); dynamicPropertyRegistry.add( - "spring.cloud.aws.endpoint", () -> localStackContainer.getEndpointOverride(SES)); + "spring.cloud.aws.endpoint", () -> localStackContainer.getEndpoint().toString()); } } diff --git a/aws-ses-project/src/test/java/com/example/awsspring/service/NotificationServiceIntegrationTest.java b/aws-ses-project/src/test/java/com/example/awsspring/service/NotificationServiceIntegrationTest.java index 3648cfbc..96667353 100644 --- a/aws-ses-project/src/test/java/com/example/awsspring/service/NotificationServiceIntegrationTest.java +++ b/aws-ses-project/src/test/java/com/example/awsspring/service/NotificationServiceIntegrationTest.java @@ -1,8 +1,9 @@ package com.example.awsspring.service; +import static org.awaitility.Awaitility.await; + import com.example.awsspring.common.AbstractIntegrationTest; import java.time.Duration; -import org.awaitility.Awaitility; import org.hamcrest.Matchers; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; @@ -20,8 +21,7 @@ void testSendMail() { simpleMailMessage.setSubject("test subject"); simpleMailMessage.setText("test text"); - Awaitility.await() - .atLeast(Duration.ofSeconds(1)) + await().atLeast(Duration.ofSeconds(1)) .atMost(Duration.ofSeconds(60)) .with() .pollInterval(Duration.ofSeconds(1)) @@ -32,12 +32,12 @@ void testSendMail() { @Test void testSendMailWithAttachments() { - SimpleMailMessage simpleMailMessage = new SimpleMailMessage(); - simpleMailMessage.setFrom("sender@example.com"); - simpleMailMessage.setTo("rajadilipkolli@gmail.com"); - simpleMailMessage.setSubject("test subject"); - simpleMailMessage.setText("test text"); - - notificationService.sendMailMessage(simpleMailMessage); + await().atLeast(Duration.ofSeconds(1)) + .atMost(Duration.ofSeconds(60)) + .with() + .pollInterval(Duration.ofSeconds(1)) + .until( + () -> notificationService.sendMailMessageWithAttachments(), + Matchers.equalTo("sent")); } }