Skip to content

Instantly share code, notes, and snippets.

@vyo
Created June 8, 2017 13:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vyo/4387e1e631c4784656bfe16a470a52d8 to your computer and use it in GitHub Desktop.
Save vyo/4387e1e631c4784656bfe16a470a52d8 to your computer and use it in GitHub Desktop.
public class EchoControllerTest extends ControllerTest<EchoController> {
private EchoService echoService;
@Before
public void setup() {
echoService = (EchoService) getField(EchoService.class);
when(echoService.reverse(eq("input"))).thenReturn("tupni");
}
@Test
public void echo() throws Exception {
String input = "input";
String reverse = new StringBuilder(input).reverse().toString();
Response response = target("echo")
.path(input)
.request()
.get();
assertEquals(Status.OK.getStatusCode(), response.getStatus());
assertEquals(MediaType.APPLICATION_JSON_TYPE, response.getMediaType());
assertEquals(reverse, response.readEntity(Echo.class).getEcho());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment