From 183bf32922e2768b95080f1aefdc21c37f2b1584 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20Jahrei=C3=9F?= Date: Thu, 20 Oct 2016 10:53:14 +0200 Subject: [PATCH] #39 - Added one more test case to ResponseInterpreterUtil. --- .../resource/ResponseInterpreterUtilTest.java | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/deployer-commons/src/test/java/de/qaware/cloud/deployer/commons/resource/ResponseInterpreterUtilTest.java b/deployer-commons/src/test/java/de/qaware/cloud/deployer/commons/resource/ResponseInterpreterUtilTest.java index 2e215ef0..0db74783 100644 --- a/deployer-commons/src/test/java/de/qaware/cloud/deployer/commons/resource/ResponseInterpreterUtilTest.java +++ b/deployer-commons/src/test/java/de/qaware/cloud/deployer/commons/resource/ResponseInterpreterUtilTest.java @@ -15,6 +15,8 @@ */ package de.qaware.cloud.deployer.commons.resource; +import okhttp3.Protocol; +import okhttp3.Request; import okhttp3.ResponseBody; import org.junit.Test; import retrofit2.Response; @@ -22,6 +24,8 @@ 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 @@ -32,7 +36,7 @@ public class ResponseInterpreterUtilTest { @Test public void testIsNotFoundResponse() { - Response response = Response.success(body); + Response response = success(body); boolean interpreterResponse = ResponseInterpreterUtil.isNotFoundResponse(response); assertFalse(interpreterResponse); @@ -51,10 +55,19 @@ public void testIsNotFoundResponse() { @Test public void testIsSuccessResponse() { - Response response = Response.success(body); + Response 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); @@ -70,7 +83,7 @@ public void testIsSuccessResponse() { @Test public void testIsServerErrorResponse() { - Response response = Response.success(body); + Response response = success(body); boolean interpreterResponse = ResponseInterpreterUtil.isServerErrorResponse(response); assertFalse(interpreterResponse);