@Test public void shouldCallFailureWhenAuthenticationFails() throws Exception { authenticationGateway.signIn("spongebob", "squidward", callbacks); apiGateway.simulateResponse(401, "Access Denied"); assertThat(callbacks.failureWasCalled, equalTo(true)); assertThat(callbacks.successWasCalled, equalTo(false)); assertThat(callbacks.completeWasCalled, equalTo(true)); }
public void signIn(String username, String password, Callbacks responseCallbacks) { apiGateway.makeRequest( new TrackerAuthenticationRequest(username, password), new AuthenticationApiResponseCallbacks(responseCallbacks, sharedPreferences)); }
AuthenticationGateway { public void signIn(String username, String password, Callbacks responseCallbacks) { apiGateway.makeRequest( new TrackerAuthenticationRequest(username, password), new AuthenticationApiResponseCallbacks(responseCallbacks, sharedPreferences)); } }
AuthenticationGateway { public void signIn(String username, String password, Callbacks responseCallbacks) { apiGateway.makeRequest( new TrackerAuthenticationRequest(username, password), new AuthenticationApiResponseCallbacks(responseCallbacks, sharedPreferences)); } AuthenticationGateway(ApiGateway apiGateway, Context context); }
AuthenticationGateway { public void signIn(String username, String password, Callbacks responseCallbacks) { apiGateway.makeRequest( new TrackerAuthenticationRequest(username, password), new AuthenticationApiResponseCallbacks(responseCallbacks, sharedPreferences)); } AuthenticationGateway(ApiGateway apiGateway, Context context); void signIn(String username, String password, Callbacks responseCallbacks); boolean isAuthenticated(); void signOut(); String getToken(); }
AuthenticationGateway { public void signIn(String username, String password, Callbacks responseCallbacks) { apiGateway.makeRequest( new TrackerAuthenticationRequest(username, password), new AuthenticationApiResponseCallbacks(responseCallbacks, sharedPreferences)); } AuthenticationGateway(ApiGateway apiGateway, Context context); void signIn(String username, String password, Callbacks responseCallbacks); boolean isAuthenticated(); void signOut(); String getToken(); public ApiGateway apiGateway; }