diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index dcf365d6..ddbdda00 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -27,10 +27,10 @@ }, // Use 'forwardPorts' to make a list of ports inside the container available locally. - "forwardPorts": [8080] + "forwardPorts": [8080], // Use 'postCreateCommand' to run commands after the container is created. - // "postCreateCommand": "java -version", + "postCreateCommand": "java -version" // Configure tool-specific properties. // "customizations": {}, diff --git a/.vscode/launch.json b/.vscode/launch.json index 89453663..3e220c5a 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -95,6 +95,26 @@ "projectName": "spring-boot-multiple-producers-consumers", "args": "", "envFile": "${workspaceFolder}/.env" + }, + { + "type": "java", + "name": "Spring Boot-Application", + "request": "launch", + "cwd": "${workspaceFolder}", + "mainClass": "com.example.outboxpattern.Application", + "projectName": "spring-modulith-outbox-pattern", + "args": "--spring.profiles.active=local", + "envFile": "${workspaceFolder}/.env" + }, + { + "type": "java", + "name": "Spring Boot-TestApplication", + "request": "launch", + "cwd": "${workspaceFolder}", + "mainClass": "com.example.outboxpattern.TestApplication", + "projectName": "spring-modulith-outbox-pattern", + "args": "", + "envFile": "${workspaceFolder}/.env" } ] } \ No newline at end of file diff --git a/kafka-sample/spring-modulith-outbox-pattern/src/main/java/com/example/outboxpattern/shipping/Shipping.java b/kafka-sample/spring-modulith-outbox-pattern/src/main/java/com/example/outboxpattern/producer/Producer.java similarity index 62% rename from kafka-sample/spring-modulith-outbox-pattern/src/main/java/com/example/outboxpattern/shipping/Shipping.java rename to kafka-sample/spring-modulith-outbox-pattern/src/main/java/com/example/outboxpattern/producer/Producer.java index 11b1d069..59824c6b 100644 --- a/kafka-sample/spring-modulith-outbox-pattern/src/main/java/com/example/outboxpattern/shipping/Shipping.java +++ b/kafka-sample/spring-modulith-outbox-pattern/src/main/java/com/example/outboxpattern/producer/Producer.java @@ -1,4 +1,4 @@ -package com.example.outboxpattern.shipping; +package com.example.outboxpattern.producer; import com.example.outboxpattern.order.OrderResponse; import lombok.RequiredArgsConstructor; @@ -11,14 +11,14 @@ @Service @Transactional @RequiredArgsConstructor -public class Shipping { +public class Producer { @ApplicationModuleListener - void on(OrderResponse event) { - ship(event.id()); + void onOrderResponseEvent(OrderResponse event) { + publish(event.id()); } - private void ship(Long orderId) { - log.info("Started shipping for order {}", orderId); + private void publish(Long orderId) { + log.info("Started publishing for order {}", orderId); } } diff --git a/kafka-sample/spring-modulith-outbox-pattern/src/test/java/com/example/outboxpattern/SchemaValidationTest.java b/kafka-sample/spring-modulith-outbox-pattern/src/test/java/com/example/outboxpattern/SchemaValidationTest.java index cc4e587e..044ecc6d 100644 --- a/kafka-sample/spring-modulith-outbox-pattern/src/test/java/com/example/outboxpattern/SchemaValidationTest.java +++ b/kafka-sample/spring-modulith-outbox-pattern/src/test/java/com/example/outboxpattern/SchemaValidationTest.java @@ -1,6 +1,11 @@ package com.example.outboxpattern; +import static org.assertj.core.api.Assertions.assertThat; + +import com.zaxxer.hikari.HikariDataSource; +import javax.sql.DataSource; import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest; @DataJpaTest( @@ -11,6 +16,11 @@ }) class SchemaValidationTest { + @Autowired + private DataSource dataSource; + @Test - void validateJpaMappingsWithDbSchema() {} + void validateJpaMappingsWithDbSchema() { + assertThat(dataSource).isInstanceOf(HikariDataSource.class); + } }