From 60663f5be357db1b35fdc0e0f289335859c6c5b9 Mon Sep 17 00:00:00 2001 From: Julian Psotta Date: Fri, 20 Oct 2023 12:09:34 +0200 Subject: [PATCH] test: Add another missing test case --- .../listeners/ORSInitContextListenerTest.java | 27 ++++++++++++------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/ors-api/src/test/java/org/heigit/ors/api/servlet/listeners/ORSInitContextListenerTest.java b/ors-api/src/test/java/org/heigit/ors/api/servlet/listeners/ORSInitContextListenerTest.java index 4a13517f73..f92bfa2701 100644 --- a/ors-api/src/test/java/org/heigit/ors/api/servlet/listeners/ORSInitContextListenerTest.java +++ b/ors-api/src/test/java/org/heigit/ors/api/servlet/listeners/ORSInitContextListenerTest.java @@ -5,6 +5,7 @@ import org.junit.jupiter.params.provider.CsvSource; import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNull; class ORSInitContextListenerTest { @@ -16,16 +17,24 @@ void setUp(){ } @ParameterizedTest @CsvSource(value = { - "https://example.com/foo1/foo2/foo3/test-repo, https://example.com, test-repo", - "https://example.com/test-repo/, https://example.com, test-repo", - "https://example.com/test-repo, https://example.com, test-repo", - "' https://example.com/test-repo ', https://example.com, test-repo", - "https://example.com/test-repos/, https://example.com, test-repos", - "http://example.com/test-repo/, http://example.com, test-repo" + "https://example.com/foo1/foo2/foo3/test-repo, https://example.com, test-repo, true", + "https://example.com/test-repo/, https://example.com, test-repo, true", + "https://example.com/test-repo, https://example.com, test-repo, true", + "' https://example.com/test-repo ', https://example.com, test-repo, true", + "https://example.com/test-repos/, https://example.com, test-repos, true", + "http://example.com/test-repo/, http://example.com, test-repo, true", + "/foo/test-repo/, null, null, false" }) - void extractSourceFileElements_withURL(String url, String expectedBaseUrl, String expectedRepoName){ + void extractSourceFileElements_withURL(String url, String expectedBaseUrl, String expectedRepoName, Boolean isUrl){ ORSInitContextListener.SourceFileElements elements = orsInitContextListener.extractSourceFileElements(url); - assertEquals(expectedBaseUrl, elements.repoBaseUrlString()); - assertEquals(expectedRepoName, elements.repoName()); + if (isUrl) { + assertEquals(expectedBaseUrl, elements.repoBaseUrlString()); + assertEquals(expectedRepoName, elements.repoName()); + assertEquals("", elements.localOsmFilePath()); + } else { + assertEquals(url, elements.localOsmFilePath()); + assertNull(elements.repoBaseUrlString()); + assertNull(elements.repoName()); + } } } \ No newline at end of file