일부 특정 속성의 모든 값이 동일한 유형 인 경우 내 통합 테스트를 확인하려고합니다. jsonPath 및 JsonPathResultMatchers와 함께이 작업을 수행하려고했지만 성공하지 못했습니다. 나는이 같은 짓 마지막에 :모든 JSON 속성 값 유형을 확인하는 가장 좋은 방법은 무엇입니까?
MvcResult result = mockMvc.perform(get("/weather/" + existingCity))
.andExpect(MockMvcResultMatchers.status().isOk())
.andReturn();
String responseContent = result.getResponse().getContentAsString();
TypeRef<List<Object>> typeRef = new TypeRef<List<Object>>() {
};
List<Object> humidities = JsonPath.using(configuration).parse(responseContent).read("$.*.humidity", typeRef);
Assertions.assertThat(humidities.stream().allMatch(humidity -> humidity instanceof Integer)).isTrue();
을하지만,이 작업을 수행하는 몇 가지 명확한 방법이 존재하는 경우 나는 같은 결과가 JSONPath을 달성 할 수 있을까? 또는 AssertJ 사용 스트림 코드없이 찾을 수있는 몇 가지 방법이 있습니다