|
|
|
|
@ -53,6 +53,13 @@ class UriTemplateTests {
@@ -53,6 +53,13 @@ class UriTemplateTests {
|
|
|
|
|
assertThat(variableNames).as("Invalid variable names").isEqualTo(Arrays.asList("hotel", "booking")); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
void getVariableNamesFromEmpty() { |
|
|
|
|
UriTemplate template = new UriTemplate(""); |
|
|
|
|
List<String> variableNames = template.getVariableNames(); |
|
|
|
|
assertThat(variableNames).isEmpty(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
void expandVarArgs() { |
|
|
|
|
UriTemplate template = new UriTemplate("/hotels/{hotel}/bookings/{booking}"); |
|
|
|
|
@ -60,6 +67,13 @@ class UriTemplateTests {
@@ -60,6 +67,13 @@ class UriTemplateTests {
|
|
|
|
|
assertThat(result).as("Invalid expanded template").isEqualTo(URI.create("/hotels/1/bookings/42")); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
void expandVarArgsFromEmpty() { |
|
|
|
|
UriTemplate template = new UriTemplate(""); |
|
|
|
|
URI result = template.expand(); |
|
|
|
|
assertThat(result).as("Invalid expanded template").isEqualTo(URI.create("")); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test // SPR-9712
|
|
|
|
|
void expandVarArgsWithArrayValue() { |
|
|
|
|
UriTemplate template = new UriTemplate("/sum?numbers={numbers}"); |
|
|
|
|
@ -135,6 +149,15 @@ class UriTemplateTests {
@@ -135,6 +149,15 @@ class UriTemplateTests {
|
|
|
|
|
assertThat(template.matches(null)).as("UriTemplate matches").isFalse(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
void matchesAgainstEmpty() { |
|
|
|
|
UriTemplate template = new UriTemplate(""); |
|
|
|
|
assertThat(template.matches("/hotels/1/bookings/42")).as("UriTemplate matches").isFalse(); |
|
|
|
|
assertThat(template.matches("/hotels/bookings")).as("UriTemplate matches").isFalse(); |
|
|
|
|
assertThat(template.matches("")).as("UriTemplate does not match").isTrue(); |
|
|
|
|
assertThat(template.matches(null)).as("UriTemplate matches").isFalse(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
void matchesCustomRegex() { |
|
|
|
|
UriTemplate template = new UriTemplate("/hotels/{hotel:\\d+}"); |
|
|
|
|
@ -153,6 +176,13 @@ class UriTemplateTests {
@@ -153,6 +176,13 @@ class UriTemplateTests {
|
|
|
|
|
assertThat(result).as("Invalid match").isEqualTo(expected); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
void matchAgainstEmpty() { |
|
|
|
|
UriTemplate template = new UriTemplate(""); |
|
|
|
|
Map<String, String> result = template.match("/hotels/1/bookings/42"); |
|
|
|
|
assertThat(result).as("Invalid match").isEmpty(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
void matchCustomRegex() { |
|
|
|
|
Map<String, String> expected = new HashMap<>(2); |
|
|
|
|
|