### Question:
ModelDescriptionController { @RequestMapping(value = "/asJson/{className}.action", method = RequestMethod.GET) public @ResponseBody Map<String, Object> getJsonSchema(@PathVariable String className) { try { JsonSchema json = modelDescriptionService.getJsonSchema(className); if (json == null) { return ResultSet.error("Model description (json) for model " + className + " is null."); } return ResultSet.success(json); } catch (Exception e) { return ResultSet.error("Could not get description for " + className + " " + e.getMessage()); } }  @RequestMapping(value = "/asJson/{className}.action", method = RequestMethod.GET) @ResponseBody Map<String, Object> getJsonSchema(@PathVariable String className); void setModelDescriptionService(ModelDescriptionService modelDescriptionService);  }### Answer:
@Test public void getJsonSchemaSuccessMap() throws Exception { final String className = "Module"; final Class<?> foundClass = Class.forName("de.terrestris.shoguncore.model.module.".concat(className)); final JsonSchemaGenerator schemaGen = new JsonSchemaGenerator(new ObjectMapper()); final JsonSchema schema = schemaGen.generateSchema(foundClass); Mockito.when(modelDescriptionService.getJsonSchema( Matchers.any(String.class)) ).thenReturn(schema); String MODELDESCRIPTION_ENDPOINT = "/describeModel/asJson/"+className+".action"; MvcResult result = mockMvc.perform(MockMvcRequestBuilders.get(MODELDESCRIPTION_ENDPOINT) .param("className", className)) .andExpect(MockMvcResultMatchers.status().isOk()).andReturn(); String content = result.getResponse().getContentAsString(); ObjectMapper objectMapper = new ObjectMapper(); Assert.assertEquals("Returned body matched mocked one.", objectMapper.writeValueAsString(ResultSet.success(schema)), content); Mockito.verify(modelDescriptionService, Mockito.times(1)). getJsonSchema(Matchers.any(String.class)); Mockito.verifyNoMoreInteractions(modelDescriptionService); }
@Test public void getJsonSchemaErrorMap() throws Exception { final String className = "Module"; final String errorMsg = "Model description (json) for model " + className + " is null."; Mockito.when(modelDescriptionService.getJsonSchema( Matchers.any(String.class)) ).thenReturn(null); String MODELDESCRIPTION_ENDPOINT = "/describeModel/asJson/"+className+".action"; MvcResult result = mockMvc.perform(MockMvcRequestBuilders.get(MODELDESCRIPTION_ENDPOINT) .param("className", className)) .andExpect(MockMvcResultMatchers.status().isOk()).andReturn(); String content = result.getResponse().getContentAsString(); ObjectMapper objectMapper = new ObjectMapper(); Assert.assertEquals("Returned body matched mocked one.", objectMapper.writeValueAsString(ResultSet.error(errorMsg)), content); Mockito.verify(modelDescriptionService, Mockito.times(1)). getJsonSchema(Matchers.any(String.class)); Mockito.verifyNoMoreInteractions(modelDescriptionService); }