### Question:
SentinelDubboConsumerFilter extends BaseSentinelDubboFilter { @Override public Result invoke(Invoker<?> invoker, Invocation invocation) throws RpcException { InvokeMode invokeMode = RpcUtils.getInvokeMode(invoker.getUrl(), invocation); if (InvokeMode.SYNC == invokeMode) { return syncInvoke(invoker, invocation); } else { return asyncInvoke(invoker, invocation); } } SentinelDubboConsumerFilter(); @Override Result invoke(Invoker<?> invoker, Invocation invocation);  }### Answer:
@Test public void testInvokeAsync() { Invocation invocation = DubboTestUtil.getDefaultMockInvocationOne(); Invoker invoker = DubboTestUtil.getDefaultMockInvoker(); when(invocation.getAttachment(ASYNC_KEY)).thenReturn(Boolean.TRUE.toString()); final Result result = mock(Result.class); when(result.hasException()).thenReturn(false); when(invoker.invoke(invocation)).thenAnswer(invocationOnMock -> { verifyInvocationStructureForAsyncCall(invoker, invocation); return result; }); consumerFilter.invoke(invoker, invocation); verify(invoker).invoke(invocation); Context context = ContextUtil.getContext(); assertNotNull(context); }
@Test public void testInvokeSync() { Invocation invocation = DubboTestUtil.getDefaultMockInvocationOne(); Invoker invoker = DubboTestUtil.getDefaultMockInvoker(); final Result result = mock(Result.class); when(result.hasException()).thenReturn(false); when(result.getException()).thenReturn(new Exception()); when(invoker.invoke(invocation)).thenAnswer(invocationOnMock -> { verifyInvocationStructure(invoker, invocation); return result; }); consumerFilter.invoke(invoker, invocation); verify(invoker).invoke(invocation); Context context = ContextUtil.getContext(); assertNull(context); }