### Question:
FlowSlot extends AbstractLinkedProcessorSlot<DefaultNode> { void checkFlow(ResourceWrapper resource, Context context, DefaultNode node, int count, boolean prioritized) throws BlockException { checker.checkFlow(ruleProvider, resource, context, node, count, prioritized); } FlowSlot();   FlowSlot(FlowRuleChecker checker); @Override void entry(Context context, ResourceWrapper resourceWrapper, DefaultNode node, int count,
                      boolean prioritized, Object... args); @Override void exit(Context context, ResourceWrapper resourceWrapper, int count, Object... args);  }### Answer:
@Test @SuppressWarnings("unchecked") public void testCheckFlowPass() throws Exception { FlowRuleChecker checker = mock(FlowRuleChecker.class); FlowSlot flowSlot = new FlowSlot(checker); Context context = mock(Context.class); DefaultNode node = mock(DefaultNode.class); doCallRealMethod().when(checker).checkFlow(any(Function.class), any(ResourceWrapper.class), any(Context.class), any(DefaultNode.class), anyInt(), anyBoolean()); String resA = "resAK"; String resB = "resBK"; FlowRule rule1 = new FlowRule(resA).setCount(10); FlowRule rule2 = new FlowRule(resB).setCount(10); FlowRuleManager.loadRules(Collections.singletonList(rule1)); when(checker.canPassCheck(eq(rule1), any(Context.class), any(DefaultNode.class), anyInt(), anyBoolean())) .thenReturn(true); when(checker.canPassCheck(eq(rule2), any(Context.class), any(DefaultNode.class), anyInt(), anyBoolean())) .thenReturn(false); flowSlot.checkFlow(new StringResourceWrapper(resA, EntryType.IN), context, node, 1, false); flowSlot.checkFlow(new StringResourceWrapper(resB, EntryType.IN), context, node, 1, false); }
@Test(expected = FlowException.class) @SuppressWarnings("unchecked") public void testCheckFlowBlock() throws Exception { FlowRuleChecker checker = mock(FlowRuleChecker.class); FlowSlot flowSlot = new FlowSlot(checker); Context context = mock(Context.class); DefaultNode node = mock(DefaultNode.class); doCallRealMethod().when(checker).checkFlow(any(Function.class), any(ResourceWrapper.class), any(Context.class), any(DefaultNode.class), anyInt(), anyBoolean()); String resA = "resAK"; FlowRule rule = new FlowRule(resA).setCount(10); FlowRuleManager.loadRules(Collections.singletonList(rule)); when(checker.canPassCheck(any(FlowRule.class), any(Context.class), any(DefaultNode.class), anyInt(), anyBoolean())) .thenReturn(false); flowSlot.checkFlow(new StringResourceWrapper(resA, EntryType.IN), context, node, 1, false); }