### Question:
FusedLocationServiceCallbackManager { void onLocationChanged(Context context, Location location, ClientManager clientManager, IFusedLocationProviderService service) { clientManager.reportLocationChanged(location); LocationAvailability availability = null; try { availability = service.getLocationAvailability(); } catch (RemoteException e) { Log.e(TAG, "Error occurred trying to get LocationAvailability", e); } ArrayList<Location> locations = new ArrayList<>(); locations.add(location); final LocationResult result = LocationResult.create(locations); clientManager.sendPendingIntent(context, location, availability, result); clientManager.reportLocationResult(location, result); }    }### Answer:
@Test public void onLocationChanged_shouldReportLocationChanged() { LostClientManager clientManager = mock(LostClientManager.class); Location location = mock(Location.class); callbackManager.onLocationChanged(mock(Context.class), location, clientManager, mock(IFusedLocationProviderService.class)); verify(clientManager).reportLocationChanged(location); }
@Test public void onLocationChanged_shouldSendPendingIntent() { LostClientManager clientManager = mock(LostClientManager.class); IFusedLocationProviderService service = mock(IFusedLocationProviderService.class); LocationAvailability locationAvailability = mock(LocationAvailability.class); try { when(service.getLocationAvailability()).thenReturn(locationAvailability); } catch (RemoteException e) { e.printStackTrace(); } Context context = mock(Context.class); Location location = mock(Location.class); callbackManager.onLocationChanged(context, location, clientManager, service); verify(clientManager).sendPendingIntent(eq(context), eq(location), eq(locationAvailability), any(LocationResult.class)); }
@Test public void onLocationChanged_shouldReportLocationResult() { LostClientManager clientManager = mock(LostClientManager.class); IFusedLocationProviderService service = mock(IFusedLocationProviderService.class); Location location = mock(Location.class); callbackManager.onLocationChanged(mock(Context.class), location, clientManager, service); verify(clientManager).reportLocationResult(eq(location), any(LocationResult.class)); }