Package com.saasovation.common.event

Examples of com.saasovation.common.event.EventStore


    public LevelDBEventStoreTest() {
        super();
    }

    public void testAllStoredEventsBetween() throws Exception {
        EventStore eventStore = this.eventStore();

        long totalEvents = eventStore.countStoredEvents();

        assertEquals(totalEvents, eventStore.allStoredEventsBetween(1, totalEvents).size());

        assertEquals(10, eventStore.allStoredEventsBetween(totalEvents - 9, totalEvents).size());
    }
View Full Code Here


        assertEquals(10, eventStore.allStoredEventsBetween(totalEvents - 9, totalEvents).size());
    }

    public void testAllStoredEventsSince() throws Exception {
        EventStore eventStore = this.eventStore();

        long totalEvents = eventStore.countStoredEvents();

        assertEquals(totalEvents, eventStore.allStoredEventsSince(0).size());

        assertEquals(0, eventStore.allStoredEventsSince(totalEvents).size());

        assertEquals(10, eventStore.allStoredEventsSince(totalEvents - 10).size());
    }
View Full Code Here

        assertEquals(10, eventStore.allStoredEventsSince(totalEvents - 10).size());
    }

    public void testAppend() throws Exception {
        EventStore eventStore = this.eventStore();

        long numberOfEvents = eventStore.countStoredEvents();

        TestableDomainEvent domainEvent = new TestableDomainEvent(10001, "testDomainEvent");

        StoredEvent storedEvent = eventStore.append(domainEvent);

        assertTrue(eventStore.countStoredEvents() > numberOfEvents);
        assertEquals(numberOfEvents + 1, eventStore.countStoredEvents());

        assertNotNull(storedEvent);

        TestableDomainEvent reconstitutedDomainEvent = storedEvent.toDomainEvent();
View Full Code Here

        assertEquals(domainEvent.name(), reconstitutedDomainEvent.name());
        assertEquals(domainEvent.occurredOn(), reconstitutedDomainEvent.occurredOn());
    }

    public void testCountStoredEvents() throws Exception {
        EventStore eventStore = this.eventStore();

        long numberOfEvents = eventStore.countStoredEvents();

        TestableDomainEvent lastDomainEvent = null;

        for (int idx = 0; idx < 10; ++idx) {
            TestableDomainEvent domainEvent = new TestableDomainEvent(10001 + idx, "testDomainEvent" + idx);

            lastDomainEvent = domainEvent;

            eventStore.append(domainEvent);
        }

        LevelDBUnitOfWork.current().commit();

        assertEquals(numberOfEvents + 10, eventStore.countStoredEvents());

        numberOfEvents = eventStore.countStoredEvents();

        assertEquals(1, eventStore.allStoredEventsBetween(numberOfEvents, numberOfEvents + 1000).size());

        StoredEvent storedEvent = eventStore.allStoredEventsBetween(numberOfEvents, numberOfEvents).get(0);

        assertNotNull(storedEvent);

        TestableDomainEvent reconstitutedDomainEvent = storedEvent.toDomainEvent();
View Full Code Here

        assertEquals(lastDomainEvent.name(), reconstitutedDomainEvent.name());
        assertEquals(lastDomainEvent.occurredOn(), reconstitutedDomainEvent.occurredOn());
    }

    public void testStoredEvent() throws Exception {
        EventStore eventStore = this.eventStore();

        TestableDomainEvent domainEvent = new TestableDomainEvent(10001, "testDomainEvent");

        StoredEvent storedEvent = eventStore.append(domainEvent);

        assertNotNull(storedEvent);

        TestableDomainEvent reconstitutedDomainEvent = storedEvent.toDomainEvent();
View Full Code Here

    public RabbitMQNotificationPublisherTest() {
        super();
    }

    public void testPublishNotifications() throws Exception {
        EventStore eventStore = this.eventStore();

        assertNotNull(eventStore);

        PublishedNotificationTrackerStore publishedNotificationTrackerStore =
                new HibernatePublishedNotificationTrackerStore(
View Full Code Here

        super.setUp();

        // always start with at least 20 events

        EventStore eventStore = this.eventStore();

        long startingDomainEventId = (new Date()).getTime();

        for (int idx = 0; idx < 20; ++idx) {
            long domainEventId = startingDomainEventId + 1;

            DomainEvent event = new TestableDomainEvent(domainEventId, "name" + domainEventId);

            eventStore.append(event);
        }
    }
View Full Code Here

            eventStore.append(event);
        }
    }

    private EventStore eventStore() {
        EventStore eventStore = new HibernateEventStore(new PersistenceManagerProvider(this.session()));

        assertNotNull(eventStore);

        return eventStore;
    }
View Full Code Here

        super();
    }

    public void testNewNotificationPublisher() throws Exception {

        EventStore eventStore = new MockEventStore(new PersistenceManagerProvider() {});

        assertNotNull(eventStore);

        PublishedNotificationTrackerStore publishedNotificationTrackerStore =
                new HibernatePublishedNotificationTrackerStore(
View Full Code Here

    public NotificationLogTest() {
        super();
    }

    public void testCurrentNotificationLogFromFactory() throws Exception {
        EventStore eventStore = this.eventStore();
        NotificationLogFactory factory = new NotificationLogFactory(eventStore);
        NotificationLog log = factory.createCurrentNotificationLog();

        assertTrue(NotificationLogFactory.notificationsPerLog() >= log.totalNotifications());
        assertTrue(eventStore.countStoredEvents() >= log.totalNotifications());
        assertFalse(log.hasNextNotificationLog());
        assertTrue(log.hasPreviousNotificationLog());
        assertFalse(log.isArchived());
    }
View Full Code Here

TOP

Related Classes of com.saasovation.common.event.EventStore

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.