refactor
This commit is contained in:
parent
411f4e9b97
commit
ee1bca08c5
|
@ -3,6 +3,8 @@ package com.baeldung.jersey.server;
|
||||||
import javax.ws.rs.GET;
|
import javax.ws.rs.GET;
|
||||||
import javax.ws.rs.POST;
|
import javax.ws.rs.POST;
|
||||||
import javax.ws.rs.Path;
|
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;
|
import com.baeldung.jersey.server.config.HelloBinding;
|
||||||
|
|
||||||
|
@ -23,7 +25,8 @@ public class Greetings {
|
||||||
|
|
||||||
@POST
|
@POST
|
||||||
@Path("/custom")
|
@Path("/custom")
|
||||||
public String getCustomGreeting(String name) {
|
public Response getCustomGreeting(String name) {
|
||||||
return "hello " + name;
|
return Response.status(Status.OK.getStatusCode())
|
||||||
|
.build();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,21 +10,21 @@ public class JerseyClientTest {
|
||||||
private static int HTTP_OK = 200;
|
private static int HTTP_OK = 200;
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getHelloGreetingTest() {
|
public void givenGreetingResource_whenCallingHelloGreeting_thenHelloReturned() {
|
||||||
String response = JerseyClient.getHelloGreeting();
|
String response = JerseyClient.getHelloGreeting();
|
||||||
|
|
||||||
Assert.assertEquals("hello", response);
|
Assert.assertEquals("hello", response);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getHiGreetingTest() {
|
public void givenGreetingResource_whenCallingHiGreeting_thenHiReturned() {
|
||||||
String response = JerseyClient.getHiGreeting();
|
String response = JerseyClient.getHiGreeting();
|
||||||
|
|
||||||
Assert.assertEquals("hi", response);
|
Assert.assertEquals("hi", response);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getCustomGreetingTest() {
|
public void givenGreetingResource_whenCallingCustomGreeting_thenCustomGreetingReturned() {
|
||||||
Response response = JerseyClient.getCustomGreeting();
|
Response response = JerseyClient.getCustomGreeting();
|
||||||
|
|
||||||
Assert.assertEquals(HTTP_OK, response.getStatus());
|
Assert.assertEquals(HTTP_OK, response.getStatus());
|
||||||
|
|
Loading…
Reference in New Issue