use of io.qameta.allure.Description in project mule by mulesoft.
the class SplitAggregateScopeTestCase method defaultTarget.
@Test
@Description("By default the router result populates the outgoing message payload.")
public void defaultTarget() throws Exception {
CoreEvent original = createListEvent();
MessageProcessorChain nested = newChain(empty(), event -> event);
nested.setMuleContext(muleContext);
router.setMessageProcessors(singletonList(nested));
muleContext.getInjector().inject(router);
router.setAnnotations(getAppleFlowComponentLocationAnnotations());
router.initialise();
Event result = router.process(original);
assertThat(result.getMessage().getPayload().getValue(), instanceOf(List.class));
List<Message> resultList = (List<Message>) result.getMessage().getPayload().getValue();
assertThat(resultList, hasSize(2));
}
use of io.qameta.allure.Description in project mule by mulesoft.
the class AbstractForkJoinStrategyTestCase method flowVarsMerged.
@Test
@Description("After successful completion of all routes the variables from each route are merged into the result.")
public void flowVarsMerged() throws Throwable {
final String beforeVarName = "before";
final String beforeVarValue = "beforeValue";
final String beforeVar2Name = "before2";
final String beforeVar2Value = "before2Value";
final String beforeVar2NewValue = "before2NewValue";
final String fooVarName = "foo";
final String fooVarValue = "fooValue1";
final String fooVar2Name = "foo2";
final String fooVar2Value1 = "foo2Value1";
final String fooVar2Value2 = "foo2Value2";
final String fooVar3Name = "foo3";
final String fooVar3Value1 = "foo3Value1";
final Apple fooVar3Value2 = new Apple();
CoreEvent original = builder(this.<CoreEvent>newEvent()).addVariable(beforeVarName, beforeVarValue).addVariable(beforeVar2Name, beforeVar2Value).build();
RoutingPair pair1 = of(original, createChain(event -> builder(event).addVariable(beforeVar2Name, beforeVar2NewValue).addVariable(fooVarName, fooVarValue).addVariable(fooVar2Name, fooVar2Value1).addVariable(fooVar3Name, fooVar3Value1).build()));
RoutingPair pair2 = of(original, createChain(event -> builder(event).addVariable(fooVar2Name, fooVar2Value2).addVariable(fooVar3Name, fooVar3Value2).build()));
CoreEvent result = invokeStrategyBlocking(strategy, original, asList(pair1, pair2));
assertThat(result.getVariables().keySet(), hasSize(5));
assertThat(result.getVariables().keySet(), hasItems(beforeVarName, beforeVar2Name, fooVarName, fooVarName, fooVar2Name, fooVar3Name));
assertThat(result.getVariables().get(beforeVarName).getValue(), equalTo(beforeVarValue));
assertThat(result.getVariables().get(beforeVar2Name).getValue(), equalTo(beforeVar2NewValue));
assertThat(result.getVariables().get(fooVarName).getValue(), equalTo(fooVarValue));
TypedValue fooVar2 = result.getVariables().get(fooVar2Name);
assertThat(fooVar2.getDataType(), equalTo(DataType.builder().collectionType(List.class).itemType(String.class).build()));
assertThat(((List<String>) fooVar2.getValue()), hasItems(fooVar2Value1, fooVar2Value2));
TypedValue fooVar3 = result.getVariables().get(fooVar3Name);
assertThat(fooVar3.getDataType(), equalTo(DataType.builder().collectionType(List.class).itemType(Object.class).build()));
assertThat(((List<Object>) fooVar3.getValue()), hasItems(fooVar3Value1, fooVar3Value2));
}
use of io.qameta.allure.Description in project mule by mulesoft.
the class AbstractForkJoinStrategyTestCase method concurrentRejectedExecution.
@Test
@Description("When executing concurrently the strategy will throw a RejectedExceptionException if the scheduler being used throws a RejectedExceptionException.")
public void concurrentRejectedExecution() throws Throwable {
when(scheduler.submit(any(Callable.class))).thenThrow(new RejectedExecutionException());
setupConcurrentProcessingStrategy();
strategy = createStrategy(processingStrategy, 4, true, MAX_VALUE);
expectedException.expect(MessagingException.class);
expectedException.expectCause(instanceOf(RejectedExecutionException.class));
invokeStrategyBlocking(strategy, testEvent(), createRoutingPairs(1));
}
use of io.qameta.allure.Description in project mule by mulesoft.
the class AbstractForkJoinStrategyTestCase method errorDelayed.
@Test
@Description("When an error occurs all routes are executed regardless and a CompositeRoutingException is thrown containing a RoutingResult with details of both failures and successes.")
public void errorDelayed() throws Throwable {
Processor processorSpy = createProcessorSpy(testEvent().getMessage());
RuntimeException exception1 = new IllegalStateException();
RoutingPair failingPair1 = of(testEvent(), createFailingRoutingPair(exception1));
RuntimeException exception2 = new UnsupportedOperationException();
RoutingPair failingPair2 = of(testEvent(), createFailingRoutingPair(exception2));
RuntimeException exception3 = new IndexOutOfBoundsException();
RoutingPair failingPair3 = of(testEvent(), createFailingRoutingPair(exception3));
RoutingPair okPair = of(testEvent(), createChain(processorSpy));
expectedException.expect(instanceOf(CompositeRoutingException.class));
invokeStrategyBlocking(strategy, testEvent(), asList(failingPair1, failingPair2, failingPair3, okPair), throwable -> {
verify(processorSpy, times(1)).process(any(CoreEvent.class));
CompositeRoutingException compositeRoutingException = assertCompositeRoutingException(throwable, 3);
RoutingResult routingResult = assertRoutingResult(compositeRoutingException, 1, 3);
assertThat(routingResult.getFailures().get("0").getCause(), is(exception1));
assertThat(routingResult.getFailures().get("1").getCause(), is(exception2));
assertThat(routingResult.getFailures().get("2").getCause(), is(exception3));
assertThat(routingResult.getFailures().get("3"), is(nullValue()));
});
}
use of io.qameta.allure.Description in project mule by mulesoft.
the class AbstractForkJoinStrategyTestCase method error.
@Test
@Description("Errors are thrown via CompositeRoutingException with RoutingResult containing details of failures.")
public void error() throws Throwable {
RuntimeException exception = new IllegalStateException();
RoutingPair failingPair = of(testEvent(), createFailingRoutingPair(exception));
expectedException.expect(instanceOf(CompositeRoutingException.class));
invokeStrategyBlocking(strategy, testEvent(), asList(failingPair), throwable -> {
CompositeRoutingException compositeRoutingException = assertCompositeRoutingException(throwable, 1);
RoutingResult routingResult = assertRoutingResult(compositeRoutingException, 0, 1);
assertThat(routingResult.getFailures().get("0").getCause(), is(exception));
});
}
Aggregations