matrei commented on code in PR #15478:
URL: https://github.com/apache/grails-core/pull/15478#discussion_r2890660192


##########
grails-test-examples/views-functional-tests/src/integration-test/groovy/functional/tests/api/NamespacedBookSpec.groovy:
##########
@@ -16,142 +16,103 @@
  *  specific language governing permissions and limitations
  *  under the License.
  */
-
 package functional.tests.api
 
-import com.fasterxml.jackson.databind.ObjectMapper
-import functional.tests.Application
-import functional.tests.HttpClientSpec
-import grails.testing.mixin.integration.Integration
-import grails.testing.spock.RunOnce
-import grails.web.http.HttpHeaders
-import io.micronaut.http.HttpRequest
-import io.micronaut.http.HttpResponse
-import io.micronaut.http.HttpStatus
-import io.micronaut.http.MediaType
-import org.junit.jupiter.api.BeforeEach
 import spock.lang.Issue
-import spock.lang.Shared
-
-@Integration(applicationClass = Application)
-class NamespacedBookSpec extends HttpClientSpec {
-
-    @Shared
-    ObjectMapper objectMapper
+import spock.lang.Specification
 
-    def setup() {
-        objectMapper = new ObjectMapper()
-    }
+import grails.testing.mixin.integration.Integration
+import org.apache.grails.testing.httpclient.HttpClientSupport
 
-    @RunOnce
-    @BeforeEach
-    void init() {
-        super.init()
-    }
+@Integration
+class NamespacedBookSpec extends Specification implements HttpClientSupport {
 
     void 'test view rendering with a namespace'() {
         when: 'A request is sent to a controller with a namespace'
-        HttpRequest request = HttpRequest.GET('/api/book')
-        HttpResponse<Map> rsp = client.toBlocking().exchange(request, Map)
-
-        then: 'The rsponse is correct'
-            rsp.status() == HttpStatus.OK
-            rsp.headers.getFirst(HttpHeaders.CONTENT_TYPE).isPresent()
-            rsp.headers.getFirst(HttpHeaders.CONTENT_TYPE).get() == 
'application/json;charset=UTF-8'
-            rsp.body().api == 'version 1.0 (Namespaced)'
-            rsp.body().title == 'API - The Shining'
+        def response = http('/api/book')
+
+        then: 'The response is correct'
+        response.expectJson(200, 'Content-Type': 
'application/json;charset=UTF-8', [
+                api: 'version 1.0 (Namespaced)',
+                title: 'API - The Shining'
+        ])

Review Comment:
   This is not correct. Map param first becomes named params in Groovy.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to