Allow UriTemplate to be built with an empty template
See gh-32432
This commit is contained in:
committed by
Stéphane Nicoll
parent
723c94e5ac
commit
1b25a1506a
@@ -66,7 +66,7 @@ public class UriTemplate implements Serializable {
|
||||
* @param uriTemplate the URI template string
|
||||
*/
|
||||
public UriTemplate(String uriTemplate) {
|
||||
Assert.hasText(uriTemplate, "'uriTemplate' must not be null");
|
||||
Assert.notNull(uriTemplate, "'uriTemplate' must not be null");
|
||||
this.uriTemplate = uriTemplate;
|
||||
this.uriComponents = UriComponentsBuilder.fromUriString(uriTemplate).build();
|
||||
|
||||
|
||||
@@ -27,6 +27,7 @@ import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
|
||||
import static org.assertj.core.api.Assertions.assertThatNoException;
|
||||
|
||||
/**
|
||||
* @author Arjen Poutsma
|
||||
@@ -218,4 +219,14 @@ class UriTemplateTests {
|
||||
assertThat(uri.toString()).isEqualTo("http://localhost/query=foo@bar");
|
||||
}
|
||||
|
||||
@Test
|
||||
void emptyPathDoesNotThrowException() {
|
||||
assertThatNoException().isThrownBy(() -> new UriTemplate(""));
|
||||
}
|
||||
|
||||
@Test
|
||||
void emptyPathThrowsException() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> new UriTemplate(null));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user