### Question:
GeofencingDwellManager { public void handleIntent(Intent intent) { int transition = intentHelper.transitionForIntent(intent); int intentId = intentHelper.extractIntentId(intent); ParcelableGeofence geofence = (ParcelableGeofence) geofencingApi.geofenceForIntentId(intentId); switch (transition) { case Geofence.GEOFENCE_TRANSITION_ENTER: geofencingApi.geofenceEntered(geofence, intentId); break; case Geofence.GEOFENCE_TRANSITION_EXIT: geofencingApi.geofenceExited(geofence); default: break; } } GeofencingDwellManager(GeofencingApi geofencingApi); void handleIntent(Intent intent);  }### Answer:
@Test public void handleIntent_shouldRegisterGeofenceEntered() { Intent intent = mock(Intent.class); when(intent.getExtras()).thenReturn(mock(Bundle.class)); when(intent.getExtras().containsKey(EXTRA_ENTERING)).thenReturn(true); when(intent.getExtras().getBoolean(EXTRA_ENTERING)).thenReturn(true); HashSet<String> categories = new HashSet<>(); categories.add("123"); when(intent.getCategories()).thenReturn(categories); dwellManager.handleIntent(intent); verify(geofencingApi).geofenceEntered(any(Geofence.class), anyInt()); }
@Test public void handleIntent_shouldRegisterGeofenceExited() { Intent intent = mock(Intent.class); when(intent.getExtras()).thenReturn(mock(Bundle.class)); when(intent.getExtras().containsKey(EXTRA_ENTERING)).thenReturn(true); when(intent.getExtras().getBoolean(EXTRA_ENTERING)).thenReturn(false); HashSet<String> categories = new HashSet<>(); categories.add("123"); when(intent.getCategories()).thenReturn(categories); dwellManager.handleIntent(intent); verify(geofencingApi).geofenceExited(any(Geofence.class)); }