-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added EventPublishingService that represents AxonFramework EventGateway
- Loading branch information
Showing
4 changed files
with
86 additions
and
0 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
32 changes: 32 additions & 0 deletions
32
...ithub/joht/showcase/quarkuseventsourcing/messaging/query/axon/EventPublishingAdapter.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,32 @@ | ||
package io.github.joht.showcase.quarkuseventsourcing.messaging.query.axon; | ||
|
||
import static javax.transaction.Transactional.TxType.REQUIRED; | ||
|
||
import javax.transaction.Transactional; | ||
|
||
import org.axonframework.eventhandling.gateway.EventGateway; | ||
|
||
import io.github.joht.showcase.quarkuseventsourcing.messaging.query.boundary.EventPublishingService; | ||
|
||
public class EventPublishingAdapter implements EventPublishingService { | ||
|
||
private final EventGateway eventGateway; | ||
|
||
public EventPublishingAdapter(EventGateway eventGateway) { | ||
this.eventGateway = eventGateway; | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
@Override | ||
@Transactional(REQUIRED) | ||
public void publish(Object... events) { | ||
eventGateway.publish(events); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "EventPublishingAdapter [eventGateway=" + eventGateway + "]"; | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
...b/joht/showcase/quarkuseventsourcing/messaging/query/boundary/EventPublishingService.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,15 @@ | ||
package io.github.joht.showcase.quarkuseventsourcing.messaging.query.boundary; | ||
|
||
/** | ||
* Provides methods to publish events. | ||
* Based on the "EventGateway" in "AxonFramework". | ||
*/ | ||
public interface EventPublishingService { | ||
|
||
/** | ||
* Publishes events that will be dispatched to all subscribed listeners. | ||
* | ||
* @param events The collection of events to publish | ||
*/ | ||
void publish(Object... events); | ||
} |
31 changes: 31 additions & 0 deletions
31
...b/joht/showcase/quarkuseventsourcing/messaging/query/axon/EventPublishingAdapterTest.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,31 @@ | ||
package io.github.joht.showcase.quarkuseventsourcing.messaging.query.axon; | ||
|
||
import static org.mockito.Mockito.verify; | ||
|
||
import org.axonframework.eventhandling.gateway.EventGateway; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.ExtendWith; | ||
import org.mockito.InjectMocks; | ||
import org.mockito.Mock; | ||
import org.mockito.junit.jupiter.MockitoExtension; | ||
|
||
@ExtendWith(MockitoExtension.class) | ||
class EventPublishingAdapterTest { | ||
|
||
@Mock | ||
EventGateway eventGateway; | ||
|
||
@InjectMocks | ||
EventPublishingAdapter adapterUnderTest; | ||
|
||
@Test | ||
void eventPublishDelegatedToEventGateway() { | ||
TestEvent testEvent = new TestEvent(); | ||
adapterUnderTest.publish(testEvent); | ||
verify(eventGateway).publish(testEvent); | ||
} | ||
|
||
private static class TestEvent { | ||
|
||
} | ||
} |