#1608 - HAL FORMS templates now expose HTTP method in all caps.

See the RFC for details: https://www.w3.org/Protocols/rfc2616/rfc2616-sec5.html#sec5.1.1.
This commit is contained in:
Oliver Drotbohm
2021-09-16 14:53:00 +02:00
parent f9274a692e
commit 60e7f2e04e
7 changed files with 20 additions and 15 deletions

View File

@@ -130,7 +130,7 @@ final class HalFormsTemplate {
@Nullable
String getMethod() {
return this.httpMethod == null ? null : this.httpMethod.toString().toLowerCase();
return this.httpMethod == null ? null : this.httpMethod.name();
}
void setMethod(String method) {

View File

@@ -225,6 +225,11 @@ class HalFormsTemplateBuilderUnitTest {
});
}
@Test // #1608
void exposesHttpMethodInAllCaps() {
assertThat(HalFormsTemplate.forMethod(HttpMethod.POST).getMethod()).isEqualTo("POST");
}
@Getter
static class PatternExample extends RepresentationModel<PatternExample> {

View File

@@ -80,13 +80,13 @@ class HalFormsWebFluxIntegrationTest {
.value(jsonPath("$._links['employees'].href", is("http://localhost/employees"))) //
.value(jsonPath("$._templates.*", hasSize(2))) //
.value(jsonPath("$._templates['default'].method", is("put"))) //
.value(jsonPath("$._templates['default'].method", is("PUT"))) //
.value(jsonPath("$._templates['default'].properties[0].name", is("name"))) //
.value(jsonPath("$._templates['default'].properties[0].required", is(true))) //
.value(jsonPath("$._templates['default'].properties[1].name", is("role"))) //
.value(jsonPath("$._templates['default'].properties[1].required").doesNotExist()) //
.value(jsonPath("$._templates['partiallyUpdateEmployee'].method", is("patch"))) //
.value(jsonPath("$._templates['partiallyUpdateEmployee'].method", is("PATCH"))) //
.value(jsonPath("$._templates['partiallyUpdateEmployee'].properties[0].name", is("name"))) //
.value(jsonPath("$._templates['partiallyUpdateEmployee'].properties[0].required").doesNotExist()) //
.value(jsonPath("$._templates['partiallyUpdateEmployee'].properties[1].name", is("role"))) //
@@ -111,7 +111,7 @@ class HalFormsWebFluxIntegrationTest {
.value(jsonPath("$._links.*", hasSize(1)))
.value(jsonPath("$._links['self'].href", is("http://localhost/employees")))
.value(jsonPath("$._templates.*", hasSize(1))).value(jsonPath("$._templates['default'].method", is("post")))
.value(jsonPath("$._templates.*", hasSize(1))).value(jsonPath("$._templates['default'].method", is("POST")))
.value(jsonPath("$._templates['default'].properties[0].name", is("name")))
.value(jsonPath("$._templates['default'].properties[0].required", is(true)))
.value(jsonPath("$._templates['default'].properties[1].name", is("role")))

View File

@@ -76,13 +76,13 @@ class HalFormsWebMvcIntegrationTest {
.andExpect(jsonPath("$._links['employees'].href", is("http://localhost/employees")))
.andExpect(jsonPath("$._templates.*", hasSize(2)))
.andExpect(jsonPath("$._templates['default'].method", is("put")))
.andExpect(jsonPath("$._templates['default'].method", is("PUT")))
.andExpect(jsonPath("$._templates['default'].properties[0].name", is("name")))
.andExpect(jsonPath("$._templates['default'].properties[0].required").value(true))
.andExpect(jsonPath("$._templates['default'].properties[1].name", is("role")))
.andExpect(jsonPath("$._templates['default'].properties[1].required").doesNotExist())
.andExpect(jsonPath("$._templates['partiallyUpdateEmployee'].method", is("patch")))
.andExpect(jsonPath("$._templates['partiallyUpdateEmployee'].method", is("PATCH")))
.andExpect(jsonPath("$._templates['partiallyUpdateEmployee'].properties[0].name", is("name")))
.andExpect(jsonPath("$._templates['partiallyUpdateEmployee'].properties[0].required").doesNotExist())
.andExpect(jsonPath("$._templates['partiallyUpdateEmployee'].properties[1].name", is("role")))
@@ -105,7 +105,7 @@ class HalFormsWebMvcIntegrationTest {
.andExpect(jsonPath("$._links['self'].href", is("http://localhost/employees")))
.andExpect(jsonPath("$._templates.*", hasSize(1)))
.andExpect(jsonPath("$._templates['default'].method", is("post")))
.andExpect(jsonPath("$._templates['default'].method", is("POST")))
.andExpect(jsonPath("$._templates['default'].properties[0].name", is("name")))
.andExpect(jsonPath("$._templates['default'].properties[0].required").value(true))
.andExpect(jsonPath("$._templates['default'].properties[1].name", is("role")))

View File

@@ -208,8 +208,8 @@ class MultiMediaTypeWebMvcIntegrationTest {
.andExpect(jsonPath("$._links['employees'].href", is("http://localhost/employees")));
expectEmployeeProperties(actions, "default", "partiallyUpdateEmployee") //
.andExpect(jsonPath("$._templates['default'].method", is("put")))
.andExpect(jsonPath("$._templates['partiallyUpdateEmployee'].method", is("patch")));
.andExpect(jsonPath("$._templates['default'].method", is("PUT")))
.andExpect(jsonPath("$._templates['partiallyUpdateEmployee'].method", is("PATCH")));
}
@Test
@@ -227,7 +227,7 @@ class MultiMediaTypeWebMvcIntegrationTest {
.andExpect(jsonPath("$._links.*", hasSize(1)))
.andExpect(jsonPath("$._links['self'].href", is("http://localhost/employees")))
.andExpect(jsonPath("$._templates['default'].method", is("post")));
.andExpect(jsonPath("$._templates['default'].method", is("POST")));
expectEmployeeProperties(actions, "default");
}
@@ -251,8 +251,8 @@ class MultiMediaTypeWebMvcIntegrationTest {
expectEmployeeProperties(actions, "default", "partiallyUpdateEmployee") //
.andExpect(jsonPath("$._templates['default'].method", is("put")))
.andExpect(jsonPath("$._templates['partiallyUpdateEmployee'].method", is("patch")));
.andExpect(jsonPath("$._templates['default'].method", is("PUT")))
.andExpect(jsonPath("$._templates['partiallyUpdateEmployee'].method", is("PATCH")));
}
@Test

View File

@@ -7,7 +7,7 @@
},
"_templates" : {
"default" : {
"method" : "post",
"method" : "POST",
"properties" : [ {
"name" : "name",
"type" : "text"

View File

@@ -11,7 +11,7 @@
},
"_templates" : {
"default" : {
"method" : "put",
"method" : "PUT",
"properties" : [ {
"name" : "name",
"required" : true,
@@ -22,7 +22,7 @@
} ]
},
"partiallyUpdateEmployee" : {
"method" : "patch",
"method" : "PATCH",
"properties" : [ {
"name" : "name",
"type" : "text"