Search in sources :

Example 16 with PolicyPointcutParameters

use of org.mule.runtime.policy.api.PolicyPointcutParameters 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)

Example 17 with PolicyPointcutParameters

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

the class PolicyPointcutParametersManagerTestCase method mockSourceFactory.

private SourcePolicyPointcutParametersFactory mockSourceFactory(boolean supportsIdentifier) {
    SourcePolicyPointcutParametersFactory factory = mock(SourcePolicyPointcutParametersFactory.class);
    when(factory.supportsSourceIdentifier(identifier)).thenReturn(supportsIdentifier);
    PolicyPointcutParameters parameters = new PolicyPointcutParameters(component);
    when(factory.createPolicyPointcutParameters(component, event.getMessage().getAttributes())).thenReturn(parameters);
    return factory;
}
Also used : SourcePolicyPointcutParametersFactory(org.mule.runtime.policy.api.SourcePolicyPointcutParametersFactory) PolicyPointcutParameters(org.mule.runtime.policy.api.PolicyPointcutParameters)

Aggregations

PolicyPointcutParameters (org.mule.runtime.policy.api.PolicyPointcutParameters)17 Test (org.junit.Test)11 OperationPolicyPointcutParametersFactory (org.mule.runtime.policy.api.OperationPolicyPointcutParametersFactory)10 SourcePolicyPointcutParametersFactory (org.mule.runtime.policy.api.SourcePolicyPointcutParametersFactory)8 HashMap (java.util.HashMap)7 Collection (java.util.Collection)4 Map (java.util.Map)4 Optional (java.util.Optional)4 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)4 Component (org.mule.runtime.api.component.Component)4 ComponentIdentifier (org.mule.runtime.api.component.ComponentIdentifier)4 CoreEvent (org.mule.runtime.core.api.event.CoreEvent)4 String.format (java.lang.String.format)2 Collections.emptyList (java.util.Collections.emptyList)2 List (java.util.List)2 Optional.empty (java.util.Optional.empty)2 Optional.of (java.util.Optional.of)2 Function (java.util.function.Function)2 Predicate (java.util.function.Predicate)2 Inject (javax.inject.Inject)2