Package org.axonframework.domain

Examples of org.axonframework.domain.SimpleDomainEventStream


    @Test
    public void testScheduleSnapshot() {
        Object aggregateIdentifier = "aggregateIdentifier";
        when(mockEventStore.readEvents("test", aggregateIdentifier))
                .thenReturn(new SimpleDomainEventStream(
                        new GenericDomainEventMessage<String>(aggregateIdentifier, (long) 0,
                                                              "Mock contents", MetaData.emptyInstance()),
                        new GenericDomainEventMessage<String>(aggregateIdentifier, (long) 1,
                                                              "Mock contents", MetaData.emptyInstance())));
        testSubject.scheduleSnapshot("test", aggregateIdentifier);
View Full Code Here


                .when(mockEventStore).appendSnapshotEvent(eq("test"), isA(DomainEventMessage.class));
        when(mockEventStore.readEvents("test", aggregateIdentifier))
                .thenAnswer(new Answer<Object>() {
                    @Override
                    public Object answer(InvocationOnMock invocationOnMock) throws Throwable {
                        return new SimpleDomainEventStream(
                                new GenericDomainEventMessage<String>(aggregateIdentifier, (long) 0,
                                                                      "Mock contents", MetaData.emptyInstance()),
                                new GenericDomainEventMessage<String>(aggregateIdentifier, (long) 1,
                                                                      "Mock contents", MetaData.emptyInstance()));
                    }
View Full Code Here

    @Test
    public void testScheduleSnapshot_SnapshotIsNull() {
        Object aggregateIdentifier = "aggregateIdentifier";
        when(mockEventStore.readEvents("test", aggregateIdentifier))
                .thenReturn(new SimpleDomainEventStream(
                        new GenericDomainEventMessage<String>(aggregateIdentifier, (long) 0,
                                                              "Mock contents", MetaData.emptyInstance())));
        testSubject.scheduleSnapshot("test", aggregateIdentifier);
        verify(mockEventStore, never()).appendSnapshotEvent(any(String.class), any(DomainEventMessage.class));
    }
View Full Code Here

    @Test
    public void testScheduleSnapshot_SnapshotReplacesOneEvent() {
        Object aggregateIdentifier = "aggregateIdentifier";
        when(mockEventStore.readEvents("test", aggregateIdentifier))
                .thenReturn(new SimpleDomainEventStream(
                        new GenericDomainEventMessage<String>(aggregateIdentifier, (long) 2,
                                                              "Mock contents", MetaData.emptyInstance())));
        testSubject.scheduleSnapshot("test", aggregateIdentifier);
        verify(mockEventStore, never()).appendSnapshotEvent(any(String.class), any(DomainEventMessage.class));
    }
View Full Code Here

                if (message.getSequenceNumber() >= firstSequenceNumber
                        && message.getSequenceNumber() <= lastSequenceNumber) {
                    filteredEvents.add(message);
                }
            }
            return new SimpleDomainEventStream(filteredEvents);
        }
View Full Code Here

        @Override
        public DomainEventStream readEvents(String type, Object identifier) {
            if (!store.containsKey(identifier)) {
                throw new AggregateNotFoundException(identifier, "Aggregate not found");
            }
            return new SimpleDomainEventStream(store.get(identifier));
        }
View Full Code Here

    public void testCreateSnapshot() {
        UUID aggregateIdentifier = UUID.randomUUID();
        DomainEventMessage firstEvent = new GenericDomainEventMessage<String>(aggregateIdentifier, (long) 0,
                                                                              "Mock contents", MetaData.emptyInstance()
        );
        SimpleDomainEventStream eventStream = new SimpleDomainEventStream(firstEvent);
        EventSourcedAggregateRoot aggregate = mock(EventSourcedAggregateRoot.class);
        when(aggregate.getIdentifier()).thenReturn(aggregateIdentifier);
        when(mockAggregateFactory.createAggregate(aggregateIdentifier, firstEvent)).thenReturn(aggregate);

        DomainEventMessage snapshot =  testSubject.createSnapshot("test", aggregateIdentifier, eventStream);
View Full Code Here

                new GenericDomainEventMessage<StubAggregate>(
                        aggregate.getIdentifier(), aggregate.getVersion(), aggregate);
        DomainEventMessage secondEvent = new GenericDomainEventMessage<String>(aggregateIdentifier, (long) 0,
                                                                               "Mock contents", MetaData.emptyInstance()
        );
        SimpleDomainEventStream eventStream = new SimpleDomainEventStream(first, secondEvent);

        when(mockAggregateFactory.createAggregate(any(), any(DomainEventMessage.class)))
                .thenAnswer(new Answer<Object>() {
                    @Override
                    public Object answer(InvocationOnMock invocation) throws Throwable {
View Full Code Here

    private String identifier = "aggregateIdentifier";

    @Test
    public void testInitializeWithEvents() {
        testSubject = new CompositeAggregateRoot();
        testSubject.initializeState(new SimpleDomainEventStream(new GenericDomainEventMessage<String>(
                identifier,
                (long) 243,
                "Mock contents", MetaData
                .emptyInstance()
        )));
View Full Code Here

            storedEvents.put(key, lastEvent);
        }

        @Override
        public DomainEventStream readEvents(String type, Object identifier) {
            return new SimpleDomainEventStream(Collections.singletonList(storedEvents.get(identifier.toString())));
        }
View Full Code Here

TOP

Related Classes of org.axonframework.domain.SimpleDomainEventStream

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.