From ee1bca08c5a8d4b73cc350b82620dc3a903c4774 Mon Sep 17 00:00:00 2001 From: Marcos Lopez Gonzalez Date: Sun, 25 Feb 2018 21:49:51 +0100 Subject: [PATCH] refactor --- .../com/baeldung/jersey/server/Greetings.java | 7 +++++-- .../jersey/client/JerseyClientTest.java | 18 +++++++++--------- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/jersey/src/main/java/com/baeldung/jersey/server/Greetings.java b/jersey/src/main/java/com/baeldung/jersey/server/Greetings.java index 5e2781ee3c..d0ea873db1 100644 --- a/jersey/src/main/java/com/baeldung/jersey/server/Greetings.java +++ b/jersey/src/main/java/com/baeldung/jersey/server/Greetings.java @@ -3,6 +3,8 @@ package com.baeldung.jersey.server; import javax.ws.rs.GET; import javax.ws.rs.POST; import javax.ws.rs.Path; +import javax.ws.rs.core.Response; +import javax.ws.rs.core.Response.Status; import com.baeldung.jersey.server.config.HelloBinding; @@ -23,7 +25,8 @@ public class Greetings { @POST @Path("/custom") - public String getCustomGreeting(String name) { - return "hello " + name; + public Response getCustomGreeting(String name) { + return Response.status(Status.OK.getStatusCode()) + .build(); } } diff --git a/jersey/src/test/java/com/baeldung/jersey/client/JerseyClientTest.java b/jersey/src/test/java/com/baeldung/jersey/client/JerseyClientTest.java index b4bdccfd86..ddee736200 100644 --- a/jersey/src/test/java/com/baeldung/jersey/client/JerseyClientTest.java +++ b/jersey/src/test/java/com/baeldung/jersey/client/JerseyClientTest.java @@ -8,26 +8,26 @@ import org.junit.Test; public class JerseyClientTest { private static int HTTP_OK = 200; - + @Test - public void getHelloGreetingTest() { + public void givenGreetingResource_whenCallingHelloGreeting_thenHelloReturned() { String response = JerseyClient.getHelloGreeting(); - + Assert.assertEquals("hello", response); } - + @Test - public void getHiGreetingTest() { + public void givenGreetingResource_whenCallingHiGreeting_thenHiReturned() { String response = JerseyClient.getHiGreeting(); - + Assert.assertEquals("hi", response); } - + @Test - public void getCustomGreetingTest() { + public void givenGreetingResource_whenCallingCustomGreeting_thenCustomGreetingReturned() { Response response = JerseyClient.getCustomGreeting(); Assert.assertEquals(HTTP_OK, response.getStatus()); } - + }