Skip to content

Commit

Permalink
feat : connecting to postgres for modulith tests
Browse files Browse the repository at this point in the history
  • Loading branch information
rajadilipkolli committed Jan 15, 2024
1 parent 8d185b7 commit abdd56d
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 12 deletions.
5 changes: 0 additions & 5 deletions kafka-sample/spring-modulith-outbox-pattern/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -144,11 +144,6 @@
<artifactId>postgresql</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

<dependencyManagement>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.example.outboxpattern.config;
package com.example.outboxpattern.exception;

import com.example.outboxpattern.exception.ResourceNotFoundException;
import java.net.URI;
import java.time.Instant;
import java.util.Comparator;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
package com.example.outboxpattern.order.internal.entities;

import jakarta.persistence.*;
import jakarta.persistence.CascadeType;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.EnumType;
import jakarta.persistence.Enumerated;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.OneToMany;
import jakarta.persistence.Table;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
package com.example.outboxpattern.order.internal.request;

import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.Positive;
import java.math.BigDecimal;

public record OrderItemRequest(
@NotBlank(message = "Product cannot be blank") String productCode, BigDecimal productPrice, int quantity) {}
@NotBlank(message = "Product cannot be blank") String productCode,
BigDecimal productPrice,
@Positive(message = "quantity cant be 0 or negative") Integer quantity) {}
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@
public class Producer {

@ApplicationModuleListener
void onOrderResponseEvent(OrderRecord event) {
publish(event.id());
void onOrderResponseEvent(OrderRecord orderRecord) {
log.info("Received Event :{}", orderRecord);
publish(orderRecord.id());
}

private void publish(Long orderId) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.when;

import com.example.outboxpattern.common.ContainersConfig;
import com.example.outboxpattern.order.OrderRecord;
import com.example.outboxpattern.order.internal.request.OrderItemRequest;
import com.example.outboxpattern.order.internal.request.OrderRequest;
Expand All @@ -14,14 +15,16 @@
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.context.annotation.Import;
import org.springframework.kafka.core.KafkaOperations;
import org.springframework.kafka.support.SendResult;
import org.springframework.modulith.test.ApplicationModuleTest;
import org.springframework.modulith.test.Scenario;

@Slf4j
@ApplicationModuleTest
class OrderModuleTests {
@Import(ContainersConfig.class)
class OrderModuleIntTests {

@MockBean
KafkaOperations<?, ?> kafkaOperations;
Expand Down

0 comments on commit abdd56d

Please sign in to comment.