Package org.axonframework.domain

Examples of org.axonframework.domain.EventMessage


        assertEquals("java.lang", actual);
    }

    @Test
    public void testOnlyPayloadTypeIsUsed() {
        EventMessage mockMessage = mock(EventMessage.class);
        when(mockMessage.getPayloadType()).thenReturn(RoutingKeyResolver.class);
        String actual = testSubject
                .resolveRoutingKey(mockMessage);
        assertEquals("org.axonframework.eventhandling.amqp", actual);
        // make sure only the payload type method is invoked
        verify(mockMessage).getPayloadType();
View Full Code Here


    }

    @SuppressWarnings("unchecked")
    @Test
    public void testAllSagasAreInvoked() {
        EventMessage event = new GenericEventMessage<Object>(new Object());
        final Saga saga1 = mock(Saga.class);
        final Saga saga2 = mock(Saga.class);
        when(saga1.getSagaIdentifier()).thenReturn("saga1");
        when(saga2.getSagaIdentifier()).thenReturn("saga2");
        activate(saga1);
View Full Code Here

        verify(mockEventBus).unsubscribe(testSubject);
    }

    @Test
    public void testSagasLoadedAndCommitted() {
        EventMessage event = new GenericEventMessage<Object>(new Object());
        testSubject.handle(event);
        verify(mockSaga1).handle(event);
        verify(mockSaga2).handle(event);
        verify(mockSaga3, never()).handle(isA(EventMessage.class));
        verify(mockSagaRepository).commit(mockSaga1);
View Full Code Here

    }

    @Test
    public void testExceptionPropagated() {
        testSubject.setSuppressExceptions(false);
        EventMessage event = new GenericEventMessage<Object>(new Object());
        doThrow(new MockException()).when(mockSaga1).handle(event);
        try {
            testSubject.handle(event);
            fail("Expected exception to be propagated");
        } catch (RuntimeException e) {
View Full Code Here

        verify(mockSagaRepository, never()).commit(mockSaga2);
    }

    @Test
    public void testExceptionSuppressed() {
        EventMessage event = new GenericEventMessage<Object>(new Object());
        doThrow(new MockException()).when(mockSaga1).handle(event);

        testSubject.handle(event);

        verify(mockSaga1).handle(event);
View Full Code Here

                .thenReturn(Collections.<String>emptySet())
                .thenReturn(singleton("saga1"));

        sagaCreationPolicy = SagaCreationPolicy.IF_NONE_FOUND;
        final AtomicInteger nestingCounter = new AtomicInteger(20);
        final EventMessage event = GenericEventMessage.asEventMessage(new Object());

        doAnswer(new Answer() {
            @Override
            public Object answer(InvocationOnMock invocationOnMock) throws Throwable {
                if (nestingCounter.decrementAndGet() > 0) {
View Full Code Here

    }

    @Test
    public void testEventMessagesArePublishedWhenLaterDomainEventMessageIsReleased() {
        EventMessage intermediateEventMessage = newEventMessage("idBla", START_TIME);
        testSubject.onIncomingMessages(mockCluster, messages.get(MINUTE_BEFORE_START));
        testSubject.onIncomingMessages(mockCluster, messages.get(SECOND_BEFORE_START));
        testSubject.onIncomingMessages(mockCluster, intermediateEventMessage);
        testSubject.onIncomingMessages(mockCluster, messages.get(START_TIME));
        testSubject.releaseMessage(mockCluster, messages.get(MINUTE_BEFORE_START));
View Full Code Here

            @Override
            public boolean matches(Object o) {
                if (!(o instanceof EventMessage)) {
                    return false;
                }
                EventMessage that = (EventMessage) o;
                return payloadType.isInstance(that.getPayload());
            }

            @Override
            public void describeTo(Description description) {
                description.appendText("Event with payload of type [");
View Full Code Here

        oos.writeObject(publishedMessages.get(0));
        oos.close();

        ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(baos.toByteArray()));
        EventMessage actual = (EventMessage) ois.readObject();

        assertNotSame(actual.getClass(), publishedMessages.get(0).getClass());
        assertEquals(actual.getIdentifier(), publishedMessages.get(0).getIdentifier());
        assertEquals(actual.getTimestamp(), publishedMessages.get(0).getTimestamp());
        assertEquals(actual.getPayload(), publishedMessages.get(0).getPayload());
        assertEquals(actual.getPayloadType(), publishedMessages.get(0).getPayloadType());
        assertEquals(actual.getMetaData(), publishedMessages.get(0).getMetaData());
        assertEquals("test1", actual.getMetaData().get("test1"));
        assertEquals("test2", actual.getMetaData().get("test2"));
        assertEquals("test3", actual.getMetaData().get("test3"));
    }
View Full Code Here

        assertEquals(1, publishedMessages.size());
        final ByteArrayOutputStream baos = new ByteArrayOutputStream();
        final XStream xStream = new XStream();
        xStream.toXML(publishedMessages.get(0), baos);
        EventMessage actual = (EventMessage) xStream.fromXML(new ByteArrayInputStream(baos.toByteArray()));

        assertNotSame(actual.getClass(), publishedMessages.get(0).getClass());
        assertEquals(actual.getIdentifier(), publishedMessages.get(0).getIdentifier());
        assertEquals(actual.getTimestamp(), publishedMessages.get(0).getTimestamp());
        assertEquals(actual.getPayload(), publishedMessages.get(0).getPayload());
        assertEquals(actual.getPayloadType(), publishedMessages.get(0).getPayloadType());
        assertEquals(actual.getMetaData(), publishedMessages.get(0).getMetaData());
        assertEquals("test1", actual.getMetaData().get("test1"));
        assertEquals("test2", actual.getMetaData().get("test2"));
        assertEquals("test3", actual.getMetaData().get("test3"));
    }
View Full Code Here

TOP

Related Classes of org.axonframework.domain.EventMessage

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.