PathApiVersionResolver is not nullable

Closes gh-35265
This commit is contained in:
rstoyanchev
2025-07-31 15:31:58 +01:00
parent da361699a4
commit 87838aa4c5
8 changed files with 70 additions and 34 deletions
@@ -22,6 +22,7 @@ import org.springframework.web.testfixture.servlet.MockHttpServletRequest;
import org.springframework.web.util.ServletRequestPathUtils;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
/**
* Unit tests for {@link PathApiVersionResolver}.
@@ -35,6 +36,11 @@ public class PathApiVersionResolverTests {
testResolve(1, "/app/1.1/path", "1.1");
}
@Test
void insufficientPathSegments() {
assertThatThrownBy(() -> testResolve(0, "/", "1.0")).isInstanceOf(InvalidApiVersionException.class);
}
private static void testResolve(int index, String requestUri, String expected) {
MockHttpServletRequest request = new MockHttpServletRequest("GET", requestUri);
try {