@Test
public void testAddEvent_3() {
assertTrue(myUserInfo.retrieveEvents(1000).isEmpty());
for(int i = 0; i < 100; i++) {
myUserInfo.addEvent(TEST_DOMAIN, new DummyEvent());
myUserInfo.addEvent(TEST_DOMAIN_2, new DummyEvent());
myUserInfo.addEvent(TEST_DOMAIN_2, new DummyEvent());
myUserInfo.addEvent(null, new DummyEvent());
myUserInfo.addEvent(null, new DummyEvent());
myUserInfo.addEvent(null, new DummyEvent());
}
List<DomainEvent> theEvents = myUserInfo.retrieveEvents(1000);
assertEquals(600, theEvents.size());
assertTrue(myUserInfo.retrieveEvents(1000).isEmpty()); //all events got
int theDomainEventCount_1 = 0;
int theDomainEventCount_2 = 0;
int theUserSpecificEventCount = 0;
for(DomainEvent theDomainEvent: theEvents) {
if(theDomainEvent.getDomain() == null) {
theUserSpecificEventCount++;
} else if(TEST_DOMAIN.equals(theDomainEvent.getDomain())) {
theDomainEventCount_1++;
} else if(TEST_DOMAIN_2.equals(theDomainEvent.getDomain())) {
theDomainEventCount_2++;
}
}
assertEquals(100, theDomainEventCount_1);
assertEquals(200, theDomainEventCount_2);
assertEquals(300, theUserSpecificEventCount);
assertTrue(myUserInfo.retrieveEvents(1000).isEmpty()); //all events got
myUserInfo.addEvent(TEST_DOMAIN, new DummyEvent());
assertEquals(1, myUserInfo.retrieveEvents(1000).size());
assertTrue(myUserInfo.retrieveEvents(1000).isEmpty()); //all events got
}