@RequestMapping(value= "/project/{id}", method= RequestMethod.GET)
public Project getEmployeeById(@PathVariable int projectId) throws Exception {
Optional<Project> emp = projectservice.getProjectById(projectId);
if(!emp.isPresent())
throw new Exception("Could not find employee with id- " + projectId);
return emp.get();
}
字符串
本试验方法的适用范围为:
@Test
public void getEmployeeByIdtest() throws Exception {
MockHttpServletResponse response = mvc.perform(get(restEndPoints.GET_EMPLOYEE_ID.uri())
.param("projectId", "2")).andReturn().getResponse();
assertThat(response.getStatus()).isEqualTo(HttpStatus.OK.value());
assertNotNull(response.getContentAsString());
}
型
获取错误:
java.lang.IllegalArgumentException:无法使用足够的变量值来展开“id”
1条答案
按热度按时间cunj1qz11#
而不是
字符串
你应该使用
型
curlies中的名称必须与方法参数名称匹配。