ApplicationContext context = mock(ApplicationContext.class);
when(context.getBeanNamesForType(Object.class)).thenReturn(new String[]{"service1"});
Class withGroupServiceClass = WithGroupService.class;
when(context.getType("service1")).thenReturn(withGroupServiceClass);
RopContext ropContext = new DefaultRopContext(context);
//method1:都在ServiceMethodGroup中定义,在ServiceMethod中直接采用
ServiceMethodHandler handler = ropContext.getServiceMethodHandler("service.method1", "1.0");
ServiceMethodDefinition definition = handler.getServiceMethodDefinition();
assertNotNull(definition);
assertEquals(definition.getMethod(), "service.method1");
assertEquals(definition.getMethodTitle(), "测试方法1");
assertEquals(definition.getMethodGroup(), "GROUP1");
assertEquals(definition.getMethodGroupTitle(), "分组1");
assertEquals(definition.getTags(), new String[]{"TAG1", "TAG2"});
assertEquals(definition.isIgnoreSign(), true);
assertEquals(definition.isNeedInSession(), false);
assertEquals(definition.getTimeout(), 100);
assertEquals(definition.getVersion(), "1.0");
//method2:在ServiceMethodGroup中定义,在ServiceMethod显式覆盖之
ServiceMethodHandler handler2 = ropContext.getServiceMethodHandler("service.method2", "2.0");
ServiceMethodDefinition definition2 = handler2.getServiceMethodDefinition();
assertNotNull(definition2);
assertEquals(definition2.getMethod(), "service.method2");
assertEquals(definition2.getMethodTitle(), "测试方法2");
assertEquals(definition2.getMethodGroup(), "GROUP2");