Search in sources :

Example 1 with ProcessorsTrace

use of org.mule.runtime.core.api.context.notification.ProcessorsTrace in project mule by mulesoft.

the class MessageProcessingFlowTraceManagerTestCase method hasExecutedProcessors.

private Matcher<ProcessorsTrace> hasExecutedProcessors(final String... expectedProcessors) {
    return new TypeSafeMatcher<ProcessorsTrace>() {

        private List<Matcher> failed = new ArrayList<>();

        @Override
        protected boolean matchesSafely(ProcessorsTrace processorsTrace) {
            Matcher<Collection<? extends Object>> sizeMatcher = hasSize(expectedProcessors.length);
            if (!sizeMatcher.matches(processorsTrace.getExecutedProcessors())) {
                failed.add(sizeMatcher);
            }
            int i = 0;
            for (String expectedProcessor : expectedProcessors) {
                Matcher processorItemMatcher = is(expectedProcessor);
                if (!processorItemMatcher.matches(processorsTrace.getExecutedProcessors().get(i))) {
                    failed.add(processorItemMatcher);
                }
                ++i;
            }
            return failed.isEmpty();
        }

        @Override
        public void describeTo(Description description) {
            description.appendValue(Arrays.asList(expectedProcessors));
        }

        @Override
        protected void describeMismatchSafely(ProcessorsTrace item, Description description) {
            description.appendText("was ").appendValue(item.getExecutedProcessors());
        }
    };
}
Also used : TypeSafeMatcher(org.hamcrest.TypeSafeMatcher) Description(org.hamcrest.Description) TypeSafeMatcher(org.hamcrest.TypeSafeMatcher) Matcher(org.hamcrest.Matcher) Collection(java.util.Collection) ArrayList(java.util.ArrayList) List(java.util.List) ProcessorsTrace(org.mule.runtime.core.api.context.notification.ProcessorsTrace)

Aggregations

ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1 List (java.util.List)1 Description (org.hamcrest.Description)1 Matcher (org.hamcrest.Matcher)1 TypeSafeMatcher (org.hamcrest.TypeSafeMatcher)1 ProcessorsTrace (org.mule.runtime.core.api.context.notification.ProcessorsTrace)1