### Question:
AuthorizationFlowHandler { public static TokenProvider fromRepository(OAuthConfig config, TokenRepository tokenRepository) { return OAuthTokenProvider.builder() .config(config) .tokenRepository(tokenRepository).build(); } AuthorizationFlowHandler(OAuthConfig config, TokenRepository tokenRepository, WebFormHandler webFormHandler, AuthorizationApiHandler authorizationApiHandler); static AuthorizationFlowHandler setup(OAuthConfig config, TokenRepository tokenRepository); static AuthorizationFlowHandler setup(OAuthConfig config); static TokenProvider fromRepository(OAuthConfig config, TokenRepository tokenRepository); TokenProvider authorize(String username, String password);  }### Answer:
@Test public void testFromRepository_whenTokenRepositoryIsNotEmpty_shouldCreateTokenProviderWithGivenRepositoryData() { TokenRepository repository = Mockito.mock(TokenRepository.class); TokenInformation tokenInformation = Mockito.mock(TokenInformation.class); Mockito.when(repository.isEmpty()).thenReturn(false); Mockito.when(repository.get()).thenReturn(tokenInformation); Mockito.when(tokenInformation.isValid()).thenReturn(true); Mockito.when(tokenInformation.getAccessToken()).thenReturn("access-token"); Mockito.when(tokenInformation.getTimestamp()).thenReturn(new Date().getTime() + 10000); TokenProvider tokenProvider = AuthorizationFlowHandler.fromRepository(defaultConfig, repository); assertThat(tokenProvider.getAccessToken()).isEqualToIgnoringCase("access-token"); }