-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
regression: support JSON Merge Patch (#10089)
- Loading branch information
1 parent
9a59ee8
commit 1620389
Showing
6 changed files
with
66 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
test-suite/src/test/java/io/micronaut/docs/jsonpatch/JsonMergePatchTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package io.micronaut.docs.jsonpatch; | ||
|
||
import io.micronaut.context.annotation.Property; | ||
import io.micronaut.context.annotation.Requires; | ||
import io.micronaut.core.annotation.Introspected; | ||
import io.micronaut.http.HttpRequest; | ||
import io.micronaut.http.MediaType; | ||
import io.micronaut.http.annotation.*; | ||
import io.micronaut.http.client.HttpClient; | ||
import io.micronaut.http.client.annotation.Client; | ||
import io.micronaut.test.extensions.junit5.annotation.MicronautTest; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import static org.junit.jupiter.api.Assertions.*; | ||
|
||
@Property(name = "spec.name", value = "JsonMergePatchTest") | ||
@MicronautTest | ||
public class JsonMergePatchTest { | ||
@Test | ||
void acceptMergePatchJsonContentType(@Client("/") HttpClient client) { | ||
String expected, body = expected = "{\"f\":\"foo\",\"b\":\"bar\"}"; | ||
String response = assertDoesNotThrow(() -> client.toBlocking().retrieve( | ||
HttpRequest.PATCH("/json-merge-patch", body) | ||
.contentType("application/merge-patch+json") | ||
.accept("application/merge-patch+json") | ||
)); | ||
assertNotNull(response); | ||
assertEquals(expected, response); | ||
} | ||
|
||
@Requires(property = "spec.name", value = "JsonMergePatchTest") | ||
@Controller("/json-merge-patch") | ||
static class JsonMergePatchController { | ||
@Consumes(MediaType.APPLICATION_JSON_MERGE_PATCH) | ||
@Produces(MediaType.APPLICATION_JSON_MERGE_PATCH) | ||
@Patch | ||
MergePatch mergePatch(@Body MergePatch body) { | ||
return body; | ||
} | ||
} | ||
|
||
@Introspected | ||
record MergePatch(String f, String b) { | ||
} | ||
} |