woonsan commented on a change in pull request #660:
URL: https://github.com/apache/jmeter/pull/660#discussion_r757964638



##########
File path: 
src/protocol/http/src/test/java/org/apache/jmeter/protocol/http/util/TestGraphQLRequestParamUtils.java
##########
@@ -97,9 +102,21 @@ void testInvalidGraphQLContentType(String contentType) {
         
assertFalse(GraphQLRequestParamUtils.isGraphQLContentType(contentType));
     }
 
-    @Test
-    void testToPostBodyString() throws Exception {
-        assertEquals(EXPECTED_POST_BODY, 
GraphQLRequestParamUtils.toPostBodyString(params));
+    static Stream<org.junit.jupiter.params.provider.Arguments> 
postBodyFieldNameAndJsonNodes() throws Exception {
+        final JsonNode expectedPostBodyJson = 
objectMapper.readTree(EXPECTED_POST_BODY);
+        final JsonNode actualPostBodyJson = objectMapper.readTree(
+                GraphQLRequestParamUtils.toPostBodyString(new 
GraphQLRequestParams(OPERATION_NAME, QUERY, VARIABLES)));
+        return Stream.of(
+                arguments(GraphQLRequestParamUtils.OPERATION_NAME_FIELD, 
expectedPostBodyJson, actualPostBodyJson),
+                arguments(GraphQLRequestParamUtils.VARIABLES_FIELD, 
expectedPostBodyJson, actualPostBodyJson),
+                arguments(GraphQLRequestParamUtils.QUERY_FIELD, 
expectedPostBodyJson, actualPostBodyJson));
+    }
+
+    @ParameterizedTest
+    @MethodSource("postBodyFieldNameAndJsonNodes")
+    void testToPostBodyString(String fieldName, JsonNode expectedNode, 
JsonNode actualNode) throws Exception {
+        assertEquals(expectedNode, actualNode,
+                "The value of the '" + fieldName + "' field doesn't match in " 
+ actualNode);

Review comment:
       It is for testing whether the `#toPostBodyString()` has the equivalent 
JSON data by asserting each field, `operationName`, `variables` and `query`. 
And the `fieldName` is used in the assert message to explain which field is 
possibly different from the expectation.




-- 
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: dev-unsubscr...@jmeter.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to