Search in sources :

Example 11 with SimpleFederatedService

use of org.onebusaway.federations.SimpleFederatedService in project onebusaway-application-modules by camsys.

the class FederatedByBoundsMethodInvocationHandlerImplTest method testSimple.

@Test
public void testSimple() throws Exception {
    SimpleFederatedService mockService = Mockito.mock(SimpleFederatedService.class);
    FederatedServiceCollection mockCollection = Mockito.mock(FederatedServiceCollectionImpl.class);
    Mockito.when(mockCollection.getServiceForBounds(0.0, 1.0, 2.0, 3.0)).thenReturn(mockService);
    Method method = SimpleFederatedService.class.getDeclaredMethod("getValueForBounds", Double.TYPE, Double.TYPE, Double.TYPE, Double.TYPE);
    Object[] args = { 0.0, 1.0, 2.0, 3.0 };
    FederatedServiceMethodInvocationHandler handler = new FederatedByBoundsMethodInvocationHandlerImpl(0, 1, 2, 3);
    handler.invoke(mockCollection, method, args);
    Mockito.verify(mockService).getValueForBounds(0.0, 1.0, 2.0, 3.0);
}
Also used : FederatedServiceCollection(org.onebusaway.federations.FederatedServiceCollection) Method(java.lang.reflect.Method) SimpleFederatedService(org.onebusaway.federations.SimpleFederatedService) Test(org.junit.Test)

Example 12 with SimpleFederatedService

use of org.onebusaway.federations.SimpleFederatedService in project onebusaway-application-modules by camsys.

the class FederatedByCoordinateBoundsMethodInvocationHandlerImplTest method test02.

@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);
}
Also used : CoordinateBoundsTestBean(org.onebusaway.federations.CoordinateBoundsTestBean) FederatedServiceCollection(org.onebusaway.federations.FederatedServiceCollection) Method(java.lang.reflect.Method) SimpleFederatedService(org.onebusaway.federations.SimpleFederatedService) CoordinateBounds(org.onebusaway.geospatial.model.CoordinateBounds) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)12 SimpleFederatedService (org.onebusaway.federations.SimpleFederatedService)12 Method (java.lang.reflect.Method)11 FederatedServiceCollection (org.onebusaway.federations.FederatedServiceCollection)11 HashSet (java.util.HashSet)4 FederatedService (org.onebusaway.federations.FederatedService)3 CoordinateBounds (org.onebusaway.geospatial.model.CoordinateBounds)2 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 CoordinateBoundsTestBean (org.onebusaway.federations.CoordinateBoundsTestBean)1 EntityIdTestBean (org.onebusaway.federations.EntityIdTestBean)1