VersionController { @ResponseBody @RequestMapping(value = "/version", method = RequestMethod.GET) public ResponseEntity<String> getVersion() { String messageSearchVersion = titleProvider.getVersionTitle(); String jsonData = "{\"messageSearchVersion\":\"" + messageSearchVersion + "\"}"; HttpHeaders responseHeaders = new HttpHeaders(); responseHeaders.setContentType(MediaType.APPLICATION_JSON); return new ResponseEntity<String>(jsonData, responseHeaders, HttpStatus.CREATED); }  @ResponseBody @RequestMapping(value = "/version", method = RequestMethod.GET) ResponseEntity<String> getVersion();  }
@Test public void testGetVersionShouldReturnVersionResponse() { given(titleProvider.getVersionTitle()).willReturn("version"); ResponseEntity<String> result = underTest.getVersion(); assertEquals(result.getStatusCode(), HttpStatus.CREATED); assertEquals("{\"messageSearchVersion\":\"version\"}", result.getBody()); assertEquals(MediaType.APPLICATION_JSON, result.getHeaders().getContentType()); }