use of com.khmelenko.lab.varis.task.TaskError in project Varis-Android by dkhmelenko.
the class TestAuthPresenter method testLoginAuthFailed.
@Test
public void testLoginAuthFailed() {
final String login = "login";
final String password = "password";
String auth = EncryptionUtils.generateBasicAuthorization(login, password);
final String gitHubToken = "gitHubToken";
Authorization authorization = new Authorization();
authorization.setToken(gitHubToken);
authorization.setId(1L);
when(mGitHubRestClient.getApiService().createNewAuthorization(eq(auth), any(AuthorizationRequest.class))).thenReturn(authorization);
AccessTokenRequest request = new AccessTokenRequest();
request.setGithubToken(gitHubToken);
TaskError taskError = new TaskError(500, "error");
TaskException exception = new TaskException(taskError);
when(mTravisRestClient.getApiService().auth(request)).thenThrow(exception);
mAuthPresenter.login(login, password);
verify(mTaskManager).createNewAuthorization(eq(auth), any(AuthorizationRequest.class));
verify(mTaskManager).startAuth(gitHubToken);
verify(mAuthView).hideProgress();
verify(mAuthView).showErrorMessage(taskError.getMessage());
}
use of com.khmelenko.lab.varis.task.TaskError in project Varis-Android by dkhmelenko.
the class TestAuthPresenter method testLoginGitHubAuthFailed.
@Test
public void testLoginGitHubAuthFailed() {
final String login = "login";
final String password = "password";
String auth = EncryptionUtils.generateBasicAuthorization(login, password);
TaskError taskError = new TaskError(500, "error");
TaskException exception = new TaskException(taskError);
when(mGitHubRestClient.getApiService().createNewAuthorization(eq(auth), any(AuthorizationRequest.class))).thenThrow(exception);
mAuthPresenter.login(login, password);
verify(mTaskManager).createNewAuthorization(eq(auth), any(AuthorizationRequest.class));
verify(mAuthView).hideProgress();
verify(mAuthView).showErrorMessage(taskError.getMessage());
}
use of com.khmelenko.lab.varis.task.TaskError in project Varis-Android by dkhmelenko.
the class TestRepoDetailsPresenter method testLoadBranchesFailed.
@Test
public void testLoadBranchesFailed() {
final String slug = "test";
final int errorCode = 401;
final String errorMsg = "error";
TaskError error = spy(new TaskError(errorCode, errorMsg));
TaskException exception = spy(new TaskException(error));
when(mTravisRestClient.getApiService().getBranches(slug)).thenThrow(exception);
mRepoDetailsPresenter.setRepoSlug(slug);
mRepoDetailsPresenter.loadBranches();
verify(mTaskManager).getBranches(slug);
verify(mRepoDetailsView).showBranchesLoadingError(error.getMessage());
}
use of com.khmelenko.lab.varis.task.TaskError in project Varis-Android by dkhmelenko.
the class TestSearchResultsPresenter method testStartRepoSearchFailed.
@Test
public void testStartRepoSearchFailed() {
final String searchQuery = "test";
final int errorCode = 401;
final String errorMsg = "error";
TaskError error = spy(new TaskError(errorCode, errorMsg));
TaskException exception = spy(new TaskException(error));
when(mTravisRestClient.getApiService().getRepos(searchQuery)).thenThrow(exception);
mSearchResultsPresenter.startRepoSearch(searchQuery);
verify(mTaskManager).findRepos(searchQuery);
verify(mSearchResultsView).hideProgress();
verify(mSearchResultsView).showLoadingError(eq(error.getMessage()));
}
use of com.khmelenko.lab.varis.task.TaskError in project Varis-Android by dkhmelenko.
the class TestBuildDetailsPresenter method testStartLoadingDataIntentUrlFailed.
@Test
public void testStartLoadingDataIntentUrlFailed() throws Exception {
final long buildId = 0L;
final String slug = "dkhmelenko/Varis-Android";
final String intentUrl = "https://travis-ci.org/dkhmelenko/Varis-Android/builds";
final String expectedUrl = "https://sample.org";
Request request = new Request.Builder().url(expectedUrl).build();
com.squareup.okhttp.Response response = new com.squareup.okhttp.Response.Builder().request(request).protocol(Protocol.HTTP_1_1).code(200).build();
final int errorCode = TaskError.NETWORK_ERROR;
final String errorMsg = "";
TaskError error = spy(new TaskError(errorCode, errorMsg));
when(mRawClient.singleRequest(intentUrl)).thenReturn(response);
mBuildsDetailsPresenter.startLoadingData(intentUrl, slug, buildId);
verify(mTaskManager).intentUrl(intentUrl);
verify(mBuildDetailsView).hideProgress();
verify(mBuildDetailsView).updateBuildDetails(null);
verify(mBuildDetailsView).showLoadingError(error.getMessage());
}
Aggregations