@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(); } } }
@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; } }
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; } } }
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); }
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); }
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);  }