### Question:
MapboxFusedLocationEngineImpl extends AndroidLocationEngineImpl { @Override public void getLastLocation(@NonNull LocationEngineCallback<LocationEngineResult> callback) throws SecurityException { Location bestLastLocation = getBestLastLocation(); if (bestLastLocation != null) { callback.onSuccess(LocationEngineResult.create(bestLastLocation)); } else { callback.onFailure(new Exception("Last location unavailable")); } } MapboxFusedLocationEngineImpl(@NonNull Context context); @NonNull @Override LocationListener createListener(LocationEngineCallback<LocationEngineResult> callback); @Override void getLastLocation(@NonNull LocationEngineCallback<LocationEngineResult> callback); @SuppressLint("MissingPermission") @Override void requestLocationUpdates(@NonNull LocationEngineRequest request,
                                     @NonNull LocationListener listener,
                                     @Nullable Looper looper); @SuppressLint("MissingPermission") @Override void requestLocationUpdates(@NonNull LocationEngineRequest request,
                                     @NonNull PendingIntent pendingIntent);  }### Answer:
@Test public void getLastLocation() throws InterruptedException { final CountDownLatch latch = new CountDownLatch(1); final AtomicReference<LocationEngineResult> resultRef = new AtomicReference<>(); LocationEngineCallback<LocationEngineResult> callback = getCallback(resultRef, latch); final Location location = getMockLocation(LATITUDE, LONGITUDE); final LocationEngineResult expectedResult = getMockEngineResult(location); when(locationManagerMock.getAllProviders()).thenReturn(Arrays.asList("gps", "network")); when(locationManagerMock.getLastKnownLocation(anyString())).thenReturn(location); engine.getLastLocation(callback); assertTrue(latch.await(5, SECONDS)); LocationEngineResult result = resultRef.get(); assertThat(result.getLastLocation()).isEqualTo(expectedResult.getLastLocation()); }
@Test(expected = NullPointerException.class) public void getLastLocationNullCallback() { engine.getLastLocation(null); }