Json Patch e2e#1565
Conversation
| gene is ObjectGene -> calculateDtoFromObject(gene, actionName) | ||
| gene is ArrayGene<*> -> calculateDtoFromArray(gene, actionName) | ||
| gene is FixedMapGene<*, *> -> calculateDtoFromFixedMapGene(gene, actionName) | ||
| gene is JsonPatchDocumentGene -> return |
There was a problem hiding this comment.
Add TODO on JsonPatchDocumentGene written as DTO when the test case is written
| var gene: Gene | ||
| if (isJsonPatch) { | ||
| name = "body" | ||
| val patchResourceSchema = JsonPatchSchemaResolver.resolveResourceSchema( |
There was a problem hiding this comment.
Add comment on what is the intended behaviour of this.
| assertEquals(dtoWriter.getCollectedDtos().size, 0) | ||
| } | ||
|
|
||
| @Test |
There was a problem hiding this comment.
this test case should be removed
| @SpringBootApplication(exclude = [SecurityAutoConfiguration::class]) | ||
| @RestController | ||
| @RequestMapping("/pets") | ||
| open class BBJsonPatchApplication { |
There was a problem hiding this comment.
Why blackbox and whitebox, I think we need only one of them for testing this functionality.
| return ResponseEntity.ok("patched") | ||
| } | ||
|
|
||
| @ApiResponses(value = [ |
There was a problem hiding this comment.
why all these @ApiResponses documentation? if it is not used directly, then it is just noise for the tests (eg, make this class harder to read). Remove them unless they are necessary
There was a problem hiding this comment.
done, i removed them 👍
| // how a JSON Patch document should be rendered when a test case is written (it is not a | ||
| // regular object/array DTO but an RFC 6902 array of operations), this should build and | ||
| // emit the corresponding DTO instead of returning. | ||
| gene is JsonPatchDocumentGene -> return |
There was a problem hiding this comment.
these will break generated tests. somewhere, there is the option of not applying DTO for an action. you could check if action is using any JsonPatchDocumentGene, and uses string instead of DTO in those cases
There was a problem hiding this comment.
ok, i applied that check in HttpWsTestCaseWriter.kt, lines 131-133, is that alright?
| @Test | ||
| fun testResolveFromGetResponse() { | ||
| val schema = parse(minimalSpec(""" | ||
| "/pets/{id}": { |
There was a problem hiding this comment.
this is fine. but, in future, it is best to have schema files under resources and read them in the tests. the point is that, once in a file, it is easier to edit and validate them with an IDE.
There was a problem hiding this comment.
done. i moved them to a file under resources 👍
We now add the logic to restAction to handle json patch request, and to read the schema from get, put or post endpoints in the same place from patch request, if there's any.
also, we add black and white box tests.