use of org.mule.runtime.policy.api.PolicyPointcutParameters in project mule by mulesoft.
the class PolicyPointcutParametersManagerTestCase method createOperationParametersWhenOneFactoryDoesNotSupportsIdentifier.
@Test
public void createOperationParametersWhenOneFactoryDoesNotSupportsIdentifier() {
Map<String, Object> operationParameters = new HashMap<>();
PolicyPointcutParameters sourceParameters = parametersManager.createSourcePointcutParameters(component, event);
OperationPolicyPointcutParametersFactory factory = mockOperationFactory(false, sourceParameters);
operationPointcutFactories.add(factory);
sourcePointcutFactories.add(mockSourceFactory(true));
PolicyPointcutParameters parameters = parametersManager.createOperationPointcutParameters(component, event, operationParameters);
assertThat(parameters.getComponent(), is(component));
assertThat(parameters.getSourceParameters(), is(of(sourceParameters)));
verify(factory).supportsOperationIdentifier(identifier);
verify(factory, never()).createPolicyPointcutParameters(any());
}
use of org.mule.runtime.policy.api.PolicyPointcutParameters in project mule by mulesoft.
the class PolicyPointcutParametersManagerTestCase method createSourceParametersWhenOneFactorySupportsIdentifier.
@Test
public void createSourceParametersWhenOneFactorySupportsIdentifier() {
SourcePolicyPointcutParametersFactory factory = mockSourceFactory(true);
sourcePointcutFactories.add(factory);
PolicyPointcutParameters parameters = parametersManager.createSourcePointcutParameters(component, event);
assertThat(parameters.getComponent(), is(component));
assertThat(parameters.getSourceParameters(), empty());
verify(factory).supportsSourceIdentifier(identifier);
verify(factory).createPolicyPointcutParameters(component, event.getMessage().getAttributes());
verify(eventContext).onTerminated(any());
}
use of org.mule.runtime.policy.api.PolicyPointcutParameters in project mule by mulesoft.
the class PolicyPointcutParametersManagerTestCase method createSourceParametersWhenOneFactoryDoesNotSupportsIdentifier.
@Test
public void createSourceParametersWhenOneFactoryDoesNotSupportsIdentifier() {
SourcePolicyPointcutParametersFactory factory = mockSourceFactory(false);
sourcePointcutFactories.add(factory);
PolicyPointcutParameters parameters = parametersManager.createSourcePointcutParameters(component, event);
assertThat(parameters.getComponent(), is(component));
assertThat(parameters.getSourceParameters(), empty());
verify(factory).supportsSourceIdentifier(identifier);
verify(factory, never()).createPolicyPointcutParameters(component, event.getMessage().getAttributes());
verify(eventContext).onTerminated(any());
}
use of org.mule.runtime.policy.api.PolicyPointcutParameters in project mule by mulesoft.
the class PolicyPointcutParametersManagerTestCase method createOperationParametersWhenOneFactorySupportsIdentifierAndOneNot.
@Test
public void createOperationParametersWhenOneFactorySupportsIdentifierAndOneNot() {
Map<String, Object> operationParameters = new HashMap<>();
PolicyPointcutParameters sourceParameters = parametersManager.createSourcePointcutParameters(component, event);
OperationPolicyPointcutParametersFactory factory1 = mockOperationFactory(true, sourceParameters);
OperationPolicyPointcutParametersFactory factory2 = mockOperationFactory(false, sourceParameters);
operationPointcutFactories.add(factory1);
operationPointcutFactories.add(factory2);
sourcePointcutFactories.add(mockSourceFactory(true));
PolicyPointcutParameters parameters = parametersManager.createOperationPointcutParameters(component, event, operationParameters);
assertThat(parameters.getComponent(), is(component));
assertThat(parameters.getSourceParameters(), is(of(sourceParameters)));
verify(factory1).supportsOperationIdentifier(identifier);
verify(factory1).createPolicyPointcutParameters(any());
verify(factory2).supportsOperationIdentifier(identifier);
verify(factory2, never()).createPolicyPointcutParameters(any());
}
use of org.mule.runtime.policy.api.PolicyPointcutParameters 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;
}
Aggregations