use of com.khmelenko.lab.varis.task.TaskException 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.TaskException 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.TaskException 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.TaskException 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.TaskException in project Varis-Android by dkhmelenko.
the class TestBuildDetailsPresenter method testStartLoadingLogFailed.
@Test
public void testStartLoadingLogFailed() {
final long jobId = 1L;
final int errorCode = 401;
final String errorMsg = "error";
TaskError error = spy(new TaskError(errorCode, errorMsg));
Response response = new Response("url", 200, "", Collections.<Header>emptyList(), null);
error.setResponse(response);
TaskException exception = spy(new TaskException(error));
when(mRawClient.getApiService().getLog(String.valueOf(jobId))).thenThrow(exception);
mBuildsDetailsPresenter.startLoadingLog(jobId);
int loadLogInvocations = BuildsDetailsPresenter.LOAD_LOG_MAX_ATTEMPT + 1;
verify(mTaskManager, times(loadLogInvocations)).getLogUrl(jobId);
verify(mBuildDetailsView).showLoadingError(error.getMessage());
verify(mBuildDetailsView).showLogError();
}
Aggregations