0
votes

Spring MockMVC: Le champ Assert JSON est un tableau vide ou non existé

J'utilise MockMVC pour tester une API qui renvoie le contenu JSON et que JSON peut contenir un champ appelé actions comme une matrice vide ou peut-être ne pas exister du tout (je veux dire partage champ).

échantillon JSON: xxx

Comment affirmer que ce champ est vide ou non existé < p> J'aime: xxx


0 commentaires

3 Réponses :


0
votes

regarder regarder Jsonpath ou condition avec MockMVC

.andExpect(jsonPath("$.isPass", anyOf(is(false),is(true))));


0 commentaires

-1
votes
import static org.hamcrest.collection.IsEmptyCollection.empty;

.andExpect(jsonPath("$.isPass",empty() ));

0 commentaires

0
votes

Si vous avez quelque chose comme ceci:

.andExpect( jsonPath( "$.arrayFieldName", Matchers.empty() );


0 commentaires