Examples of AxonAssertionError


Examples of org.axonframework.test.AxonAssertionError

     */
    public void assertAssociationPresent(String associationKey, String associationValue) {
        Set<String> associatedSagas =
                sagaRepository.find(sagaType, new AssociationValue(associationKey, associationValue));
        if (associatedSagas.isEmpty()) {
            throw new AxonAssertionError(format(
                    "Expected a saga to be associated with key:<%s> value:<%s>, but found <none>",
                    associationKey,
                    associationValue));
        }
    }
View Full Code Here

Examples of org.axonframework.test.AxonAssertionError

     */
    public void assertNoAssociationPresent(String associationKey, String associationValue) {
        Set<String> associatedSagas =
                sagaRepository.find(sagaType, new AssociationValue(associationKey, associationValue));
        if (!associatedSagas.isEmpty()) {
            throw new AxonAssertionError(format(
                    "Expected a saga to be associated with key:<%s> value:<%s>, but found <%s>",
                    associationKey,
                    associationValue,
                    associatedSagas.size()));
        }
View Full Code Here

Examples of org.axonframework.test.AxonAssertionError

     *
     * @param expected The number of expected sagas.
     */
    public void assertActiveSagas(int expected) {
        if (expected != sagaRepository.size()) {
            throw new AxonAssertionError(format("Wrong number of active sagas. Expected <%s>, got <%s>.",
                                                expected,
                                                sagaRepository.size()));
        }
    }
View Full Code Here

Examples of org.axonframework.test.AxonAssertionError

        }
        Description expected = new StringDescription();
        Description actual = new StringDescription();
        matcher.describeTo(expected);
        describe(eventScheduler.getScheduledItems(), actual);
        throw new AxonAssertionError(String.format(
                "Did not find an event at the given schedule. \nExpected:\n<%s> at <%s>\nGot:%s\n",
                expected, scheduledTime, actual));
    }
View Full Code Here

Examples of org.axonframework.test.AxonAssertionError

     * Asserts that no events are scheduled for publication.
     */
    public void assertNoScheduledEvents() {
        List<ScheduledItem> scheduledItems = eventScheduler.getScheduledItems();
        if (scheduledItems != null && !scheduledItems.isEmpty()) {
            throw new AxonAssertionError("Expected no scheduled events, got " + scheduledItems.size());
        }
    }
View Full Code Here

Examples of org.axonframework.test.AxonAssertionError

     * @param expected The commands expected to have been published on the bus
     */
    public void assertDispatchedEqualTo(Object... expected) {
        List<CommandMessage<?>> actual = commandBus.getDispatchedCommands();
        if (actual.size() != expected.length) {
            throw new AxonAssertionError(format(
                    "Got wrong number of commands dispatched. Expected <%s>, got <%s>",
                    expected.length,
                    actual.size()));
        }
        Iterator<CommandMessage<?>> actualIterator = actual.iterator();
        Iterator<Object> expectedIterator = Arrays.asList(expected).iterator();

        int counter = 0;
        while (actualIterator.hasNext()) {
            CommandMessage<?> actualItem = actualIterator.next();
            Object expectedItem = expectedIterator.next();
            if (expectedItem instanceof CommandMessage) {
                CommandMessage<?> expectedMessage = (CommandMessage<?>) expectedItem;
                if (!expectedMessage.getPayloadType().equals(actualItem.getPayloadType())) {
                    throw new AxonAssertionError(format(
                            "Unexpected payload type of command at position %s (0-based). Expected <%s>, got <%s>",
                            counter,
                            expectedMessage.getPayloadType(),
                            actualItem.getPayloadType()));
                }
                assertCommandEquality(counter, expectedMessage.getPayload(), actualItem.getPayload());
                if (!expectedMessage.getMetaData().equals(actualItem.getMetaData())) {
                    throw new AxonAssertionError(format(
                            "Unexpected Meta Data of command at position %s (0-based). Expected <%s>, got <%s>",
                            counter,
                            expectedMessage.getMetaData(),
                            actualItem.getMetaData()));
                }
View Full Code Here

Examples of org.axonframework.test.AxonAssertionError

        if (!matcher.matches(commandBus.getDispatchedCommands())) {
            Description expectedDescription = new StringDescription();
            Description actualDescription = new StringDescription();
            matcher.describeTo(expectedDescription);
            describe(commandBus.getDispatchedCommands(), actualDescription);
            throw new AxonAssertionError(format("Incorrect dispatched command. Expected <%s>, but got <%s>",
                                                expectedDescription, actualDescription));
        }
    }
View Full Code Here

Examples of org.axonframework.test.AxonAssertionError

    }

    private void assertCommandEquality(int commandIndex, Object expected, Object actual) {
        if (!expected.equals(actual)) {
            if (!expected.getClass().equals(actual.getClass())) {
                throw new AxonAssertionError(format("Wrong command type at index %s (0-based). "
                                                            + "Expected <%s>, but got <%s>",
                                                    commandIndex,
                                                    expected.getClass().getSimpleName(),
                                                    actual.getClass().getSimpleName()));
            }
            EqualFieldsMatcher<Object> matcher = new EqualFieldsMatcher<Object>(expected);
            if (!matcher.matches(actual)) {
                throw new AxonAssertionError(format("Unexpected command at index %s (0-based). "
                                                            + "Field value of '%s.%s', expected <%s>, but got <%s>",
                                                    commandIndex,
                                                    expected.getClass().getSimpleName(),
                                                    matcher.getFailedField().getName(),
                                                    matcher.getFailedFieldExpectedValue(),
View Full Code Here

Examples of org.axonframework.test.AxonAssertionError

        if (!matcher.matches(publishedEvents)) {
            StringDescription expectedDescription = new StringDescription();
            StringDescription actualDescription = new StringDescription();
            matcher.describeTo(expectedDescription);
            describe(publishedEvents, actualDescription);
            throw new AxonAssertionError(format("Published events did not match.\nExpected:\n<%s>\n\nGot:\n<%s>\n",
                                                expectedDescription, actualDescription));
        }
    }
View Full Code Here

Examples of org.axonframework.test.AxonAssertionError

     *
     * @param expected the events that must have been published.
     */
    public void assertPublishedEvents(Object... expected) {
        if (publishedEvents.size() != expected.length) {
            throw new AxonAssertionError(format(
                    "Got wrong number of events published. Expected <%s>, got <%s>",
                    expected.length,
                    publishedEvents.size()));
        }

View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.