Fix incorrect assertions using json path

Closes gh-32036
This commit is contained in:
Stéphane Nicoll 2024-01-16 10:59:43 +01:00
parent faba044735
commit e0c5068d0b
3 changed files with 10 additions and 10 deletions

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -110,7 +110,7 @@ class ExceptionHandlerTests {
.accept(MediaType.APPLICATION_JSON)
.exchange()
.expectStatus().isOk()
.expectBody().jsonPath("$.name", "Yoda");
.expectBody().jsonPath("$.name").isEqualTo("Yoda");
}
@Test
@ -123,7 +123,7 @@ class ExceptionHandlerTests {
.accept(MediaType.APPLICATION_JSON)
.exchange()
.expectStatus().isOk()
.expectBody().jsonPath("$.error", "local - IllegalArgumentException");
.expectBody().jsonPath("$.error").isEqualTo("local - IllegalArgumentException");
}
@Test
@ -136,7 +136,7 @@ class ExceptionHandlerTests {
.accept(MediaType.APPLICATION_JSON)
.exchange()
.expectStatus().isOk()
.expectBody().jsonPath("$.error", "global - IllegalArgumentException");
.expectBody().jsonPath("$.error").isEqualTo("global - IllegalStateException");
}
@Test
@ -149,7 +149,7 @@ class ExceptionHandlerTests {
.accept(MediaType.APPLICATION_JSON)
.exchange()
.expectStatus().isOk()
.expectBody().jsonPath("$.error", "globalPersonController - IllegalStateException");
.expectBody().jsonPath("$.error").isEqualTo("globalPersonController - IllegalStateException");
}
@Test
@ -162,7 +162,7 @@ class ExceptionHandlerTests {
.accept(MediaType.APPLICATION_JSON)
.exchange()
.expectStatus().isOk()
.expectBody().jsonPath("$.error", "global - NoHandlerFoundException");
.expectBody().jsonPath("$.error").isEqualTo("global - NoHandlerFoundException");
}
}

View File

@ -45,7 +45,7 @@ public class RequestParameterTests {
.exchange()
.expectStatus().isOk()
.expectHeader().contentType(MediaType.APPLICATION_JSON)
.expectBody().jsonPath("$.name", "George");
.expectBody().jsonPath("$.name").isEqualTo("George");
}

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2020 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -85,7 +85,7 @@ class ViewResolutionTests {
.exchange()
.expectStatus().isOk()
.expectHeader().contentTypeCompatibleWith(MediaType.APPLICATION_JSON)
.expectBody().jsonPath("$.person.name", "Corea");
.expectBody().jsonPath("$.person.name").isEqualTo("Corea");
}
@Test
@ -143,7 +143,7 @@ class ViewResolutionTests {
.exchange()
.expectStatus().isOk()
.expectHeader().contentTypeCompatibleWith(MediaType.APPLICATION_JSON)
.expectBody().jsonPath("$.person.name", "Corea");
.expectBody().jsonPath("$.person.name").isEqualTo("Corea");
testClient.get().uri("/person/Corea")
.accept(MediaType.APPLICATION_XML)