Search in sources :

Example 6 with StandardProcessScheduler

use of org.apache.nifi.controller.scheduling.StandardProcessScheduler in project nifi by apache.

the class TestStandardControllerServiceProvider method validateEnableServices2.

/**
 * This test is similar to the above, but different combination of service
 * dependencies
 */
@Test
public void validateEnableServices2() {
    StandardProcessScheduler scheduler = createScheduler();
    FlowController controller = Mockito.mock(FlowController.class);
    StandardControllerServiceProvider provider = new StandardControllerServiceProvider(controller, scheduler, null, stateManagerProvider, variableRegistry, niFiProperties);
    ProcessGroup procGroup = new MockProcessGroup(controller);
    Mockito.when(controller.getGroup(Mockito.anyString())).thenReturn(procGroup);
    ControllerServiceNode A = provider.createControllerService(ServiceC.class.getName(), "A", systemBundle.getBundleDetails().getCoordinate(), null, false);
    ControllerServiceNode B = provider.createControllerService(ServiceA.class.getName(), "B", systemBundle.getBundleDetails().getCoordinate(), null, false);
    ControllerServiceNode C = provider.createControllerService(ServiceB.class.getName(), "C", systemBundle.getBundleDetails().getCoordinate(), null, false);
    ControllerServiceNode D = provider.createControllerService(ServiceA.class.getName(), "D", systemBundle.getBundleDetails().getCoordinate(), null, false);
    ControllerServiceNode F = provider.createControllerService(ServiceA.class.getName(), "F", systemBundle.getBundleDetails().getCoordinate(), null, false);
    procGroup.addControllerService(A);
    procGroup.addControllerService(B);
    procGroup.addControllerService(C);
    procGroup.addControllerService(D);
    procGroup.addControllerService(F);
    setProperty(A, ServiceC.REQ_SERVICE_1.getName(), "B");
    setProperty(A, ServiceC.REQ_SERVICE_2.getName(), "D");
    setProperty(B, ServiceA.OTHER_SERVICE.getName(), "C");
    setProperty(F, ServiceA.OTHER_SERVICE.getName(), "D");
    setProperty(D, ServiceA.OTHER_SERVICE.getName(), "C");
    provider.enableControllerServices(Arrays.asList(C, F, A, B, D));
    assertTrue(A.isActive());
    assertTrue(B.isActive());
    assertTrue(C.isActive());
    assertTrue(D.isActive());
    assertTrue(F.isActive());
}
Also used : ServiceC(org.apache.nifi.controller.service.mock.ServiceC) ServiceB(org.apache.nifi.controller.service.mock.ServiceB) ServiceA(org.apache.nifi.controller.service.mock.ServiceA) ProcessGroup(org.apache.nifi.groups.ProcessGroup) MockProcessGroup(org.apache.nifi.controller.service.mock.MockProcessGroup) StandardProcessGroup(org.apache.nifi.groups.StandardProcessGroup) FlowController(org.apache.nifi.controller.FlowController) MockProcessGroup(org.apache.nifi.controller.service.mock.MockProcessGroup) StandardProcessScheduler(org.apache.nifi.controller.scheduling.StandardProcessScheduler) Test(org.junit.Test)

Aggregations

FlowController (org.apache.nifi.controller.FlowController)6 StandardProcessScheduler (org.apache.nifi.controller.scheduling.StandardProcessScheduler)6 MockProcessGroup (org.apache.nifi.controller.service.mock.MockProcessGroup)6 ProcessGroup (org.apache.nifi.groups.ProcessGroup)6 StandardProcessGroup (org.apache.nifi.groups.StandardProcessGroup)6 Test (org.junit.Test)6 ServiceA (org.apache.nifi.controller.service.mock.ServiceA)5 ServiceB (org.apache.nifi.controller.service.mock.ServiceB)5 ServiceC (org.apache.nifi.controller.service.mock.ServiceC)2 ProcessorNode (org.apache.nifi.controller.ProcessorNode)1 StandardProcessorNode (org.apache.nifi.controller.StandardProcessorNode)1