### Question:
AuthenticatorManager { void registerForRemoteNotifications(String newDeviceToken) throws AuthenticatorException { if(this.deviceToken == null) { this.deviceToken = newDeviceToken; this.pushFactory = new PushFactory(context, storageClient, newDeviceToken); this.notificationFactory = new NotificationFactory(storageClient); PushResponder.getInstance(storageClient); } else { if(this.deviceToken.equals(newDeviceToken)) { Logger.warn(TAG, "The SDK was already initialized with this device token: %s", newDeviceToken); throw new AuthenticatorException("The SDK was already initialized with the FCM device token."); } else { Logger.warn(TAG, "The SDK was initialized with a different deviceToken: %s, however a new " + "device token (%s) was received.", this.deviceToken, newDeviceToken); throw new AuthenticatorException("The SDK was initialized with a different deviceToken."); } } } AuthenticatorManager(Context context, StorageClient storageClient, String deviceToken);   }### Answer:
@Test public void testShouldFailToRegisterDeviceTokenForRemoteNotificationsAlreadyRegisteredSameToken() { authenticatorManager = new AuthenticatorManager(context, storageClient, "s-o-m-e-t-o-k-e-n"); try { authenticatorManager.registerForRemoteNotifications("s-o-m-e-t-o-k-e-n"); fail("Should throw AuthenticatorException"); } catch (Exception e) { assertTrue(e instanceof AuthenticatorException); assertTrue(e.getLocalizedMessage().contains("The SDK was already initialized with the FCM device token")); } }
@Test public void testShouldFailToRegisterDeviceTokenForRemoteNotificationsAlreadyRegisteredDifferentToken() { authenticatorManager = new AuthenticatorManager(context, storageClient, "s-o-m-e-t-o-k-e-n"); try { authenticatorManager.registerForRemoteNotifications("a-n-o-t-h-e-r-t-o-k-e-n"); fail("Should throw AuthenticatorException"); } catch (Exception e) { assertTrue(e instanceof AuthenticatorException); assertTrue(e.getLocalizedMessage().contains("The SDK was initialized with a different deviceToken")); } }