Search in sources :

Example 6 with OperationPolicyPointcutParametersFactory

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

the class PolicyPointcutParametersManagerTestCase method mockOperationFactory.

private OperationPolicyPointcutParametersFactory mockOperationFactory(boolean supportsIdentifier, PolicyPointcutParameters sourceParameters) {
    OperationPolicyPointcutParametersFactory factory = mock(OperationPolicyPointcutParametersFactory.class);
    when(factory.supportsOperationIdentifier(identifier)).thenReturn(supportsIdentifier);
    PolicyPointcutParameters parameters = new PolicyPointcutParameters(component, sourceParameters);
    when(factory.createPolicyPointcutParameters(any())).thenReturn(parameters);
    return factory;
}
Also used : OperationPolicyPointcutParametersFactory(org.mule.runtime.policy.api.OperationPolicyPointcutParametersFactory) PolicyPointcutParameters(org.mule.runtime.policy.api.PolicyPointcutParameters)

Example 7 with OperationPolicyPointcutParametersFactory

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

the class PolicyPointcutParametersManagerTestCase method createOperationParametersWhenOneFactorySupportsIdentifierMultipleTimes.

@Test
public void createOperationParametersWhenOneFactorySupportsIdentifierMultipleTimes() {
    Map<String, Object> operationParameters = new HashMap<>();
    PolicyPointcutParameters sourceParameters = parametersManager.createSourcePointcutParameters(component, event);
    OperationPolicyPointcutParametersFactory factory = mockOperationFactory(true, sourceParameters);
    operationPointcutFactories.add(factory);
    sourcePointcutFactories.add(mockSourceFactory(true));
    parametersManager.createOperationPointcutParameters(component, event, operationParameters);
    PolicyPointcutParameters parameters = parametersManager.createOperationPointcutParameters(component, event, operationParameters);
    assertThat(parameters.getComponent(), is(component));
    assertThat(parameters.getSourceParameters(), is(of(sourceParameters)));
    verify(factory, times(2)).supportsOperationIdentifier(identifier);
    verify(factory, times(2)).createPolicyPointcutParameters(any());
}
Also used : HashMap(java.util.HashMap) OperationPolicyPointcutParametersFactory(org.mule.runtime.policy.api.OperationPolicyPointcutParametersFactory) PolicyPointcutParameters(org.mule.runtime.policy.api.PolicyPointcutParameters) Test(org.junit.Test)

Aggregations

OperationPolicyPointcutParametersFactory (org.mule.runtime.policy.api.OperationPolicyPointcutParametersFactory)7 PolicyPointcutParameters (org.mule.runtime.policy.api.PolicyPointcutParameters)7 HashMap (java.util.HashMap)5 Test (org.junit.Test)5 String.format (java.lang.String.format)1 Collection (java.util.Collection)1 Map (java.util.Map)1 Optional (java.util.Optional)1 Optional.empty (java.util.Optional.empty)1 Optional.of (java.util.Optional.of)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 Function (java.util.function.Function)1 Predicate (java.util.function.Predicate)1 Component (org.mule.runtime.api.component.Component)1 ComponentIdentifier (org.mule.runtime.api.component.ComponentIdentifier)1 MuleRuntimeException (org.mule.runtime.api.exception.MuleRuntimeException)1 I18nMessageFactory.createStaticMessage (org.mule.runtime.api.i18n.I18nMessageFactory.createStaticMessage)1 CoreEvent (org.mule.runtime.core.api.event.CoreEvent)1 BaseEventContext (org.mule.runtime.core.privileged.event.BaseEventContext)1 OperationPolicyPointcutParametersParameters (org.mule.runtime.policy.api.OperationPolicyPointcutParametersParameters)1