### Question:
SentinelDubboConsumerFilter extends BaseSentinelDubboFilter { @Override String getInterfaceName(Invoker invoker, String prefix) { return DubboUtils.getInterfaceName(invoker, prefix); } SentinelDubboConsumerFilter(); @Override Result invoke(Invoker<?> invoker, Invocation invocation);  }### Answer:
@Test public void testInterfaceLevelFollowControlAsync() throws InterruptedException { Invoker invoker = DubboTestUtil.getDefaultMockInvoker(); Invocation invocation = DubboTestUtil.getDefaultMockInvocationOne(); when(invocation.getAttachment(ASYNC_KEY)).thenReturn(Boolean.TRUE.toString()); initFlowRule(DubboUtils.getInterfaceName(invoker)); Result result1 = invokeDubboRpc(false, invoker, invocation); assertEquals("normal", result1.getValue()); Result result2 = invokeDubboRpc(false, invoker, invocation); assertEquals("fallback", result2.getValue()); Thread.sleep(1000); Result result3 = invokeDubboRpc(false, invoker, invocation); assertEquals("normal", result3.getValue()); verifyInvocationStructureForCallFinish(invoker, invocation); }
@Test public void testDegradeAsync() throws InterruptedException { Invocation invocation = DubboTestUtil.getDefaultMockInvocationOne(); Invoker invoker = DubboTestUtil.getDefaultMockInvoker(); when(invocation.getAttachment(ASYNC_KEY)).thenReturn(Boolean.TRUE.toString()); initDegradeRule(DubboUtils.getInterfaceName(invoker)); Result result = invokeDubboRpc(false, invoker, invocation); verifyInvocationStructureForCallFinish(invoker, invocation); assertEquals("normal", result.getValue()); for (int i = 0; i < 5; i++) { invokeDubboRpc(true, invoker, invocation); verifyInvocationStructureForCallFinish(invoker, invocation); } Result result2 = invokeDubboRpc(false, invoker, invocation); assertEquals("fallback", result2.getValue()); Thread.sleep(1000); Result result3 = invokeDubboRpc(false, invoker, invocation); assertEquals("normal", result3.getValue()); Context context = ContextUtil.getContext(); assertNull(context); }
@Test public void testDegradeSync() throws InterruptedException { Invocation invocation = DubboTestUtil.getDefaultMockInvocationOne(); Invoker invoker = DubboTestUtil.getDefaultMockInvoker(); initDegradeRule(DubboUtils.getInterfaceName(invoker)); Result result = invokeDubboRpc(false, invoker, invocation); verifyInvocationStructureForCallFinish(invoker, invocation); assertEquals("normal", result.getValue()); for (int i = 0; i < 5; i++) { invokeDubboRpc(true, invoker, invocation); verifyInvocationStructureForCallFinish(invoker, invocation); } Result result2 = invokeDubboRpc(false, invoker, invocation); assertEquals("fallback", result2.getValue()); Thread.sleep(1000); Result result3 = invokeDubboRpc(false, invoker, invocation); assertEquals("normal", result3.getValue()); Context context = ContextUtil.getContext(); assertNull(context); }