diff --git a/aws-sns-project/docker/docker-compose.yml b/aws-sns-project/docker/docker-compose.yml index c898d321..9a67b922 100644 --- a/aws-sns-project/docker/docker-compose.yml +++ b/aws-sns-project/docker/docker-compose.yml @@ -2,7 +2,7 @@ version: '3.8' services: localstack: - image: localstack/localstack:3.8.1 + image: localstack/localstack:4.0.3 ports: - "4566:4566" environment: diff --git a/aws-sns-project/pom.xml b/aws-sns-project/pom.xml index d39091b9..ea633130 100644 --- a/aws-sns-project/pom.xml +++ b/aws-sns-project/pom.xml @@ -212,7 +212,7 @@ - 2.47.0 + 2.50.0 diff --git a/aws-sns-project/src/main/java/com/learning/awssns/config/WebMvcConfig.java b/aws-sns-project/src/main/java/com/learning/awssns/config/WebMvcConfig.java index d0759b4f..f96f379c 100644 --- a/aws-sns-project/src/main/java/com/learning/awssns/config/WebMvcConfig.java +++ b/aws-sns-project/src/main/java/com/learning/awssns/config/WebMvcConfig.java @@ -3,22 +3,26 @@ import static io.awspring.cloud.sns.configuration.NotificationHandlerMethodArgumentResolverConfigurationUtils.getNotificationHandlerMethodArgumentResolver; import java.util.List; -import lombok.RequiredArgsConstructor; import org.springframework.context.annotation.Configuration; +import org.springframework.lang.NonNull; import org.springframework.web.method.support.HandlerMethodArgumentResolver; import org.springframework.web.servlet.config.annotation.CorsRegistry; import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; import software.amazon.awssdk.services.sns.SnsClient; @Configuration(proxyBeanMethods = false) -@RequiredArgsConstructor class WebMvcConfig implements WebMvcConfigurer { private final ApplicationProperties properties; private final SnsClient snsClient; + public WebMvcConfig(ApplicationProperties properties, SnsClient snsClient) { + this.properties = properties; + this.snsClient = snsClient; + } + @Override - public void addCorsMappings(CorsRegistry registry) { + public void addCorsMappings(@NonNull CorsRegistry registry) { registry.addMapping(properties.getCors().getPathPattern()) .allowedMethods(properties.getCors().getAllowedMethods()) .allowedHeaders(properties.getCors().getAllowedHeaders()) @@ -27,7 +31,7 @@ public void addCorsMappings(CorsRegistry registry) { } @Override - public void addArgumentResolvers(List argumentResolvers) { + public void addArgumentResolvers(@NonNull List argumentResolvers) { argumentResolvers.add(getNotificationHandlerMethodArgumentResolver(snsClient)); } } diff --git a/aws-sns-project/src/test/java/com/learning/awssns/TestSNSApplication.java b/aws-sns-project/src/test/java/com/learning/awssns/TestSNSApplication.java index 27fec876..d14cb2ca 100644 --- a/aws-sns-project/src/test/java/com/learning/awssns/TestSNSApplication.java +++ b/aws-sns-project/src/test/java/com/learning/awssns/TestSNSApplication.java @@ -1,14 +1,15 @@ package com.learning.awssns; import com.learning.awssns.common.ContainersConfig; +import com.learning.awssns.utils.AppConstants; import org.springframework.boot.SpringApplication; public class TestSNSApplication { public static void main(String[] args) { - System.setProperty("spring.profiles.active", "local"); SpringApplication.from(SNSApplication::main) .with(ContainersConfig.class) + .withAdditionalProfiles(AppConstants.PROFILE_LOCAL) .run(args); } } diff --git a/aws-sns-project/src/test/java/com/learning/awssns/common/ContainersConfig.java b/aws-sns-project/src/test/java/com/learning/awssns/common/ContainersConfig.java index 8666ef3f..51a7148e 100644 --- a/aws-sns-project/src/test/java/com/learning/awssns/common/ContainersConfig.java +++ b/aws-sns-project/src/test/java/com/learning/awssns/common/ContainersConfig.java @@ -13,6 +13,6 @@ public class ContainersConfig { @ServiceConnection LocalStackContainer localstackContainer() { return new LocalStackContainer( - DockerImageName.parse("localstack/localstack").withTag("3.7.2")); + DockerImageName.parse("localstack/localstack").withTag("4.0.3")); } } diff --git a/aws-sqs-project/docker/docker-compose.yml b/aws-sqs-project/docker/docker-compose.yml index 0f2158a8..e6ff684a 100644 --- a/aws-sqs-project/docker/docker-compose.yml +++ b/aws-sqs-project/docker/docker-compose.yml @@ -16,7 +16,7 @@ services: retries: 5 localstack: - image: localstack/localstack:3.8.1 + image: localstack/localstack:4.0.3 environment: - AWS_DEFAULT_REGION=us-east-1 - EDGE_PORT=4566 diff --git a/aws-sqs-project/pom.xml b/aws-sqs-project/pom.xml index 32870775..a3d079d9 100644 --- a/aws-sqs-project/pom.xml +++ b/aws-sqs-project/pom.xml @@ -336,7 +336,7 @@ - 1.22.0 + 1.25.0 diff --git a/aws-sqs-project/src/test/java/com/learning/awspring/config/LocalStackTestContainers.java b/aws-sqs-project/src/test/java/com/learning/awspring/config/LocalStackTestContainers.java index f1f291ab..edcf9867 100644 --- a/aws-sqs-project/src/test/java/com/learning/awspring/config/LocalStackTestContainers.java +++ b/aws-sqs-project/src/test/java/com/learning/awspring/config/LocalStackTestContainers.java @@ -13,7 +13,7 @@ public class LocalStackTestContainers { @ServiceConnection LocalStackContainer localstackContainer() { return new LocalStackContainer( - DockerImageName.parse("localstack/localstack").withTag("3.7.2")) + DockerImageName.parse("localstack/localstack").withTag("4.0.3")) .withReuse(true); } } diff --git a/aws-sqs-project/src/test/java/com/learning/awspring/config/SQLTestcontainersConfig.java b/aws-sqs-project/src/test/java/com/learning/awspring/config/SQLTestcontainersConfig.java index 8ad37f00..4eec6ff7 100644 --- a/aws-sqs-project/src/test/java/com/learning/awspring/config/SQLTestcontainersConfig.java +++ b/aws-sqs-project/src/test/java/com/learning/awspring/config/SQLTestcontainersConfig.java @@ -12,6 +12,6 @@ public class SQLTestcontainersConfig { @Bean @ServiceConnection PostgreSQLContainer postgreSQLContainer() { - return new PostgreSQLContainer<>(DockerImageName.parse("postgres").withTag("17.0-alpine")); + return new PostgreSQLContainer<>(DockerImageName.parse("postgres").withTag("17.2-alpine")); } } diff --git a/aws-sqs-project/src/test/java/com/learning/awspring/repositories/SchemaValidationTest.java b/aws-sqs-project/src/test/java/com/learning/awspring/repositories/SchemaValidationTest.java index 0330829f..674fb874 100644 --- a/aws-sqs-project/src/test/java/com/learning/awspring/repositories/SchemaValidationTest.java +++ b/aws-sqs-project/src/test/java/com/learning/awspring/repositories/SchemaValidationTest.java @@ -7,15 +7,13 @@ import javax.sql.DataSource; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase; import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest; import org.springframework.context.annotation.Import; -@DataJpaTest( - properties = { - "spring.jpa.hibernate.ddl-auto=validate", - "spring.test.database.replace=none" - }) +@DataJpaTest(properties = {"spring.jpa.hibernate.ddl-auto=validate"}) @Import(SQLTestcontainersConfig.class) +@AutoConfigureTestDatabase class SchemaValidationTest { @Autowired private DataSource dataSource; diff --git a/aws-sqs-project/src/test/java/com/learning/awspring/utils/FakeObjectCreator.java b/aws-sqs-project/src/test/java/com/learning/awspring/utils/FakeObjectCreator.java index 81b83098..cf418f04 100644 --- a/aws-sqs-project/src/test/java/com/learning/awspring/utils/FakeObjectCreator.java +++ b/aws-sqs-project/src/test/java/com/learning/awspring/utils/FakeObjectCreator.java @@ -9,6 +9,7 @@ public class FakeObjectCreator { public static SQSMessagePayload createMessage() { return new SQSMessagePayload( - RandomStringUtils.randomNumeric(3), RandomStringUtils.randomAlphanumeric(100)); + RandomStringUtils.secure().nextNumeric(3), + RandomStringUtils.secure().nextAlphanumeric(100)); } } diff --git a/aws-sqs-project/src/test/java/com/learning/awspring/web/controllers/CustomerControllerTest.java b/aws-sqs-project/src/test/java/com/learning/awspring/web/controllers/CustomerControllerTest.java index 241c681d..055bef21 100644 --- a/aws-sqs-project/src/test/java/com/learning/awspring/web/controllers/CustomerControllerTest.java +++ b/aws-sqs-project/src/test/java/com/learning/awspring/web/controllers/CustomerControllerTest.java @@ -25,8 +25,8 @@ import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; -import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.http.MediaType; +import org.springframework.test.context.bean.override.mockito.MockitoBean; import org.springframework.test.web.servlet.MockMvc; @WebMvcTest(controllers = CustomerController.class) @@ -34,7 +34,7 @@ class CustomerControllerTest { @Autowired private MockMvc mockMvc; - @MockBean private CustomerService customerService; + @MockitoBean private CustomerService customerService; @Autowired private ObjectMapper objectMapper; diff --git a/aws-sqs-project/src/test/java/com/learning/awspring/web/controllers/InboundLogControllerTest.java b/aws-sqs-project/src/test/java/com/learning/awspring/web/controllers/InboundLogControllerTest.java index 3b5b5f29..1abda8e3 100644 --- a/aws-sqs-project/src/test/java/com/learning/awspring/web/controllers/InboundLogControllerTest.java +++ b/aws-sqs-project/src/test/java/com/learning/awspring/web/controllers/InboundLogControllerTest.java @@ -26,10 +26,10 @@ import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; -import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.data.domain.Page; import org.springframework.data.domain.PageImpl; import org.springframework.http.MediaType; +import org.springframework.test.context.bean.override.mockito.MockitoBean; import org.springframework.test.web.servlet.MockMvc; @WebMvcTest(controllers = InboundLogController.class) @@ -37,7 +37,7 @@ class InboundLogControllerTest { @Autowired private MockMvc mockMvc; - @MockBean private InboundLogService inboundLogService; + @MockitoBean private InboundLogService inboundLogService; @Autowired private ObjectMapper objectMapper;