Removed tests for invalid -1 index (for compatibility with JsonPath 2.1)
This commit is contained in:
@@ -78,7 +78,6 @@ public class JsonPathRequestMatchersIntegrationTests {
|
|||||||
.andExpect(content().contentType("application/json;charset=UTF-8"))
|
.andExpect(content().contentType("application/json;charset=UTF-8"))
|
||||||
.andExpect(jsonPath("$.composers[?(@.name == 'Edvard Grieeeeeeg')]").doesNotExist())
|
.andExpect(jsonPath("$.composers[?(@.name == 'Edvard Grieeeeeeg')]").doesNotExist())
|
||||||
.andExpect(jsonPath("$.composers[?(@.name == 'Robert Schuuuuuuman')]").doesNotExist())
|
.andExpect(jsonPath("$.composers[?(@.name == 'Robert Schuuuuuuman')]").doesNotExist())
|
||||||
.andExpect(jsonPath("$.composers[-1]").doesNotExist())
|
|
||||||
.andExpect(jsonPath("$.composers[4]").doesNotExist())
|
.andExpect(jsonPath("$.composers[4]").doesNotExist())
|
||||||
.andRespond(withSuccess());
|
.andRespond(withSuccess());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -45,6 +45,7 @@ public class JsonPathAssertionTests {
|
|||||||
|
|
||||||
private MockMvc mockMvc;
|
private MockMvc mockMvc;
|
||||||
|
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setup() {
|
public void setup() {
|
||||||
this.mockMvc = standaloneSetup(new MusicController())
|
this.mockMvc = standaloneSetup(new MusicController())
|
||||||
@@ -54,9 +55,9 @@ public class JsonPathAssertionTests {
|
|||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testExists() throws Exception {
|
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void exists() throws Exception {
|
||||||
String composerByName = "$.composers[?(@.name == '%s')]";
|
String composerByName = "$.composers[?(@.name == '%s')]";
|
||||||
String performerByName = "$.performers[?(@.name == '%s')]";
|
String performerByName = "$.performers[?(@.name == '%s')]";
|
||||||
|
|
||||||
@@ -74,16 +75,15 @@ public class JsonPathAssertionTests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testDoesNotExist() throws Exception {
|
public void doesNotExist() throws Exception {
|
||||||
this.mockMvc.perform(get("/music/people"))
|
this.mockMvc.perform(get("/music/people"))
|
||||||
.andExpect(jsonPath("$.composers[?(@.name == 'Edvard Grieeeeeeg')]").doesNotExist())
|
.andExpect(jsonPath("$.composers[?(@.name == 'Edvard Grieeeeeeg')]").doesNotExist())
|
||||||
.andExpect(jsonPath("$.composers[?(@.name == 'Robert Schuuuuuuman')]").doesNotExist())
|
.andExpect(jsonPath("$.composers[?(@.name == 'Robert Schuuuuuuman')]").doesNotExist())
|
||||||
.andExpect(jsonPath("$.composers[-1]").doesNotExist())
|
|
||||||
.andExpect(jsonPath("$.composers[4]").doesNotExist());
|
.andExpect(jsonPath("$.composers[4]").doesNotExist());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testEqualTo() throws Exception {
|
public void equality() throws Exception {
|
||||||
this.mockMvc.perform(get("/music/people"))
|
this.mockMvc.perform(get("/music/people"))
|
||||||
.andExpect(jsonPath("$.composers[0].name").value("Johann Sebastian Bach"))
|
.andExpect(jsonPath("$.composers[0].name").value("Johann Sebastian Bach"))
|
||||||
.andExpect(jsonPath("$.performers[1].name").value("Yehudi Menuhin"));
|
.andExpect(jsonPath("$.performers[1].name").value("Yehudi Menuhin"));
|
||||||
@@ -95,7 +95,7 @@ public class JsonPathAssertionTests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testHamcrestMatcher() throws Exception {
|
public void hamcrestMatcher() throws Exception {
|
||||||
this.mockMvc.perform(get("/music/people"))
|
this.mockMvc.perform(get("/music/people"))
|
||||||
.andExpect(jsonPath("$.composers[0].name", startsWith("Johann")))
|
.andExpect(jsonPath("$.composers[0].name", startsWith("Johann")))
|
||||||
.andExpect(jsonPath("$.performers[0].name", endsWith("Ashkenazy")))
|
.andExpect(jsonPath("$.performers[0].name", endsWith("Ashkenazy")))
|
||||||
@@ -104,8 +104,7 @@ public class JsonPathAssertionTests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testHamcrestMatcherWithParameterizedJsonPath() throws Exception {
|
public void hamcrestMatcherWithParameterizedJsonPath() throws Exception {
|
||||||
|
|
||||||
String composerName = "$.composers[%s].name";
|
String composerName = "$.composers[%s].name";
|
||||||
String performerName = "$.performers[%s].name";
|
String performerName = "$.performers[%s].name";
|
||||||
|
|
||||||
@@ -135,4 +134,5 @@ public class JsonPathAssertionTests {
|
|||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user