-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adds IntegrationTests (missing some assertions)
- Loading branch information
Showing
15 changed files
with
2,779 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
src/test/java/io/zenwave360/modulith/events/scs/SCSAvroEventExternalizerTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package io.zenwave360.modulith.events.scs; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.boot.test.context.SpringBootTest; | ||
import org.springframework.context.annotation.Import; | ||
import org.springframework.jdbc.core.JdbcTemplate; | ||
import org.springframework.transaction.annotation.Transactional; | ||
|
||
@SpringBootTest(classes = { TestsConfiguration.class }) | ||
@Import({ AvroEventSerializerConfiguration.class }) | ||
@Transactional | ||
public class SCSAvroEventExternalizerTest { | ||
|
||
@Autowired | ||
TestsConfiguration.CustomerEventsProducer customerEventsProducer; | ||
|
||
@Autowired | ||
JdbcTemplate jdbcTemplate; | ||
|
||
@Test | ||
void testExternalizeAvroEvent() { | ||
var event = new io.zenwave360.modulith.events.scs.dtos.avro.CustomerEvent(); | ||
event.setName("John Doe"); | ||
customerEventsProducer.onCustomerEventAvro(event); | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
src/test/java/io/zenwave360/modulith/events/scs/SCSJsonEventExternalizerTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package io.zenwave360.modulith.events.scs; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.boot.test.context.SpringBootTest; | ||
import org.springframework.context.annotation.Import; | ||
import org.springframework.jdbc.core.JdbcTemplate; | ||
import org.springframework.transaction.annotation.Transactional; | ||
|
||
@SpringBootTest(classes = { TestsConfiguration.class }) | ||
@Import({ MessageEventSerializerConfiguration.class }) | ||
@Transactional | ||
public class SCSJsonEventExternalizerTest { | ||
|
||
@Autowired | ||
TestsConfiguration.CustomerEventsProducer customerEventsProducer; | ||
|
||
@Autowired | ||
JdbcTemplate jdbcTemplate; | ||
|
||
@Test | ||
void testExternalizeJsonEvent() { | ||
var event = new io.zenwave360.modulith.events.scs.dtos.json.CustomerEvent() | ||
.withName("John Doe"); | ||
customerEventsProducer.onCustomerEventJson(event); | ||
} | ||
} |
11 changes: 0 additions & 11 deletions
11
src/test/java/io/zenwave360/modulith/events/scs/SpringCloudStreamEventExternalizerTest.java
This file was deleted.
Oops, something went wrong.
62 changes: 62 additions & 0 deletions
62
src/test/java/io/zenwave360/modulith/events/scs/TestsConfiguration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
package io.zenwave360.modulith.events.scs; | ||
|
||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration; | ||
import org.springframework.context.ApplicationEventPublisher; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Import; | ||
import org.springframework.kafka.test.EmbeddedKafkaBroker; | ||
import org.springframework.kafka.test.EmbeddedKafkaZKBroker; | ||
import org.springframework.kafka.test.context.EmbeddedKafka; | ||
import org.springframework.messaging.Message; | ||
import org.springframework.messaging.support.MessageBuilder; | ||
import org.springframework.transaction.annotation.EnableTransactionManagement; | ||
|
||
@EnableAutoConfiguration | ||
@Import({ SpringCloudStreamEventExternalizerConfiguration.class }) | ||
@EmbeddedKafka(partitions = 1, topics = { "customers-json-topic" }) | ||
@EnableTransactionManagement | ||
public class TestsConfiguration { | ||
|
||
@Bean | ||
public ObjectMapper objectMapper() { | ||
return new ObjectMapper(); // Customize if needed | ||
} | ||
|
||
@Bean | ||
EmbeddedKafkaBroker embeddedKafkaBroker() { | ||
return new EmbeddedKafkaZKBroker(1, true, 1, "customers-json-topic"); | ||
} | ||
|
||
@Bean | ||
CustomerEventsProducer customerEventsProducer(ApplicationEventPublisher applicationEventPublisher) { | ||
return new CustomerEventsProducer(applicationEventPublisher); | ||
} | ||
|
||
static class CustomerEventsProducer { | ||
|
||
private final ApplicationEventPublisher applicationEventPublisher; | ||
|
||
public CustomerEventsProducer(ApplicationEventPublisher applicationEventPublisher) { | ||
this.applicationEventPublisher = applicationEventPublisher; | ||
} | ||
|
||
public void onCustomerEventJson(io.zenwave360.modulith.events.scs.dtos.json.CustomerEvent event) { | ||
Message<io.zenwave360.modulith.events.scs.dtos.json.CustomerEvent> message = MessageBuilder.withPayload(event) | ||
.setHeader( | ||
SpringCloudStreamEventExternalizer.SPRING_CLOUD_STREAM_SENDTO_DESTINATION_HEADER, | ||
"customers-json-out-0") // <- target binding name | ||
.build(); | ||
applicationEventPublisher.publishEvent(message); | ||
} | ||
|
||
public void onCustomerEventAvro(io.zenwave360.modulith.events.scs.dtos.avro.CustomerEvent event) { | ||
Message<io.zenwave360.modulith.events.scs.dtos.avro.CustomerEvent> message = MessageBuilder.withPayload(event) | ||
.setHeader( | ||
SpringCloudStreamEventExternalizer.SPRING_CLOUD_STREAM_SENDTO_DESTINATION_HEADER, | ||
"customers-avro-out-0") // <- target binding name | ||
.build(); | ||
applicationEventPublisher.publishEvent(message); | ||
} | ||
} | ||
} |
Oops, something went wrong.