Search in sources :

Example 6 with TaskException

use of com.khmelenko.lab.varis.task.TaskException 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 7 with TaskException

use of com.khmelenko.lab.varis.task.TaskException 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 8 with TaskException

use of com.khmelenko.lab.varis.task.TaskException 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 9 with TaskException

use of com.khmelenko.lab.varis.task.TaskException 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)

Example 10 with TaskException

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

the class TestRepoDetailsPresenter method testLoadBuildsHistoryFailed.

@Test
public void testLoadBuildsHistoryFailed() {
    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().getBuilds(slug)).thenThrow(exception);
    mRepoDetailsPresenter.setRepoSlug(slug);
    mRepoDetailsPresenter.loadBuildsHistory();
    verify(mTaskManager).getBuildHistory(slug);
    verify(mRepoDetailsView).showBuildHistoryLoadingError(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)11 TaskException (com.khmelenko.lab.varis.task.TaskException)11 Test (org.junit.Test)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 ArrayList (java.util.ArrayList)1 Header (retrofit.client.Header)1