### Question:
ServiceFacade { public Object syncCallService(String flowName, Object message) throws TimeoutException { FlowRouter flowRouter = buildFlowRouter(flowName, -1); return flowRouter.syncCallService(message); } ServiceFacade(FlowerFactory flowerFactory); void asyncCallService(String flowName, Object message, AsyncContext asyncContext); void asyncCallService(String flowName, Object message); Object syncCallService(String flowName, Object message); FlowRouter buildFlowRouter(String flowName, int actorNumber); ServiceRouter buildServiceRouter(ServiceConfig serviceConfig, int actorNumber); void asyncCall(String serviceName, Object message); Object syncCall(String serviceName, Object message);  }### Answer:
@Test public void testSyncCallService() throws Exception { String flowName = generateFlowName(); ServiceFlow serviceFlow = serviceFactory.getOrCreateServiceFlow(flowName); serviceFlow.buildFlow(UserServiceA.class, UserServiceB.class); serviceFlow.buildFlow(UserServiceB.class, Arrays.asList(UserServiceC1.class, UserServiceC2.class)); serviceFlow.buildFlow(Arrays.asList(UserServiceC1.class, UserServiceC2.class), UserServiceD.class); serviceFlow.build(); User user = new User(); user.setName("响应式编程"); user.setAge(2); Object o = serviceFacade.syncCallService(flowName, user); System.out.println(o); }
@Test public void testSyncCallAggregateService() throws Exception { String flowName = generateFlowName(); ServiceFlow serviceFlow = serviceFactory.getOrCreateServiceFlow(flowName); serviceFlow.buildFlow(UserServiceA.class, UserServiceB.class); serviceFlow.buildFlow(UserServiceB.class, Arrays.asList(UserServiceC1.class, UserServiceC2.class)); serviceFlow.buildFlow(Arrays.asList(UserServiceC1.class, UserServiceC2.class), UserServiceD.class); serviceFlow.build(); User user = new User(); user.setName("响应式编程"); user.setAge(2); List<User> ret = (List<User>) serviceFacade.syncCallService(flowName, user); assertNotNull(ret); assertEquals(ret.size(), 2); assertEquals(5, ret.get(0).getAge()); assertEquals(5, ret.get(1).getAge()); }
@Test(expected = FlowException.class) public void testSyncException() throws TimeoutException { String flowName = generateFlowName(); ServiceFlow serviceFlow = serviceFactory.getOrCreateServiceFlow(flowName); serviceFlow.buildFlow(UserServiceA.class, UserServiceB.class); serviceFlow.buildFlow(UserServiceB.class, UserServiceC1.class); serviceFlow.buildFlow(UserServiceC1.class, ExceptionService.class); serviceFlow.buildFlow(ExceptionService.class, UserServiceC2.class); User user = new User(); user.setName("响应式编程"); user.setAge(2); Object o = serviceFacade.syncCallService(flowName, user); System.out.println(o); }