Package com.saasovation.common.event

Examples of com.saasovation.common.event.TestableDomainEvent


        assertNotNull(this.eventStore);

        List<DomainEvent> events = new ArrayList<DomainEvent>();

        for (int idx = 1; idx <= 2; ++idx) {
            events.add(new TestableDomainEvent(idx, "Name: " + idx));
        }

        EventStreamId eventId = new EventStreamId(UUID.randomUUID().toString());

        this.eventStore.appendWith(eventId, events);
View Full Code Here


        assertNotNull(this.eventStore);

        List<DomainEvent> events = new ArrayList<DomainEvent>();

        for (int idx = 1; idx <= 3; ++idx) {
            events.add(new TestableDomainEvent(idx, "Name: " + idx));
        }

        EventStreamId eventId = new EventStreamId(UUID.randomUUID().toString());

        this.eventStore.appendWith(eventId, events);

        EventStream eventStream = this.eventStore.fullEventStreamFor(eventId);

        assertEquals(3, eventStream.version());
        assertEquals(3, eventStream.events().size());

        events.clear();
        events.add(new TestableDomainEvent(4, "Name: " + 4));

        this.eventStore.appendWith(eventId.withStreamVersion(4), events);

        eventStream = this.eventStore.fullEventStreamFor(eventId);
View Full Code Here

        assertNotNull(this.eventStore);

        List<DomainEvent> events = new ArrayList<DomainEvent>();

        for (int idx = 1; idx <= 10; ++idx) {
            events.add(new TestableDomainEvent(idx, "Name: " + idx));
        }

        EventStreamId eventId = new EventStreamId(UUID.randomUUID().toString());

        this.eventStore.appendWith(eventId, events);

        EventStream eventStream = this.eventStore.fullEventStreamFor(eventId);

        assertEquals(10, eventStream.version());
        assertEquals(10, eventStream.events().size());

        events.clear();
        events.add(new TestableDomainEvent(11, "Name: " + 11));

        for (int idx = 0; idx < 3; ++idx) {
            try {
                this.eventStore.appendWith(eventId.withStreamVersion(8 + idx), events);
View Full Code Here

        assertNotNull(this.eventStore);

        List<DomainEvent> events = new ArrayList<DomainEvent>();

        for (int idx = 1; idx <= 10; ++idx) {
            events.add(new TestableDomainEvent(idx, "Name: " + idx));
        }

        EventStreamId eventId = new EventStreamId(UUID.randomUUID().toString());

        this.eventStore.appendWith(eventId, events);
View Full Code Here

        assertNotNull(this.eventStore);

        List<DomainEvent> events = new ArrayList<DomainEvent>();

        for (int idx = 1; idx <= 10; ++idx) {
            events.add(new TestableDomainEvent(idx, "Name: " + idx));
        }

        EventStreamId eventId = new EventStreamId(UUID.randomUUID().toString());

        this.eventStore.appendWith(eventId, events);
View Full Code Here

        assertNotNull(this.eventStore);

        List<DomainEvent> events = new ArrayList<DomainEvent>();

        for (int idx = 1; idx <= 3; ++idx) {
            events.add(new TestableDomainEvent(idx, "Name: " + idx));
        }

        EventStreamId eventId = new EventStreamId(UUID.randomUUID().toString());

        this.eventStore.appendWith(eventId, events);

        EventStream eventStream = this.eventStore.fullEventStreamFor(eventId);

        assertEquals(3, eventStream.version());
        assertEquals(3, eventStream.events().size());

        events.clear();
        events.add(new TestableDomainEvent(4, "Name: " + 4));

        this.eventStore.appendWith(eventId.withStreamVersion(4), events);

        eventStream = this.eventStore.fullEventStreamFor(eventId);
View Full Code Here

    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();

        assertNotNull(reconstitutedDomainEvent);
        assertEquals(domainEvent.id(), reconstitutedDomainEvent.id());
        assertEquals(domainEvent.name(), reconstitutedDomainEvent.name());
        assertEquals(domainEvent.occurredOn(), reconstitutedDomainEvent.occurredOn());
    }
View Full Code Here

    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();

        assertNotNull(reconstitutedDomainEvent);
        assertEquals(lastDomainEvent.id(), reconstitutedDomainEvent.id());
        assertEquals(lastDomainEvent.name(), reconstitutedDomainEvent.name());
        assertEquals(lastDomainEvent.occurredOn(), reconstitutedDomainEvent.occurredOn());
    }
View Full Code Here

    }

    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();

        assertNotNull(reconstitutedDomainEvent);
        assertEquals(domainEvent.id(), reconstitutedDomainEvent.id());
        assertEquals(domainEvent.name(), reconstitutedDomainEvent.name());
        assertEquals(domainEvent.occurredOn(), reconstitutedDomainEvent.occurredOn());
    }
View Full Code Here

        }

        long startId = 991;

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

            this.eventStore.append(domainEvent);
        }

        LevelDBUnitOfWork.current().commit();
View Full Code Here

TOP

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

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.