use of org.mule.runtime.api.component.Component in project mule by mulesoft.
the class MessageProcessingFlowTraceManagerTestCase method createMockProcessor.
public Processor createMockProcessor(String processorPath, boolean useLocationSettings) {
ComponentLocation componentLocation = mock(ComponentLocation.class);
when(componentLocation.getLocation()).thenReturn(processorPath);
when(componentLocation.getFileName()).thenReturn(useLocationSettings ? of(CONFIG_FILE_NAME) : empty());
when(componentLocation.getLineInFile()).thenReturn(useLocationSettings ? of(LINE_NUMBER) : empty());
Component annotatedMessageProcessor = (Component) mock(Processor.class, withSettings().extraInterfaces(Component.class).defaultAnswer(RETURNS_DEEP_STUBS));
when(annotatedMessageProcessor.getAnnotation(any())).thenReturn(null);
when(annotatedMessageProcessor.getLocation()).thenReturn(componentLocation);
return (Processor) annotatedMessageProcessor;
}
use of org.mule.runtime.api.component.Component in project mule by mulesoft.
the class MessageProcessingFlowTraceManagerTestCase method newAnnotatedComponentCall.
@Test
public void newAnnotatedComponentCall() {
CoreEvent event = buildEvent("newAnnotatedComponentCall");
PipelineMessageNotification pipelineNotification = buildPipelineNotification(event, rootFlowConstruct.getName());
assertThat(getContextInfo(event, rootFlowConstruct), is(""));
manager.onPipelineNotificationStart(pipelineNotification);
assertThat(getContextInfo(event, rootFlowConstruct), is("at " + rootFlowConstruct.getName()));
Component annotatedMessageProcessor = (Component) createMockProcessor("/comp", true);
when(annotatedMessageProcessor.getAnnotation(docNameAttrName)).thenReturn("annotatedName");
manager.onMessageProcessorNotificationPreInvoke(buildProcessorNotification(event, (Processor) annotatedMessageProcessor));
assertThat(getContextInfo(event, rootFlowConstruct), is("at " + rootFlowConstruct.getName() + "(/comp @ " + APP_ID + ":muleApp.xml:10 (annotatedName))"));
manager.onPipelineNotificationComplete(pipelineNotification);
assertThat(getContextInfo(event, rootFlowConstruct), is(""));
}
use of org.mule.runtime.api.component.Component in project mule by mulesoft.
the class ComponentInvocationHandlerTestCase method notAnnotated.
@Test
public void notAnnotated() throws Exception {
Component annotated = addAnnotationsToClass(NotAnnotated.class).newInstance();
assertThat(annotated.getAnnotations().keySet(), empty());
annotated.setAnnotations(singletonMap(LOCATION_KEY, "value"));
assertThat(annotated.getAnnotations().keySet(), contains(LOCATION_KEY));
assertThat(annotated.getClass().getMethod("setSomething", Object.class).isAnnotationPresent(Inject.class), is(true));
assertThat(removeDynamicAnnotations(annotated), instanceOf(NotAnnotated.class));
assertThat(removeDynamicAnnotations(annotated), not(instanceOf(Component.class)));
}
use of org.mule.runtime.api.component.Component in project mule by mulesoft.
the class ComponentInvocationHandlerTestCase method implementsInitialisable.
@Test
public void implementsInitialisable() throws Exception {
Component annotated = addAnnotationsToClass(ImplementsInitialisable.class).newInstance();
assertThat(annotated.getAnnotations().keySet(), empty());
annotated.setAnnotations(singletonMap(LOCATION_KEY, "value"));
assertThat(annotated.getAnnotations().keySet(), contains(LOCATION_KEY));
}
use of org.mule.runtime.api.component.Component in project mule by mulesoft.
the class ComponentInvocationHandlerTestCase method extendsAbstractAnnotated.
@Test
public void extendsAbstractAnnotated() throws Exception {
Component annotated = addAnnotationsToClass(ExtendsAnnotated.class).newInstance();
assertThat(annotated.getAnnotations().keySet(), empty());
annotated.setAnnotations(singletonMap(LOCATION_KEY, "value"));
assertThat(annotated.getAnnotations().keySet(), contains(LOCATION_KEY));
assertThat(annotated.getClass().getMethod("setSomething", Object.class).isAnnotationPresent(Inject.class), is(true));
}
Aggregations