-
Notifications
You must be signed in to change notification settings - Fork 31
/
AbstractTramEventTest.java
41 lines (27 loc) · 1.18 KB
/
AbstractTramEventTest.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package io.eventuate.tram.examples.basic.events;
import io.eventuate.tram.events.common.DomainEvent;
import io.eventuate.tram.events.publisher.DomainEventPublisher;
import io.eventuate.tram.examples.basic.events.domain.AccountDebited;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.Collections;
import java.util.concurrent.TimeUnit;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
public abstract class AbstractTramEventTest {
@Autowired
private DomainEventPublisher domainEventPublisher;
@Autowired
private AbstractTramEventTestConfig config;
@Autowired
private TramEventTestEventConsumer tramEventTestEventConsumer;
@Test
public void shouldReceiveEvent() throws InterruptedException {
long uniqueId = config.get();
DomainEvent domainEvent = new AccountDebited(uniqueId);
domainEventPublisher.publish(config.getAggregateType(), config.getAggregateId(), Collections.singletonList(domainEvent));
AccountDebited event = tramEventTestEventConsumer.getQueue().poll(10, TimeUnit.SECONDS);
assertNotNull(event);
assertEquals(uniqueId, event.getAmount());
}
}