test_class.declarator: invocation
test_class.modifier: private
test_class.original_string: private RpcInvocation invocation;
test_class.type: RpcInvocation
test_class.var_name: invocation
test_class.declarator: cacheFilter = new CacheFilter()
test_class.modifier: private
test_class.original_string: private CacheFilter cacheFilter = new CacheFilter();
test_class.type: CacheFilter
test_class.var_name: cacheFilter
test_class.declarator: invoker = mock(Invoker.class)
test_class.modifier: private
test_class.original_string: private Invoker<?> invoker = mock(Invoker.class);
test_class.type: Invoker<?>
test_class.var_name: invoker
test_class.declarator: invoker1 = mock(Invoker.class)
test_class.modifier: private
test_class.original_string: private Invoker<?> invoker1 = mock(Invoker.class);
test_class.type: Invoker<?>
test_class.var_name: invoker1
test_class.declarator: invoker2 = mock(Invoker.class)
test_class.modifier: private
test_class.original_string: private Invoker<?> invoker2 = mock(Invoker.class);
test_class.type: Invoker<?>
test_class.var_name: invoker2
test_class.declarator: invoker3 = mock(Invoker.class)
test_class.modifier: private
test_class.original_string: private Invoker<?> invoker3 = mock(Invoker.class);
test_class.type: Invoker<?>
test_class.var_name: invoker3
test_class.declarator: invoker4 = mock(Invoker.class)
test_class.modifier: private
test_class.original_string: private Invoker<?> invoker4 = mock(Invoker.class);
test_class.type: Invoker<?>
test_class.var_name: invoker4
test_class.declarator: cacheType
test_class.modifier: private
test_class.original_string: private String cacheType;
test_class.type: String
test_class.var_name: cacheType
test_class.declarator: cacheFactory
test_class.modifier: private
test_class.original_string: private CacheFactory cacheFactory;
test_class.type: CacheFactory
test_class.var_name: cacheFactory
test_class.file: dubbo-filter/dubbo-filter-cache/src/test/java/com/alibaba/dubbo/cache/filter/CacheFilterTest.java
test_class.identifier: CacheFilterTest
test_case.body: @Test
      public void testMethodWithArgs() {
          invocation.setMethodName("echo1");
          invocation.setParameterTypes(new Class<?>[]{String.class});
          invocation.setArguments(new Object[]{"arg1"});
  
          cacheFilter.invoke(invoker, invocation);
          RpcResult rpcResult1 = (RpcResult) cacheFilter.invoke(invoker1, invocation);
          RpcResult rpcResult2 = (RpcResult) cacheFilter.invoke(invoker2, invocation);
          Assert.assertEquals(rpcResult1.getValue(), rpcResult2.getValue());
          Assert.assertEquals(rpcResult1.getValue(), "value");
      }
test_case.class_method_signature: CacheFilterTest.testMethodWithArgs()
test_case.full_signature: @Test public void testMethodWithArgs()
test_case.identifier: testMethodWithArgs
test_case.invocations: setMethodName setParameterTypes setArguments invoke invoke invoke assertEquals getValue getValue assertEquals getValue
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testMethodWithArgs()
focal_class.declarator: cacheFactory
focal_class.modifier: private
focal_class.original_string: private CacheFactory cacheFactory;
focal_class.type: CacheFactory
focal_class.var_name: cacheFactory
focal_class.file: dubbo-filter/dubbo-filter-cache/src/main/java/com/alibaba/dubbo/cache/filter/CacheFilter.java
focal_class.identifier: CacheFilter
focal_class.interfaces: implements Filter
focal_class.class_method_signature: CacheFilter.setCacheFactory(CacheFactory cacheFactory)
focal_class.full_signature: public void setCacheFactory(CacheFactory cacheFactory)
focal_class.identifier: setCacheFactory
focal_class.modifiers: public
focal_class.parameters: (CacheFactory cacheFactory)
focal_class.return: void
focal_class.signature: void setCacheFactory(CacheFactory cacheFactory)
focal_class.class_method_signature: CacheFilter.invoke(Invoker<?> invoker, Invocation invocation)
focal_class.full_signature: @Override public Result invoke(Invoker<?> invoker, Invocation invocation)
focal_class.identifier: invoke
focal_class.modifiers: @Override public
focal_class.parameters: (Invoker<?> invoker, Invocation invocation)
focal_class.return: Result
focal_class.signature: Result invoke(Invoker<?> invoker, Invocation invocation)
focal_method.body: @Override
      public Result invoke(Invoker<?> invoker, Invocation invocation) throws RpcException {
          if (cacheFactory != null && ConfigUtils.isNotEmpty(invoker.getUrl().getMethodParameter(invocation.getMethodName(), Constants.CACHE_KEY))) {
              Cache cache = cacheFactory.getCache(invoker.getUrl(), invocation);
              if (cache != null) {
                  String key = StringUtils.toArgumentString(invocation.getArguments());
                  Object value = cache.get(key);
                  if (value != null) {
                      return new RpcResult(value);
                  }
                  Result result = invoker.invoke(invocation);
                  if (!result.hasException() && result.getValue() != null) {
                      cache.put(key, result.getValue());
                  }
                  return result;
              }
          }
          return invoker.invoke(invocation);
      }
focal_method.class_method_signature: CacheFilter.invoke(Invoker<?> invoker, Invocation invocation)
focal_method.full_signature: @Override public Result invoke(Invoker<?> invoker, Invocation invocation)
focal_method.identifier: invoke
focal_method.invocations: isNotEmpty getMethodParameter getUrl getMethodName getCache getUrl toArgumentString getArguments get invoke hasException getValue put getValue invoke
focal_method.modifiers: @Override public
focal_method.parameters: (Invoker<?> invoker, Invocation invocation)
focal_method.return: Result
focal_method.signature: Result invoke(Invoker<?> invoker, Invocation invocation)