use of org.mule.runtime.api.component.Component in project mule by mulesoft.
the class ComponentInvocationHandlerTestCase method overridesAbstractAnnotated.
@Test
public void overridesAbstractAnnotated() throws Exception {
Class<Component> clazz = addAnnotationsToClass(ExtendsAnnotated.class);
Method method = clazz.getMethod("setSomething", Object.class);
assertThat(method.getAnnotation(Inject.class), not(nullValue()));
}
use of org.mule.runtime.api.component.Component in project mule by mulesoft.
the class MVELExpressionLanguageTestCase method collectionAccessPayloadChangedMULE7506.
@Test
public void collectionAccessPayloadChangedMULE7506() throws Exception {
PrivilegedEvent event = this.<PrivilegedEvent.Builder>getEventBuilder().message(of(new String[] { "1", "2" })).build();
assertEquals("1", mvel.evaluateUntyped("payload[0]", event, PrivilegedEvent.builder(event), ((Component) flowConstruct).getLocation(), null));
event = PrivilegedEvent.builder(event).message(InternalMessage.builder(event.getMessage()).value(singletonList("1")).build()).build();
assertEquals("1", mvel.evaluateUntyped("payload[0]", event, PrivilegedEvent.builder(event), ((Component) flowConstruct).getLocation(), null));
}
use of org.mule.runtime.api.component.Component in project mule by mulesoft.
the class FirstSuccessfulTestCase method createFirstSuccessfulRouter.
private FirstSuccessful createFirstSuccessfulRouter(Processor... processors) throws Exception {
FirstSuccessful fs = new FirstSuccessful();
fs.setAnnotations(getAppleFlowComponentLocationAnnotations());
final FlowConstruct flow = mock(FlowConstruct.class, withSettings().extraInterfaces(Component.class));
when(flow.getMuleContext()).thenReturn(muleContext);
when(((Component) flow).getLocation()).thenReturn(TEST_CONNECTOR_LOCATION);
fs.setMuleContext(muleContext);
fs.setRoutes(asList(processors));
return fs;
}
use of org.mule.runtime.api.component.Component in project mule by mulesoft.
the class DefaultPolicyManager method createOperationPolicy.
@Override
public OperationPolicy createOperationPolicy(Component operation, CoreEvent event, Map<String, Object> operationParameters, OperationExecutionFunction operationExecutionFunction) {
PolicyPointcutParameters operationPointcutParameters = policyPointcutParametersManager.createOperationPointcutParameters(operation, event, operationParameters);
List<Policy> parameterizedPolicies = policyProvider.findOperationParameterizedPolicies(operationPointcutParameters);
if (parameterizedPolicies.isEmpty()) {
return (operationEvent) -> operationExecutionFunction.execute(operationParameters, operationEvent);
}
return new CompositeOperationPolicy(parameterizedPolicies, lookupOperationParametersTransformer(operation.getLocation().getComponentIdentifier().getIdentifier()), operationPolicyProcessorFactory, () -> operationParameters, operationExecutionFunction, streamingManager);
}
use of org.mule.runtime.api.component.Component in project mule by mulesoft.
the class PolicyPointcutParametersManager method createOperationPointcutParameters.
/**
* Creates {@link PolicyPointcutParameters} for a specific operation. Stored parameters from the source are included in the
* newly created parameters to be able to correlate parameters from both source and operation.
*
* @param operation the operation component to which policies will be applied
* @param event the event which will execute the operation policies
* @param operationParameters a map containing the parameters of the operation
* @return the created {@link PolicyPointcutParameters}
*/
public PolicyPointcutParameters createOperationPointcutParameters(Component operation, CoreEvent event, Map<String, Object> operationParameters) {
ComponentIdentifier operationIdentifier = operation.getLocation().getComponentIdentifier().getIdentifier();
PolicyPointcutParameters sourceParameters = sourceParametersMap.get(event.getContext().getCorrelationId());
OperationPolicyPointcutParametersParameters parameters = new OperationPolicyPointcutParametersParameters(operation, operationParameters, sourceParameters);
Function<OperationPolicyPointcutParametersFactory, PolicyPointcutParameters> creationFunction = factory -> {
try {
return factory.createPolicyPointcutParameters(parameters);
} catch (AbstractMethodError error) {
return factory.createPolicyPointcutParameters(parameters.getOperation(), parameters.getOperationParameters());
}
};
return createPointcutParameters(operation, OperationPolicyPointcutParametersFactory.class, operationPointcutFactories, factory -> factory.supportsOperationIdentifier(operationIdentifier), creationFunction).orElse(new PolicyPointcutParameters(operation, sourceParameters));
}
Aggregations