From d22167f7e5d548961664c084428ed658f7dd8792 Mon Sep 17 00:00:00 2001 From: Kai Moritz Date: Thu, 21 Nov 2019 22:10:29 +0100 Subject: [PATCH] WIP: Clearified intend... --- ...orResponseErrorHandlerIntegrationTest.java | 56 ++++++++++--------- 1 file changed, 31 insertions(+), 25 deletions(-) diff --git a/src/test/java/de/juplo/facebook/errors/GraphApiErrorResponseErrorHandlerIntegrationTest.java b/src/test/java/de/juplo/facebook/errors/GraphApiErrorResponseErrorHandlerIntegrationTest.java index 470af41..9f70b35 100644 --- a/src/test/java/de/juplo/facebook/errors/GraphApiErrorResponseErrorHandlerIntegrationTest.java +++ b/src/test/java/de/juplo/facebook/errors/GraphApiErrorResponseErrorHandlerIntegrationTest.java @@ -51,22 +51,22 @@ public class GraphApiErrorResponseErrorHandlerIntegrationTest @Test public void testNoError() { -// server -// .enqueue(new MockResponse() -// .setResponseCode(HttpStatus.CONTINUE.value()) -// .setHeader("Content-Type", "application/json") -// .setBody("{ \"message\": \"Hello World!\" }")); -// -// try -// { -// String result = clientTemplate.getForObject(uri, String.class); -// assertEquals("{ \"message\": \"Hello World!\" }", result); -// } -// catch(Exception e) -// { -// LOG.debug("{}", e.toString()); -// fail("Unexpected error: " + e); -// } + server + .enqueue(new MockResponse() + .setResponseCode(HttpStatus.CONTINUE.value()) + .setHeader("Content-Type", "application/json") + .setBody("{ \"message\": \"Hello World!\" }")); + + try + { + SimpleMessage result = clientTemplate.getForObject(uri, SimpleMessage.class); + assertEquals("Hello World!", result.message); + } + catch(Exception e) + { + LOG.debug("{}", e.toString()); + fail("Unexpected error: " + e); + } server @@ -77,8 +77,8 @@ public class GraphApiErrorResponseErrorHandlerIntegrationTest try { - String result = clientTemplate.getForObject(uri, String.class); - assertEquals("{ \"message\": \"Hello World!\" }", result); + SimpleMessage result = clientTemplate.getForObject(uri, SimpleMessage.class); + assertEquals("Hello World!", result.message); } catch(Exception e) { @@ -95,8 +95,8 @@ public class GraphApiErrorResponseErrorHandlerIntegrationTest try { - String result = clientTemplate.getForObject(uri, String.class); - assertEquals("{ \"message\": \"Hello World!\" }", result); + SimpleMessage result = clientTemplate.getForObject(uri, SimpleMessage.class); + assertEquals("Hello World!", result.message); } catch(Exception e) { @@ -113,7 +113,7 @@ public class GraphApiErrorResponseErrorHandlerIntegrationTest try { - clientTemplate.getForObject(uri, String.class); + clientTemplate.getForObject(uri, SimpleMessage.class); fail("The parent handler should have raised an exception!"); } catch(HttpClientErrorException e) @@ -135,7 +135,7 @@ public class GraphApiErrorResponseErrorHandlerIntegrationTest try { - clientTemplate.getForObject(uri, String.class); + clientTemplate.getForObject(uri, SimpleMessage.class); fail("The parent handler should have raised an exception!"); } catch(HttpServerErrorException e) @@ -168,7 +168,7 @@ public class GraphApiErrorResponseErrorHandlerIntegrationTest try { - clientTemplate.getForObject(uri, String.class); + clientTemplate.getForObject(uri, SimpleMessage.class); fail("The expected exception was not thrown"); } catch(RateLimitExceededException e) @@ -199,7 +199,7 @@ public class GraphApiErrorResponseErrorHandlerIntegrationTest try { - clientTemplate.getForObject(uri, String.class); + clientTemplate.getForObject(uri, SimpleMessage.class); fail("The expected exception was not thrown"); } catch(GraphApiException e) @@ -236,7 +236,7 @@ public class GraphApiErrorResponseErrorHandlerIntegrationTest try { - clientTemplate.getForObject(uri, String.class); + clientTemplate.getForObject(uri, SimpleMessage.class); fail("The expected exception was not thrown"); } catch(HttpClientErrorException e) @@ -248,4 +248,10 @@ public class GraphApiErrorResponseErrorHandlerIntegrationTest fail("A wrong exception was thrown: " + e.toString()); } } + + + static class SimpleMessage + { + String message; + } } -- 2.20.1