### Question:
DefaultAccountConnectionsService implements AccountConnectionsService, NetworkStateListener { @Override public void onNetworkEvent(@Nonnull final NetworkData networkData) { switch (networkData.getState()) { case CONNECTED: notificationService.remove(NO_INTERNET_NOTIFICATION); notificationService.remove(newAccountConnectionErrorNotification()); accountConnections.tryStartAll(true); break; case UNKNOWN: case NOT_CONNECTED: if (accountConnections.onNoInternetConnection()) { notificationService.add(NO_INTERNET_NOTIFICATION); } break; } } @Inject  DefaultAccountConnectionsService(@Nonnull Application context); @Override void init(); @Override void tryStopAll(); @Override void tryStartAll(); @Override boolean isInternetConnectionExists(); @Override void onNetworkEvent(@Nonnull final NetworkData networkData);  }### Answer:
@Test public void testShouldNotifyConnectionsIfNoInternet() throws Exception { int count = 0; for (NetworkState networkState : NetworkState.values()) { when(networkData.getState()).thenReturn(networkState); service.onNetworkEvent(networkData); if (networkState != CONNECTED) { count++; verify(accountConnections, times(count)).onNoInternetConnection(); } } }
@Test public void testShouldNotifyUserIfNoInternetAndExistsConnectionsRequiringInternet() throws Exception { when(networkData.getState()).thenReturn(NOT_CONNECTED); when(accountConnections.onNoInternetConnection()).thenReturn(true); service.onNetworkEvent(networkData); verify(notificationService, times(1)).add(Notifications.NO_INTERNET_NOTIFICATION); }
@Test public void testShouldRemoveUserNotificationIfInternetExists() throws Exception { when(networkData.getState()).thenReturn(CONNECTED); service.onNetworkEvent(networkData); verify(notificationService, times(1)).remove(Notifications.NO_INTERNET_NOTIFICATION); verify(notificationService, times(1)).remove(Notifications.newAccountConnectionErrorNotification()); }