Search in sources :

Example 21 with Description

use of io.qameta.allure.Description in project mule by mulesoft.

the class AbstractForkJoinStrategyTestCase method timeoutEager.

@Test
@Description("When configured with delayErrors='false' the first timeout causes strategy to throw a TimeoutException.")
public void timeoutEager() throws Throwable {
    strategy = createStrategy(processingStrategy, 1, false, 50);
    Message pair2Result = of(2);
    Processor pair2Processor = createProcessorSpy(pair2Result);
    RoutingPair pair2 = of(testEvent(), createChain(pair2Processor));
    expectedException.expect(instanceOf(DefaultMuleException.class));
    expectedException.expectCause(instanceOf(TimeoutException.class));
    invokeStrategyBlocking(strategy, testEvent(), asList(createRoutingPairWithSleep(of(1), 250), pair2), throwable -> verify(pair2Processor, never()).process(any(CoreEvent.class)));
}
Also used : DefaultMuleException(org.mule.runtime.api.exception.DefaultMuleException) ReactiveProcessor(org.mule.runtime.core.api.processor.ReactiveProcessor) InternalProcessor(org.mule.runtime.core.privileged.processor.InternalProcessor) Processor(org.mule.runtime.core.api.processor.Processor) Message(org.mule.runtime.api.message.Message) RoutingPair(org.mule.runtime.core.internal.routing.ForkJoinStrategy.RoutingPair) TimeoutException(java.util.concurrent.TimeoutException) Description(io.qameta.allure.Description) Test(org.junit.Test)

Example 22 with Description

use of io.qameta.allure.Description in project mule by mulesoft.

the class AbstractForkJoinStrategyTestCase method timeout.

@Test
@Description("When a route timeout occurs a CompositeRoutingException is thrown with details of timeout error in RoutingResult.")
public void timeout() throws Throwable {
    strategy = createStrategy(processingStrategy, 1, true, 50);
    expectedException.expect(instanceOf(CompositeRoutingException.class));
    invokeStrategyBlocking(strategy, testEvent(), asList(createRoutingPairWithSleep(of(1), 250)), throwable -> {
        CompositeRoutingException compositeRoutingException = assertCompositeRoutingException(throwable, 1);
        RoutingResult routingResult = assertRoutingResult(compositeRoutingException, 0, 1);
        assertThat(routingResult.getFailures().get("0").getCause(), instanceOf(TimeoutException.class));
    });
}
Also used : CompositeRoutingException(org.mule.runtime.core.privileged.routing.CompositeRoutingException) RoutingResult(org.mule.runtime.core.privileged.routing.RoutingResult) TimeoutException(java.util.concurrent.TimeoutException) Description(io.qameta.allure.Description) Test(org.junit.Test)

Example 23 with Description

use of io.qameta.allure.Description in project mule by mulesoft.

the class CollectListForkJoinStrategyTestCase method collectList.

@Test
@Description("This strategy waits for all routes to return and then collects results into a list.")
public void collectList() throws Throwable {
    CoreEvent original = testEvent();
    Message route1Result = of(1);
    Message route2Result = of(2);
    Message route3Result = of(3);
    RoutingPair pair1 = createRoutingPair(route1Result);
    RoutingPair pair2 = createRoutingPair(route2Result);
    RoutingPair pair3 = createRoutingPair(route3Result);
    CoreEvent result = invokeStrategyBlocking(strategy, original, asList(pair1, pair2, pair3));
    assertThat(result.getMessage().getPayload().getValue(), instanceOf(List.class));
    List<Message> resultList = (List<Message>) result.getMessage().getPayload().getValue();
    assertThat(resultList, hasSize(3));
    assertThat(resultList, hasItems(route1Result, route2Result, route3Result));
}
Also used : Message(org.mule.runtime.api.message.Message) CoreEvent(org.mule.runtime.core.api.event.CoreEvent) List(java.util.List) Arrays.asList(java.util.Arrays.asList) RoutingPair(org.mule.runtime.core.internal.routing.ForkJoinStrategy.RoutingPair) Description(io.qameta.allure.Description) Test(org.junit.Test)

Example 24 with Description

