Add test for passing @MatrixVariable without specified name. Add documentation for @MatrixVariable support. Fixes gh-307.

This commit is contained in:
Olga Maciaszek-Sharma
2020-03-20 19:58:47 +01:00
parent cd1cead7fd
commit db2e84ef06
2 changed files with 50 additions and 0 deletions

View File

@@ -554,6 +554,22 @@ public class SpringMvcContractTests {
.isEqualTo(data.indexToExpander().get(0).expand("value"));
}
@Test
public void testMatrixVariableWithNoName() throws NoSuchMethodException {
Method method = TestTemplate_MatrixVariable.class
.getDeclaredMethod("matrixVariableNotNamed", Map.class);
MethodMetadata data = this.contract
.parseAndValidateMetadata(method.getDeclaringClass(), method);
Map<String, String> testMap = new HashMap<>();
testMap.put("param", "value");
assertThat(data.template().method()).isEqualTo("GET");
assertThat(data.template().url()).isEqualTo("/matrixVariable/{params}");
assertThat(";param=value")
.isEqualTo(data.indexToExpander().get(0).expand(testMap));
}
@Test
public void testAddingTemplatedParameterWithTheSameKey()
throws NoSuchMethodException {
@@ -697,6 +713,9 @@ public class SpringMvcContractTests {
@RequestMapping(path = "/matrixVariableObject/{param}")
String matrixVariableObject(@MatrixVariable("param") Object object);
@RequestMapping(path = "/matrixVariable/{params}")
String matrixVariableNotNamed(@MatrixVariable Map<String, Object> params);
}
@JsonAutoDetect