Search in sources :

Example 11 with ProcessorInitializationContext

use of org.apache.nifi.processor.ProcessorInitializationContext in project nifi by apache.

the class TestConsumeAzureEventHub method setupProcessor.

@Before
public void setupProcessor() {
    processor = new ConsumeAzureEventHub();
    final ProcessorInitializationContext initContext = Mockito.mock(ProcessorInitializationContext.class);
    final String componentId = "componentId";
    when(initContext.getIdentifier()).thenReturn(componentId);
    MockComponentLog componentLog = new MockComponentLog(componentId, processor);
    when(initContext.getLogger()).thenReturn(componentLog);
    processor.initialize(initContext);
    final ProcessSessionFactory processSessionFactory = Mockito.mock(ProcessSessionFactory.class);
    processor.setProcessSessionFactory(processSessionFactory);
    processor.setNamespaceName("namespace");
    sharedState = new SharedSessionState(processor, new AtomicLong(0));
    processSession = new MockProcessSession(sharedState, processor);
    when(processSessionFactory.createSession()).thenReturn(processSession);
    eventProcessor = processor.new EventProcessor();
    partitionContext = Mockito.mock(PartitionContext.class);
    when(partitionContext.getEventHubPath()).thenReturn("eventhub-name");
    when(partitionContext.getPartitionId()).thenReturn("partition-id");
    when(partitionContext.getConsumerGroupName()).thenReturn("consumer-group");
}
Also used : PartitionContext(com.microsoft.azure.eventprocessorhost.PartitionContext) SharedSessionState(org.apache.nifi.util.SharedSessionState) AtomicLong(java.util.concurrent.atomic.AtomicLong) MockComponentLog(org.apache.nifi.util.MockComponentLog) ProcessSessionFactory(org.apache.nifi.processor.ProcessSessionFactory) MockProcessSession(org.apache.nifi.util.MockProcessSession) ProcessorInitializationContext(org.apache.nifi.processor.ProcessorInitializationContext) Before(org.junit.Before)

Example 12 with ProcessorInitializationContext

use of org.apache.nifi.processor.ProcessorInitializationContext in project nifi-minifi by apache.

the class ProcessorInitializer method initialize.

@Override
public void initialize(ConfigurableComponent component) {
    Processor processor = (Processor) component;
    ProcessorInitializationContext initializationContext = new MockProcessorInitializationContext();
    try (NarCloseable narCloseable = NarCloseable.withComponentNarLoader(component.getClass(), initializationContext.getIdentifier())) {
        processor.initialize(initializationContext);
    }
}
Also used : NarCloseable(org.apache.nifi.nar.NarCloseable) Processor(org.apache.nifi.processor.Processor) MockProcessorInitializationContext(org.apache.nifi.mock.MockProcessorInitializationContext) MockProcessorInitializationContext(org.apache.nifi.mock.MockProcessorInitializationContext) ProcessorInitializationContext(org.apache.nifi.processor.ProcessorInitializationContext)

Aggregations

ProcessorInitializationContext (org.apache.nifi.processor.ProcessorInitializationContext)12 Processor (org.apache.nifi.processor.Processor)6 Test (org.junit.Test)5 ProcessContext (org.apache.nifi.processor.ProcessContext)4 ComponentLog (org.apache.nifi.logging.ComponentLog)3 ProcessSession (org.apache.nifi.processor.ProcessSession)3 StandardProcessorInitializationContext (org.apache.nifi.processor.StandardProcessorInitializationContext)3 JmsProcessingSummary (org.apache.nifi.processors.standard.util.JmsProcessingSummary)3 MockProcessContext (org.apache.nifi.util.MockProcessContext)3 MockProcessorInitializationContext (org.apache.nifi.util.MockProcessorInitializationContext)3 TestRunner (org.apache.nifi.util.TestRunner)3 IOException (java.io.IOException)2 InputStream (java.io.InputStream)2 Bundle (org.apache.nifi.bundle.Bundle)2 MockProcessorInitializationContext (org.apache.nifi.mock.MockProcessorInitializationContext)2 NarCloseable (org.apache.nifi.nar.NarCloseable)2 AbstractProcessor (org.apache.nifi.processor.AbstractProcessor)2 InputStreamCallback (org.apache.nifi.processor.io.InputStreamCallback)2 StandardComponentVariableRegistry (org.apache.nifi.registry.variable.StandardComponentVariableRegistry)2 ModifiesClasspathNoAnnotationProcessor (org.apache.nifi.test.processors.ModifiesClasspathNoAnnotationProcessor)2