use of io.qameta.allure.Description in project mule by mulesoft.

the class ScatterGatherRouterTestCase method consumablePayload.

@Test
@Description("Consumable payloads are not supported.")
public void consumablePayload() throws Exception {
    MessageProcessorChain route1 = newChain(empty(), event -> event);
    MessageProcessorChain route2 = newChain(empty(), event -> event);
    router.setRoutes(asList(route1, route2));
    muleContext.getInjector().inject(router);
    router.setAnnotations(getAppleFlowComponentLocationAnnotations());
    router.initialise();
    expectedException.expect(instanceOf(MuleRuntimeException.class));
    router.process(CoreEvent.builder(testEvent()).message(Message.of(new StringBufferInputStream(TEST_PAYLOAD))).build());
}
Also used : MessageProcessorChain(org.mule.runtime.core.privileged.processor.chain.MessageProcessorChain) StringBufferInputStream(java.io.StringBufferInputStream) MuleRuntimeException(org.mule.runtime.api.exception.MuleRuntimeException) Description(io.qameta.allure.Description) Test(org.junit.Test)

Example 25 with Description

use of io.qameta.allure.Description in project mule by mulesoft.

the class SplitAggregateScopeTestCase method customTargetMessage.

@Test
@Description("When a custom target is configured the router result is set in a variable and the input event is output.")
public void customTargetMessage() throws Exception {
    final String variableName = "foo";
    CoreEvent original = createListEvent();
    MessageProcessorChain nested = newChain(empty(), event -> event);
    nested.setMuleContext(muleContext);
    router.setMessageProcessors(singletonList(nested));
    router.setTarget(variableName);
    router.setTargetValue("#[message]");
    muleContext.getInjector().inject(router);
    router.setAnnotations(getAppleFlowComponentLocationAnnotations());
    router.initialise();
    Event result = router.process(original);
    assertThat(result.getMessage(), equalTo(original.getMessage()));
    assertThat(((Message) result.getVariables().get(variableName).getValue()).getPayload().getValue(), instanceOf(List.class));
    List<Message> resultList = (List<Message>) ((Message) result.getVariables().get(variableName).getValue()).getPayload().getValue();
    assertThat(resultList, hasSize(2));
}
Also used : MessageProcessorChain(org.mule.runtime.core.privileged.processor.chain.MessageProcessorChain) Message(org.mule.runtime.api.message.Message) CoreEvent(org.mule.runtime.core.api.event.CoreEvent) Event(org.mule.runtime.api.event.Event) CoreEvent(org.mule.runtime.core.api.event.CoreEvent) Collections.singletonList(java.util.Collections.singletonList) List(java.util.List) ArrayList(java.util.ArrayList) Description(io.qameta.allure.Description) Test(org.junit.Test)

Aggregations

Description (io.qameta.allure.Description)123 Test (org.junit.Test)111 CoreEvent (org.mule.runtime.core.api.event.CoreEvent)41 Matchers.containsString (org.hamcrest.Matchers.containsString)15 Message (org.mule.runtime.api.message.Message)13 TypedValue (org.mule.runtime.api.metadata.TypedValue)13 RoutingPair (org.mule.runtime.core.internal.routing.ForkJoinStrategy.RoutingPair)12 MessageProcessorChain (org.mule.runtime.core.privileged.processor.chain.MessageProcessorChain)12 OperationParameters (org.mule.runtime.extension.api.client.OperationParameters)12 Issue (io.qameta.allure.Issue)10 Matchers.anyString (org.mockito.Matchers.anyString)8 List (java.util.List)7 MavenConfiguration (org.mule.maven.client.api.model.MavenConfiguration)7 Processor (org.mule.runtime.core.api.processor.Processor)7 PlainCommand (com.axibase.tsd.api.model.command.PlainCommand)6 PropertyCommand (com.axibase.tsd.api.model.command.PropertyCommand)6 Property (com.axibase.tsd.api.model.property.Property)6 RemoteRepository (org.mule.maven.client.api.model.RemoteRepository)6 Event (org.mule.runtime.api.event.Event)6 ReactiveProcessor (org.mule.runtime.core.api.processor.ReactiveProcessor)6