我正在通过继承PHP的ArrayObject类来实现一个类。但是我没有找到如何在迭代时获取数组的索引。我想同时显示键和值
@RunWith(SpringRunner.class)
@SpringBootTest
@AutoConfigureMockMvc(addFilters = false)
public class UserControllerTest {
@Autowired
private MockMvc mockMvc;
@Test
public void findAll() throws Exception {
MvcResult result = mockMvc
.perform(get("/api/user").contentType(MediaType.APPLICATION_JSON))
.andExpect(status().isOk()).andReturn();
MockHttpServletResponse response = result.getResponse();
RestResponse restResponse = mapper.readValue(response.getContentAsString(), RestResponse.class);
Assert.assertEquals(restResponse.getHttpStatus().name(), HttpStatus.OK.name() );
}
}
@RunWith(SpringRunner.class)
@SpringBootTest
@AutoConfigureMockMvc(addFilters = false)
public class ProductControllerTest {
@Autowired
private MockMvc mockMvc;
@Test
public void findAll() throws Exception {
MvcResult result = mockMvc
.perform(get("/api/product").contentType(MediaType.APPLICATION_JSON))
.andExpect(status().isOk()).andReturn();
MockHttpServletResponse response = result.getResponse();
RestResponse restResponse = mapper.readValue(response.getContentAsString(), RestResponse.class);
Assert.assertEquals(restResponse.getHttpStatus().name(), HttpStatus.OK.name() );
}
}
有人可以帮助我吗?
答案 0 :(得分:0)