### Question:
DefaultController implements TrafficShapingController { @Override public boolean canPass(Node node, int acquireCount) { return canPass(node, acquireCount, false); } DefaultController(double count, int grade); @Override boolean canPass(Node node, int acquireCount); @Override boolean canPass(Node node, int acquireCount, boolean prioritized);  }### Answer:
@Test public void testCanPassForQps() { double threshold = 10; TrafficShapingController controller = new DefaultController(threshold, RuleConstant.FLOW_GRADE_QPS); Node node = mock(Node.class); when(node.passQps()).thenReturn(threshold - 1) .thenReturn(threshold); assertTrue(controller.canPass(node, 1)); assertFalse(controller.canPass(node, 1)); }
@Test public void testCanPassForThreadCount() { int threshold = 8; TrafficShapingController controller = new DefaultController(threshold, RuleConstant.FLOW_GRADE_THREAD); Node node = mock(Node.class); when(node.curThreadNum()).thenReturn(threshold - 1) .thenReturn(threshold); assertTrue(controller.canPass(node, 1)); assertFalse(controller.canPass(node, 1)); }