Search in sources :

Example 1 with OperationPolicyParametersTransformer

use of org.mule.runtime.core.api.policy.OperationPolicyParametersTransformer in project mule by mulesoft.

the class CompositeOperationPolicyTestCase method singlePolicy.

@Test
public void singlePolicy() throws Exception {
    compositeOperationPolicy = new CompositeOperationPolicy(asList(firstPolicy), operationPolicyParametersTransformer, operationPolicyProcessorFactory, operationParametersProcessor, operationExecutionFunction, streamingManager);
    CoreEvent result = from(compositeOperationPolicy.process(initialEvent)).doOnNext(event1 -> System.out.println("FINAL " + event1.getMessage().getPayload().getValue())).block();
    assertThat(result.getMessage(), is(nextProcessResultEvent.getMessage()));
    verify(operationExecutionFunction).execute(any(), same(initialEvent));
    verify(operationPolicyProcessorFactory).createOperationPolicy(same(firstPolicy), any());
    verify(firstPolicyOperationPolicyProcessor).apply(any());
}
Also used : Matchers.same(org.mockito.Matchers.same) Message(org.mule.runtime.api.message.Message) Optional.of(java.util.Optional.of) Processor(org.mule.runtime.core.api.processor.Processor) StreamingManager(org.mule.runtime.core.api.streaming.StreamingManager) Assert.assertThat(org.junit.Assert.assertThat) AbstractMuleTestCase(org.mule.tck.junit4.AbstractMuleTestCase) MuleException(org.mule.runtime.api.exception.MuleException) Arrays.asList(java.util.Arrays.asList) Is.is(org.hamcrest.core.Is.is) ExpectedException.none(org.junit.rules.ExpectedException.none) Mono.from(reactor.core.publisher.Mono.from) Mono.just(reactor.core.publisher.Mono.just) RETURNS_DEEP_STUBS(org.mockito.Mockito.RETURNS_DEEP_STUBS) Mono.error(reactor.core.publisher.Mono.error) ExpectedException(org.junit.rules.ExpectedException) Before(org.junit.Before) Collections.emptyList(java.util.Collections.emptyList) CoreEvent(org.mule.runtime.core.api.event.CoreEvent) EventContextFactory.create(org.mule.runtime.core.api.event.EventContextFactory.create) Test(org.junit.Test) Mockito.when(org.mockito.Mockito.when) OperationPolicyParametersTransformer(org.mule.runtime.core.api.policy.OperationPolicyParametersTransformer) Mockito.verify(org.mockito.Mockito.verify) Matchers.any(org.mockito.Matchers.any) Rule(org.junit.Rule) Exceptions.rxExceptionToMuleException(org.mule.runtime.core.api.rx.Exceptions.rxExceptionToMuleException) Policy(org.mule.runtime.core.api.policy.Policy) Optional(java.util.Optional) DefaultComponentLocation.fromSingleComponent(org.mule.runtime.dsl.api.component.config.DefaultComponentLocation.fromSingleComponent) FlowConstruct(org.mule.runtime.core.api.construct.FlowConstruct) Mockito.mock(org.mockito.Mockito.mock) CoreEvent(org.mule.runtime.core.api.event.CoreEvent) Test(org.junit.Test)

Aggregations

Arrays.asList (java.util.Arrays.asList)1 Collections.emptyList (java.util.Collections.emptyList)1 Optional (java.util.Optional)1 Optional.of (java.util.Optional.of)1 Is.is (org.hamcrest.core.Is.is)1 Assert.assertThat (org.junit.Assert.assertThat)1 Before (org.junit.Before)1 Rule (org.junit.Rule)1 Test (org.junit.Test)1 ExpectedException (org.junit.rules.ExpectedException)1 ExpectedException.none (org.junit.rules.ExpectedException.none)1 Matchers.any (org.mockito.Matchers.any)1 Matchers.same (org.mockito.Matchers.same)1 RETURNS_DEEP_STUBS (org.mockito.Mockito.RETURNS_DEEP_STUBS)1 Mockito.mock (org.mockito.Mockito.mock)1 Mockito.verify (org.mockito.Mockito.verify)1 Mockito.when (org.mockito.Mockito.when)1 MuleException (org.mule.runtime.api.exception.MuleException)1 Message (org.mule.runtime.api.message.Message)1 FlowConstruct (org.mule.runtime.core.api.construct.FlowConstruct)1