Skip to content
Snippets Groups Projects
Commit 13baeae0 authored by Jawnnypoo's avatar Jawnnypoo
Browse files

Better logging in tests

parent 0da57c37
No related branches found
No related tags found
No related merge requests found
Pipeline #
Loading
Loading
@@ -67,7 +67,7 @@ public class ApiTests {
Response<List<Project>> projectsResponse = gitLab
.getAllProjects()
.execute();
assertTrue(projectsResponse.isSuccessful());
TestUtil.assertRetrofitResponseSuccess(projectsResponse);
assertNotNull(projectsResponse.body());
}
 
Loading
Loading
@@ -76,7 +76,7 @@ public class ApiTests {
Response<List<Group>> groupResponse = gitLab
.getGroups()
.execute();
assertTrue(groupResponse.isSuccessful());
TestUtil.assertRetrofitResponseSuccess(groupResponse);
assertNotNull(groupResponse.body());
}
 
Loading
Loading
@@ -86,7 +86,7 @@ public class ApiTests {
Response<List<Issue>> issuesResponse = gitLab
.getIssues(sFakeProject.getId(), defaultState)
.execute();
assertTrue(issuesResponse.isSuccessful());
TestUtil.assertRetrofitResponseSuccess(issuesResponse);
assertNotNull(issuesResponse.body());
}
 
Loading
Loading
@@ -97,7 +97,7 @@ public class ApiTests {
Response<List<RepositoryTreeObject>> treeResponse = gitLab
.getTree(sFakeProject.getId(), defaultBranch, currentPath)
.execute();
assertTrue(treeResponse.isSuccessful());
TestUtil.assertRetrofitResponseSuccess(treeResponse);
assertNotNull(treeResponse.body());
}
 
Loading
Loading
@@ -107,7 +107,7 @@ public class ApiTests {
Response<List<RepositoryCommit>> commitsResponse = gitLab
.getCommits(sFakeProject.getId(), defaultBranch, 0)
.execute();
assertTrue(commitsResponse.isSuccessful());
TestUtil.assertRetrofitResponseSuccess(commitsResponse);
assertNotNull(commitsResponse.body());
}
 
Loading
Loading
@@ -117,7 +117,7 @@ public class ApiTests {
Response<List<MergeRequest>> mergeRequestResponse = gitLab
.getMergeRequests(sFakeProject.getId(), defaultState)
.execute();
assertTrue(mergeRequestResponse.isSuccessful());
TestUtil.assertRetrofitResponseSuccess(mergeRequestResponse);
assertNotNull(mergeRequestResponse.body());
}
 
Loading
Loading
@@ -126,7 +126,7 @@ public class ApiTests {
Response<UserFull> userFullResponse = gitLab
.getThisUser()
.execute();
assertTrue(userFullResponse.isSuccessful());
TestUtil.assertRetrofitResponseSuccess(userFullResponse);
assertNotNull(userFullResponse.body());
}
 
Loading
Loading
Loading
Loading
@@ -8,6 +8,8 @@ import com.commit451.gitlab.api.OkHttpClientFactory;
import com.commit451.gitlab.model.Account;
import com.commit451.gitlab.model.api.UserLogin;
 
import org.junit.Assert;
import okhttp3.OkHttpClient;
import okhttp3.logging.HttpLoggingInterceptor;
import retrofit2.Response;
Loading
Loading
@@ -39,4 +41,10 @@ public class TestUtil {
account.setPrivateToken(loginResponse.body().getPrivateToken());
return gitLab;
}
public static void assertRetrofitResponseSuccess(Response response) throws Exception {
if (!response.isSuccessful()) {
Assert.assertTrue(response.errorBody().string(), response.isSuccessful());
}
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment