vlsi commented on a change in pull request #660:
URL: https://github.com/apache/jmeter/pull/660#discussion_r757608183
##########
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:
Please refine the test so it is clear what it does.
Currently, it looks like it duplicates the same data 3 times, and
`fieldName` seems to be unused.
What is the purpose of having parameters here?
--
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]