Class BenchmarkTestCaseLoader
The test data files use the c2j protocol test format, where the top-level
structure is an array of operation-group objects. Each group contains
a cases array with individual test cases.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classRepresents a single marshalling test case loaded from the input JSON.static final classRepresents a single unmarshalling test case loaded from the output JSON. -
Method Summary
Modifier and TypeMethodDescriptionstatic OperationInfobuildOperationInfo(IntermediateModel model, BenchmarkTestCaseLoader.MarshallTestCase testCase) Build anOperationInfofor the given operation by inspecting the intermediate model's input shape to determine payload flags.static IntermediateModelloadIntermediateModel(String resourcePath) Load anIntermediateModelfrom the classpath and patch member names so thatShapeModelReflectorresolves the correct fluent setter method names.loadMarshallTestCases(String resourcePath) Load all marshall test cases from the given resource path.loadUnmarshallTestCases(String resourcePath) Load all unmarshall test cases from the given resource path.
-
Method Details
-
loadMarshallTestCases
public static List<BenchmarkTestCaseLoader.MarshallTestCase> loadMarshallTestCases(String resourcePath) Load all marshall test cases from the given resource path.Iterates through the top-level array of operation groups, then through each group's
casesarray. Extractsidfrom the case,operationNamefromcase.given.name, andinputDatafromcase.params.- Parameters:
resourcePath- classpath resource path to the input test JSON file- Returns:
- list of marshall test cases
- Throws:
IllegalStateException- if the resource is not foundIllegalArgumentException- if the JSON is malformed or missing required fields
-
loadUnmarshallTestCases
public static List<BenchmarkTestCaseLoader.UnmarshallTestCase> loadUnmarshallTestCases(String resourcePath) Load all unmarshall test cases from the given resource path.Iterates through the top-level array of operation groups, then through each group's
casesarray. Extractsidfrom the case,operationNamefromcase.given.name,responseBodyfromcase.response.body,statusCodefromcase.response.status_code(defaults to 200 if absent), andheadersfromcase.response.headers(null if absent).- Parameters:
resourcePath- classpath resource path to the output test JSON file- Returns:
- list of unmarshall test cases
- Throws:
IllegalStateException- if the resource is not foundIllegalArgumentException- if the JSON is malformed or missing required fields
-
loadIntermediateModel
Load anIntermediateModelfrom the classpath and patch member names so thatShapeModelReflectorresolves the correct fluent setter method names.The codegen-generated fluent setter for a member named
"SS"isss(), butShapeModelReflectorderives the setter name by callingStringUtils.uncapitalize(member.getName())which produces"sS". This method patches each member'snameto be the capitalized form offluentSetterMethodNameso that uncapitalize produces the correct result.- Parameters:
resourcePath- classpath resource path to the intermediate model JSON- Returns:
- the loaded and patched IntermediateModel
-
buildOperationInfo
public static OperationInfo buildOperationInfo(IntermediateModel model, BenchmarkTestCaseLoader.MarshallTestCase testCase) Build anOperationInfofor the given operation by inspecting the intermediate model's input shape to determine payload flags. This replicates the logic the codegen uses when generating per-operation marshallers.- Parameters:
model- the loaded IntermediateModeltestCase- the test case (provides operationName, httpMethod, requestUri)- Returns:
- correctly configured OperationInfo
-