@Test public void testIsWorkToDo() { final ProcessorNode procNode = Mockito.mock(ProcessorNode.class); Mockito.when(procNode.hasIncomingConnection()).thenReturn(false); final Processor processor = Mockito.mock(Processor.class); Mockito.when(procNode.getIdentifier()).thenReturn("123"); Mockito.when(procNode.getRunnableComponent()).thenReturn(processor); final ConnectableTask task = createTask(procNode); assertFalse(task.invoke().isYield()); final Connection selfLoopingConnection = Mockito.mock(Connection.class); when(selfLoopingConnection.getSource()).thenReturn(procNode); when(selfLoopingConnection.getDestination()).thenReturn(procNode); when(procNode.hasIncomingConnection()).thenReturn(true); when(procNode.getIncomingConnections()).thenReturn(Collections.singletonList(selfLoopingConnection)); assertFalse(task.invoke().isYield()); final FlowFileQueue flowFileQueue = Mockito.mock(FlowFileQueue.class); when(flowFileQueue.isActiveQueueEmpty()).thenReturn(true); final FlowFileQueue nonEmptyQueue = Mockito.mock(FlowFileQueue.class); when(nonEmptyQueue.isActiveQueueEmpty()).thenReturn(false); when(selfLoopingConnection.getFlowFileQueue()).thenReturn(nonEmptyQueue); assertFalse(task.invoke().isYield()); final Connection emptyConnection = Mockito.mock(Connection.class); when(emptyConnection.getSource()).thenReturn(Mockito.mock(ProcessorNode.class)); when(emptyConnection.getDestination()).thenReturn(procNode); when(emptyConnection.getFlowFileQueue()).thenReturn(flowFileQueue); when(procNode.getIncomingConnections()).thenReturn(Collections.singletonList(emptyConnection)); assertTrue(task.invoke().isYield()); final Connection nonEmptyConnection = Mockito.mock(Connection.class); when(nonEmptyConnection.getSource()).thenReturn(Mockito.mock(ProcessorNode.class)); when(nonEmptyConnection.getDestination()).thenReturn(procNode); when(nonEmptyConnection.getFlowFileQueue()).thenReturn(nonEmptyQueue); when(procNode.getIncomingConnections()).thenReturn(Collections.singletonList(nonEmptyConnection)); assertFalse(task.invoke().isYield()); }
private boolean isWorkToDo() { boolean hasNonLoopConnection = Connectables.hasNonLoopConnection(connectable); if (connectable.getConnectableType() == ConnectableType.FUNNEL) { return connectable.hasIncomingConnection() && hasNonLoopConnection && !connectable.getConnections().isEmpty() && Connectables.flowFilesQueued(connectable); } final boolean isSourceComponent = connectable.isTriggerWhenEmpty() || !connectable.hasIncomingConnection() || !hasNonLoopConnection; return isSourceComponent || Connectables.flowFilesQueued(connectable); }
ConnectableTask { private boolean isWorkToDo() { boolean hasNonLoopConnection = Connectables.hasNonLoopConnection(connectable); if (connectable.getConnectableType() == ConnectableType.FUNNEL) { return connectable.hasIncomingConnection() && hasNonLoopConnection && !connectable.getConnections().isEmpty() && Connectables.flowFilesQueued(connectable); } final boolean isSourceComponent = connectable.isTriggerWhenEmpty() || !connectable.hasIncomingConnection() || !hasNonLoopConnection; return isSourceComponent || Connectables.flowFilesQueued(connectable); } }
ConnectableTask { private boolean isWorkToDo() { boolean hasNonLoopConnection = Connectables.hasNonLoopConnection(connectable); if (connectable.getConnectableType() == ConnectableType.FUNNEL) { return connectable.hasIncomingConnection() && hasNonLoopConnection && !connectable.getConnections().isEmpty() && Connectables.flowFilesQueued(connectable); } final boolean isSourceComponent = connectable.isTriggerWhenEmpty() || !connectable.hasIncomingConnection() || !hasNonLoopConnection; return isSourceComponent || Connectables.flowFilesQueued(connectable); } ConnectableTask(final SchedulingAgent schedulingAgent, final Connectable connectable,
            final FlowController flowController, final RepositoryContextFactory contextFactory, final LifecycleState scheduleState,
            final StringEncryptor encryptor); }
ConnectableTask { private boolean isWorkToDo() { boolean hasNonLoopConnection = Connectables.hasNonLoopConnection(connectable); if (connectable.getConnectableType() == ConnectableType.FUNNEL) { return connectable.hasIncomingConnection() && hasNonLoopConnection && !connectable.getConnections().isEmpty() && Connectables.flowFilesQueued(connectable); } final boolean isSourceComponent = connectable.isTriggerWhenEmpty() || !connectable.hasIncomingConnection() || !hasNonLoopConnection; return isSourceComponent || Connectables.flowFilesQueued(connectable); } ConnectableTask(final SchedulingAgent schedulingAgent, final Connectable connectable,
            final FlowController flowController, final RepositoryContextFactory contextFactory, final LifecycleState scheduleState,
            final StringEncryptor encryptor); void setExceptionToleranceCount(int exceptionToleranceCount); int getExceptionToleranceCount(); Connectable getConnectable(); InvocationResult invoke(); }
ConnectableTask { private boolean isWorkToDo() { boolean hasNonLoopConnection = Connectables.hasNonLoopConnection(connectable); if (connectable.getConnectableType() == ConnectableType.FUNNEL) { return connectable.hasIncomingConnection() && hasNonLoopConnection && !connectable.getConnections().isEmpty() && Connectables.flowFilesQueued(connectable); } final boolean isSourceComponent = connectable.isTriggerWhenEmpty() || !connectable.hasIncomingConnection() || !hasNonLoopConnection; return isSourceComponent || Connectables.flowFilesQueued(connectable); } ConnectableTask(final SchedulingAgent schedulingAgent, final Connectable connectable,
            final FlowController flowController, final RepositoryContextFactory contextFactory, final LifecycleState scheduleState,
            final StringEncryptor encryptor); void setExceptionToleranceCount(int exceptionToleranceCount); int getExceptionToleranceCount(); Connectable getConnectable(); InvocationResult invoke();  }