Package com.saasovation.common.event.sourcing

Examples of com.saasovation.common.event.sourcing.EventStreamId


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

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


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

                fail("Should have thrown an exception.");

            } catch (EventStoreAppendException e) {
                // good
            }
        }

        // this should succeed

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

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

        List<DispatchableDomainEvent> loggedEvents = this.eventStore.eventsSince(2);
View Full Code Here

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

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

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

        for (int idx = 10; idx >= 1; --idx) {
            EventStream eventStream = this.eventStore.eventStreamSince(eventId.withStreamVersion(idx));

            assertEquals(10, eventStream.version());
            assertEquals(10 - idx + 1, eventStream.events().size());

            DomainEvent domainEvent = eventStream.events().get(0);

            assertEquals(idx, ((TestableDomainEvent) domainEvent).id());
        }

        try {
            this.eventStore.eventStreamSince(eventId.withStreamVersion(11));

            fail("Should have thrown an exception.");

        } catch (EventStoreException e) {
            // good
View Full Code Here

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

                fail("Should have thrown an exception.");

            } catch (EventStoreAppendException e) {
                // good
            }
        }

        // this should succeed

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

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

        assertEquals(4, eventStream.version());
        assertEquals(4, eventStream.events().size());
View Full Code Here

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

        List<DispatchableDomainEvent> loggedEvents =
                this.eventStore.eventsSince(this.greatestEventId() - 8L);
View Full Code Here

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

        for (int idx = 10; idx >= 1; --idx) {
            EventStream eventStream = this.eventStore.eventStreamSince(eventId.withStreamVersion(idx));

            assertEquals(10, eventStream.version());
            assertEquals(10 - idx + 1, eventStream.events().size());

            DomainEvent domainEvent = eventStream.events().get(0);

            assertEquals(idx, ((TestableDomainEvent) domainEvent).id());
        }

        try {
            this.eventStore.eventStreamSince(eventId.withStreamVersion(11));

            fail("Should have thrown an exception.");

        } catch (EventStoreException e) {
            // good
View Full Code Here

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

        assertEquals(4, eventStream.version());
        assertEquals(4, eventStream.events().size());
View Full Code Here

TOP

Related Classes of com.saasovation.common.event.sourcing.EventStreamId

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.