Skip to content

Commit

Permalink
#39 - Added one more test case to ResponseInterpreterUtil.
Browse files Browse the repository at this point in the history
  • Loading branch information
Simon Jahreiß committed Oct 20, 2016
1 parent cac0d6c commit 183bf32
Showing 1 changed file with 16 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,17 @@
*/
package de.qaware.cloud.deployer.commons.resource;

import okhttp3.Protocol;
import okhttp3.Request;
import okhttp3.ResponseBody;
import org.junit.Test;
import retrofit2.Response;

import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import static retrofit2.Response.success;

/**
* @author sjahreis
Expand All @@ -32,7 +36,7 @@ public class ResponseInterpreterUtilTest {

@Test
public void testIsNotFoundResponse() {
Response<ResponseBody> response = Response.success(body);
Response<ResponseBody> response = success(body);
boolean interpreterResponse = ResponseInterpreterUtil.isNotFoundResponse(response);
assertFalse(interpreterResponse);

Expand All @@ -51,10 +55,19 @@ public void testIsNotFoundResponse() {

@Test
public void testIsSuccessResponse() {
Response<ResponseBody> response = Response.success(body);
Response<ResponseBody> response = success(body);
boolean interpreterResponse = ResponseInterpreterUtil.isSuccessResponse(response);
assertTrue(interpreterResponse);

response = success(body, new okhttp3.Response.Builder()
.code(201)
.message("OK")
.protocol(Protocol.HTTP_1_1)
.request(new Request.Builder().url("http://localhost/").build())
.build());
interpreterResponse = ResponseInterpreterUtil.isSuccessResponse(response);
assertTrue(interpreterResponse);

response = Response.error(401, body);
interpreterResponse = ResponseInterpreterUtil.isSuccessResponse(response);
assertFalse(interpreterResponse);
Expand All @@ -70,7 +83,7 @@ public void testIsSuccessResponse() {

@Test
public void testIsServerErrorResponse() {
Response<ResponseBody> response = Response.success(body);
Response<ResponseBody> response = success(body);
boolean interpreterResponse = ResponseInterpreterUtil.isServerErrorResponse(response);
assertFalse(interpreterResponse);

Expand Down

0 comments on commit 183bf32

Please sign in to comment.