### Question:
RememberMeCheckService { public boolean equalWithPersistentToken(String presentedSeries, String presentedToken) { PersistentRememberMeToken token = persistentTokenRepository.getTokenForSeries(presentedSeries); if (token != null) { String persistentToken = token.getTokenValue(); if (!ObjectUtils.equals(presentedToken, persistentToken)) { String logErrorMessage = composeErrorMessageForNotEqualTokens( token.getUsername(), presentedToken, presentedSeries, persistentToken); LOGGER.error(logErrorMessage); return false; } } return true; } RememberMeCheckService(PersistentTokenRepository persistentTokenRepository); boolean equalWithPersistentToken(String presentedSeries, String presentedToken);  }### Answer:
@Test public void equalForNotExistPersistentTokenShouldReturnTrue() { when(persistentTokenRepository.getTokenForSeries(PRESENTED_SERIES)) .thenReturn(null); boolean isEqual = rememberMeCheckService.equalWithPersistentToken(PRESENTED_SERIES, PRESENTED_TOKEN); Assert.assertTrue(isEqual, "We didn't find anything in database for given series, so this method must return true"); }
@Test public void equalWithTheDifferentPersistentTokenShouldReturnFalse() { PersistentRememberMeToken notEqualPersistentRememberMeToken = new PersistentRememberMeToken("username", PRESENTED_SERIES, BROKED_TOKEN, null); when(persistentTokenRepository.getTokenForSeries(PRESENTED_SERIES)) .thenReturn(notEqualPersistentRememberMeToken); boolean isEqual = rememberMeCheckService.equalWithPersistentToken(PRESENTED_SERIES, PRESENTED_TOKEN); Assert.assertFalse(isEqual, "We found persistent token and it isn't equal to presented, so this method must return false"); }
@Test public void equalWithTheSamePersistenTokenShouldReturnTrue() { PersistentRememberMeToken notEqualPersistentRememberMeToken = new PersistentRememberMeToken("username", PRESENTED_SERIES, PRESENTED_TOKEN, null); when(persistentTokenRepository.getTokenForSeries(PRESENTED_SERIES)) .thenReturn(notEqualPersistentRememberMeToken); boolean isEqual = rememberMeCheckService.equalWithPersistentToken(PRESENTED_SERIES, PRESENTED_TOKEN); Assert.assertTrue(isEqual, "We found persistent token and it is equal to presented, so this method must return true"); }