Skip to content

Json Patch e2e#1565

Open
suarezrominajulieta wants to merge 13 commits into
masterfrom
feature/jsonPatch_e2e
Open

Json Patch e2e#1565
suarezrominajulieta wants to merge 13 commits into
masterfrom
feature/jsonPatch_e2e

Conversation

@suarezrominajulieta

Copy link
Copy Markdown
Collaborator

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.

Base automatically changed from feature/jsonPatch to master June 4, 2026 07:03
@suarezrominajulieta suarezrominajulieta marked this pull request as ready for review June 4, 2026 17:56
gene is ObjectGene -> calculateDtoFromObject(gene, actionName)
gene is ArrayGene<*> -> calculateDtoFromArray(gene, actionName)
gene is FixedMapGene<*, *> -> calculateDtoFromFixedMapGene(gene, actionName)
gene is JsonPatchDocumentGene -> return

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add TODO on JsonPatchDocumentGene written as DTO when the test case is written

var gene: Gene
if (isJsonPatch) {
name = "body"
val patchResourceSchema = JsonPatchSchemaResolver.resolveResourceSchema(

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add comment on what is the intended behaviour of this.

assertEquals(dtoWriter.getCollectedDtos().size, 0)
}

@Test

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this test case should be removed

@SpringBootApplication(exclude = [SecurityAutoConfiguration::class])
@RestController
@RequestMapping("/pets")
open class BBJsonPatchApplication {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why blackbox and whitebox, I think we need only one of them for testing this functionality.

@jgaleotti jgaleotti assigned arcuri82 and unassigned arcuri82 Jun 8, 2026
@jgaleotti jgaleotti requested a review from arcuri82 June 8, 2026 19:22
return ResponseEntity.ok("patched")
}

@ApiResponses(value = [

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, i applied that check in HttpWsTestCaseWriter.kt, lines 131-133, is that alright?

@Test
fun testResolveFromGetResponse() {
val schema = parse(minimalSpec("""
"/pets/{id}": {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done. i moved them to a file under resources 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants