Search in sources :

Example 1 with SourcePolicyPointcutParametersFactory

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());
}
Also used : SourcePolicyPointcutParametersFactory(org.mule.runtime.policy.api.SourcePolicyPointcutParametersFactory) PolicyPointcutParameters(org.mule.runtime.policy.api.PolicyPointcutParameters) Test(org.junit.Test)

Example 2 with SourcePolicyPointcutParametersFactory

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());
}
Also used : SourcePolicyPointcutParametersFactory(org.mule.runtime.policy.api.SourcePolicyPointcutParametersFactory) PolicyPointcutParameters(org.mule.runtime.policy.api.PolicyPointcutParameters) Test(org.junit.Test)

Example 3 with SourcePolicyPointcutParametersFactory

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());
}
Also used : SourcePolicyPointcutParametersFactory(org.mule.runtime.policy.api.SourcePolicyPointcutParametersFactory) PolicyPointcutParameters(org.mule.runtime.policy.api.PolicyPointcutParameters) Test(org.junit.Test)

Example 4 with SourcePolicyPointcutParametersFactory

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;
}
Also used : SourcePolicyPointcutParametersFactory(org.mule.runtime.policy.api.SourcePolicyPointcutParametersFactory) PolicyPointcutParameters(org.mule.runtime.policy.api.PolicyPointcutParameters)

Aggregations

PolicyPointcutParameters (org.mule.runtime.policy.api.PolicyPointcutParameters)4 SourcePolicyPointcutParametersFactory (org.mule.runtime.policy.api.SourcePolicyPointcutParametersFactory)4 Test (org.junit.Test)3