FederatedByCoordinateBoundsMethodInvocationHandlerImpl implements
    FederatedServiceMethodInvocationHandler { public Object invoke(FederatedServiceCollection collection, Method method, Object[] args) throws ServiceAreaServiceException, IllegalArgumentException, IllegalAccessException, InvocationTargetException { Object value = args[_argumentIndex]; if (_expression != null) value = _expression.invoke(value); CoordinateBounds bounds = (CoordinateBounds) value; FederatedService service = collection.getServiceForBounds(bounds); return method.invoke(service, args); } FederatedByCoordinateBoundsMethodInvocationHandlerImpl(Method method,
      int argumentIndex, String expression); int getArgumentIndex(); PropertyPathExpression getExpression(); Object invoke(FederatedServiceCollection collection, Method method,
      Object[] args);  }
@Test public void test01() throws Exception { CoordinateBounds bounds = new CoordinateBounds(0,1,2,3); SimpleFederatedService mockService = Mockito.mock(SimpleFederatedService.class); FederatedServiceCollection mockCollection = Mockito.mock(FederatedServiceCollectionImpl.class); Mockito.when(mockCollection.getServiceForBounds(bounds)).thenReturn(mockService); Method method = SimpleFederatedService.class.getDeclaredMethod("getValueForCoordinateBounds", CoordinateBounds.class); Object[] args = {bounds}; FederatedServiceMethodInvocationHandler handler = new FederatedByCoordinateBoundsMethodInvocationHandlerImpl(method,0,""); handler.invoke(mockCollection, method, args); Mockito.verify(mockService).getValueForCoordinateBounds(bounds); }
@Test public void test02() throws Exception { CoordinateBounds bounds = new CoordinateBounds(0,1,2,3); CoordinateBoundsTestBean bean = new CoordinateBoundsTestBean(); bean.setBounds(bounds); SimpleFederatedService mockService = Mockito.mock(SimpleFederatedService.class); FederatedServiceCollection mockCollection = Mockito.mock(FederatedServiceCollectionImpl.class); Mockito.when(mockCollection.getServiceForBounds(bounds)).thenReturn(mockService); Method method = SimpleFederatedService.class.getDeclaredMethod("getValueForCoordinateBoundsTestBean", CoordinateBoundsTestBean.class); Object[] args = {bean}; FederatedServiceMethodInvocationHandler handler = new FederatedByCoordinateBoundsMethodInvocationHandlerImpl(method,0,"bounds"); handler.invoke(mockCollection, method, args); Mockito.verify(mockService).getValueForCoordinateBoundsTestBean(bean); }