use of org.mule.runtime.policy.api.SourcePolicyPointcutParametersFactory in project mule by mulesoft.
the class PolicyPointcutParametersManagerTestCase method createSourceParametersWhenOneFactorySupportsIdentifierAndOneNot.
@Test
public void createSourceParametersWhenOneFactorySupportsIdentifierAndOneNot() {
SourcePolicyPointcutParametersFactory factory1 = mockSourceFactory(true);
SourcePolicyPointcutParametersFactory factory2 = mockSourceFactory(false);
sourcePointcutFactories.add(factory1);
sourcePointcutFactories.add(factory2);
PolicyPointcutParameters parameters = parametersManager.createSourcePointcutParameters(component, event);
assertThat(parameters.getComponent(), is(component));
assertThat(parameters.getSourceParameters(), empty());
verify(factory1).supportsSourceIdentifier(identifier);
verify(factory1).createPolicyPointcutParameters(component, event.getMessage().getAttributes());
verify(factory2).supportsSourceIdentifier(identifier);
verify(factory2, never()).createPolicyPointcutParameters(component, event.getMessage().getAttributes());
verify(eventContext).onTerminated(any());
}
use of org.mule.runtime.policy.api.SourcePolicyPointcutParametersFactory 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.SourcePolicyPointcutParametersFactory 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.SourcePolicyPointcutParametersFactory 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;
}
Aggregations