use of org.apache.nifi.controller.ProcessScheduler in project nifi by apache.
the class TestProcessorLifecycle method validateIdempotencyOfProcessorStartOperation.
/**
* Will validate the idempotent nature of processor start operation which
* can be called multiple times without any side-effects.
*/
@Test
public void validateIdempotencyOfProcessorStartOperation() throws Exception {
final FlowControllerAndSystemBundle fcsb = this.buildFlowControllerForTest();
fc = fcsb.getFlowController();
ProcessGroup testGroup = fc.createProcessGroup(UUID.randomUUID().toString());
this.setControllerRootGroup(fc, testGroup);
final ProcessorNode testProcNode = fc.createProcessor(TestProcessor.class.getName(), UUID.randomUUID().toString(), fcsb.getSystemBundle().getBundleDetails().getCoordinate());
testProcNode.setProperties(properties);
TestProcessor testProcessor = (TestProcessor) testProcNode.getProcessor();
// sets the scenario for the processor to run
this.noop(testProcessor);
final ProcessScheduler ps = fc.getProcessScheduler();
ps.startProcessor(testProcNode, true);
ps.startProcessor(testProcNode, true);
ps.startProcessor(testProcNode, true);
Thread.sleep(500);
assertCondition(() -> testProcessor.operationNames.size() == 1);
assertEquals("@OnScheduled", testProcessor.operationNames.get(0));
}
Aggregations