Search in sources :

Example 6 with TaskError

use of com.khmelenko.lab.varis.task.TaskError 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();
}
Also used : Response(retrofit.client.Response) TaskException(com.khmelenko.lab.varis.task.TaskException) TaskError(com.khmelenko.lab.varis.task.TaskError) Test(org.junit.Test)

Example 7 with TaskError

use of com.khmelenko.lab.varis.task.TaskError in project Varis-Android by dkhmelenko.

the class TestBuildDetailsPresenter method testStartLoadingDataFailed.

@Test
public void testStartLoadingDataFailed() {
    final long buildId = 1L;
    final String slug = "test";
    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(mTravisRestClient.getApiService().getBuild(slug, buildId)).thenThrow(exception);
    mBuildsDetailsPresenter.startLoadingData(null, slug, buildId);
    verify(mTaskManager).getBuildDetails(slug, buildId);
    verify(mBuildDetailsView).showProgress();
    verify(mBuildDetailsView).hideProgress();
    verify(mBuildDetailsView).updateBuildDetails(null);
    verify(mBuildDetailsView).showLoadingError(error.getMessage());
}
Also used : Response(retrofit.client.Response) TaskException(com.khmelenko.lab.varis.task.TaskException) TaskError(com.khmelenko.lab.varis.task.TaskError) Test(org.junit.Test)

Example 8 with TaskError

use of com.khmelenko.lab.varis.task.TaskError in project Varis-Android by dkhmelenko.

the class TestBuildDetailsPresenter method testCancelBuildFailed.

@Test
public void testCancelBuildFailed() {
    final int errorCode = 401;
    final String errorMsg = "error";
    TaskError error = spy(new TaskError(errorCode, errorMsg));
    TaskException exception = spy(new TaskException(error));
    when(mTravisRestClient.getApiService().cancelBuild(any(Long.class), any(TypedOutput.class))).thenThrow(exception);
    mBuildsDetailsPresenter.cancelBuild();
    verify(mTaskManager).getBuildDetails(any(String.class), any(Long.class));
    verify(mBuildDetailsView, times(2)).showLoadingError(error.getMessage());
}
Also used : TaskException(com.khmelenko.lab.varis.task.TaskException) TypedOutput(retrofit.mime.TypedOutput) TaskError(com.khmelenko.lab.varis.task.TaskError) Test(org.junit.Test)

Example 9 with TaskError

use of com.khmelenko.lab.varis.task.TaskError in project Varis-Android by dkhmelenko.

the class TestBuildDetailsPresenter method testRestartBuildFailed.

@Test
public void testRestartBuildFailed() {
    final int errorCode = 401;
    final String errorMsg = "error";
    TaskError error = spy(new TaskError(errorCode, errorMsg));
    TaskException exception = spy(new TaskException(error));
    when(mTravisRestClient.getApiService().restartBuild(any(Long.class), any(TypedOutput.class))).thenThrow(exception);
    mBuildsDetailsPresenter.restartBuild();
    verify(mTaskManager).getBuildDetails(any(String.class), any(Long.class));
    verify(mBuildDetailsView, times(2)).showLoadingError(error.getMessage());
}
Also used : TaskException(com.khmelenko.lab.varis.task.TaskException) TypedOutput(retrofit.mime.TypedOutput) TaskError(com.khmelenko.lab.varis.task.TaskError) Test(org.junit.Test)

Example 10 with TaskError

use of com.khmelenko.lab.varis.task.TaskError in project Varis-Android by dkhmelenko.

the class TestRepoDetailsPresenter method testLoadRequestsFailed.

@Test
public void testLoadRequestsFailed() {
    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().getRequests(slug)).thenThrow(exception);
    mRepoDetailsPresenter.setRepoSlug(slug);
    mRepoDetailsPresenter.loadRequests();
    verify(mTaskManager).getRequests(slug);
    verify(mRepoDetailsView).showPullRequestsLoadingError(error.getMessage());
}
Also used : TaskException(com.khmelenko.lab.varis.task.TaskException) TaskError(com.khmelenko.lab.varis.task.TaskError) Test(org.junit.Test)

Aggregations

TaskError (com.khmelenko.lab.varis.task.TaskError)12 Test (org.junit.Test)12 TaskException (com.khmelenko.lab.varis.task.TaskException)11 AuthorizationRequest (com.khmelenko.lab.varis.network.request.AuthorizationRequest)3 Response (retrofit.client.Response)3 AccessTokenRequest (com.khmelenko.lab.varis.network.request.AccessTokenRequest)2 Authorization (com.khmelenko.lab.varis.network.response.Authorization)2 TypedOutput (retrofit.mime.TypedOutput)2 AccessToken (com.khmelenko.lab.varis.network.response.AccessToken)1 Request (com.squareup.okhttp.Request)1 ArrayList (java.util.ArrayList)1 Header (retrofit.client.Header)1