Skip to content

Commit

Permalink
fix : add correct Integrationtest
Browse files Browse the repository at this point in the history
  • Loading branch information
rajadilipkolli committed Nov 6, 2023
1 parent 47474a7 commit 1a4ce93
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 13 deletions.
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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());
}
}
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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))
Expand All @@ -32,12 +32,12 @@ void testSendMail() {

@Test
void testSendMailWithAttachments() {
SimpleMailMessage simpleMailMessage = new SimpleMailMessage();
simpleMailMessage.setFrom("[email protected]");
simpleMailMessage.setTo("[email protected]");
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"));
}
}

0 comments on commit 1a4ce93

Please sign in to comment.