From da0a8b8b2471c91fe62e86d27378708160292c9d Mon Sep 17 00:00:00 2001 From: Martin Lippert Date: Tue, 11 Feb 2025 09:04:16 +0100 Subject: [PATCH] GH-1463: added test case for string concatenation with request mappings from parent classes with attribute names --- .../test/RequestMappingSymbolProviderTest.java | 8 ++++++++ ...romParentWithStringConcatenationPerAttribute.java | 12 ++++++++++++ ...ppingPathWithStringConcatenationPerAttribute.java | 7 +++++++ 3 files changed, 27 insertions(+) create mode 100644 headless-services/spring-boot-language-server/src/test/resources/test-projects/test-request-mapping-symbols/src/main/java/org/test/inheritance/SubclassWithMappingFromParentWithStringConcatenationPerAttribute.java create mode 100644 headless-services/spring-boot-language-server/src/test/resources/test-projects/test-request-mapping-symbols/src/main/java/org/test/inheritance/SuperclassWithMappingPathWithStringConcatenationPerAttribute.java diff --git a/headless-services/spring-boot-language-server/src/test/java/org/springframework/ide/vscode/boot/java/requestmapping/test/RequestMappingSymbolProviderTest.java b/headless-services/spring-boot-language-server/src/test/java/org/springframework/ide/vscode/boot/java/requestmapping/test/RequestMappingSymbolProviderTest.java index c1a64f8f0..6d72468dd 100644 --- a/headless-services/spring-boot-language-server/src/test/java/org/springframework/ide/vscode/boot/java/requestmapping/test/RequestMappingSymbolProviderTest.java +++ b/headless-services/spring-boot-language-server/src/test/java/org/springframework/ide/vscode/boot/java/requestmapping/test/RequestMappingSymbolProviderTest.java @@ -257,6 +257,14 @@ public class RequestMappingSymbolProviderTest { assertTrue(containsSymbol(symbols, "@/superpath/subclass", docUri, 6, 1, 6, 34)); } + @Test + void testMappingPathFromSuperclassWithStringConcatenationPerAttribute() throws Exception { + String docUri = directory.toPath().resolve("src/main/java/org/test/inheritance/SubclassWithMappingFromParentWithStringConcatenationPerAttribute.java").toUri().toString(); + List symbols = indexer.getSymbols(docUri); + assertEquals(1, symbols.size()); + assertTrue(containsSymbol(symbols, "@/superpath/subclass", docUri, 6, 1, 6, 42)); + } + @Test void testMappingPathFromSuperclassWithMethodsAndPathAttribute() throws Exception { String docUri = directory.toPath().resolve("src/main/java/org/test/inheritance/SubclassWithMappingFromParentWithMethods.java").toUri().toString(); diff --git a/headless-services/spring-boot-language-server/src/test/resources/test-projects/test-request-mapping-symbols/src/main/java/org/test/inheritance/SubclassWithMappingFromParentWithStringConcatenationPerAttribute.java b/headless-services/spring-boot-language-server/src/test/resources/test-projects/test-request-mapping-symbols/src/main/java/org/test/inheritance/SubclassWithMappingFromParentWithStringConcatenationPerAttribute.java new file mode 100644 index 000000000..fa7afc684 --- /dev/null +++ b/headless-services/spring-boot-language-server/src/test/resources/test-projects/test-request-mapping-symbols/src/main/java/org/test/inheritance/SubclassWithMappingFromParentWithStringConcatenationPerAttribute.java @@ -0,0 +1,12 @@ +package org.test.inheritance; + +import org.springframework.web.bind.annotation.RequestMapping; + +public class SubclassWithMappingFromParentWithStringConcatenationPerAttribute extends SuperclassWithMappingPathWithStringConcatenationPerAttribute { + + @RequestMapping(value = "/sub" + "class") + public String hello() { + return "Hello"; + } + +} diff --git a/headless-services/spring-boot-language-server/src/test/resources/test-projects/test-request-mapping-symbols/src/main/java/org/test/inheritance/SuperclassWithMappingPathWithStringConcatenationPerAttribute.java b/headless-services/spring-boot-language-server/src/test/resources/test-projects/test-request-mapping-symbols/src/main/java/org/test/inheritance/SuperclassWithMappingPathWithStringConcatenationPerAttribute.java new file mode 100644 index 000000000..cac49d567 --- /dev/null +++ b/headless-services/spring-boot-language-server/src/test/resources/test-projects/test-request-mapping-symbols/src/main/java/org/test/inheritance/SuperclassWithMappingPathWithStringConcatenationPerAttribute.java @@ -0,0 +1,7 @@ +package org.test.inheritance; + +import org.springframework.web.bind.annotation.RequestMapping; + +@RequestMapping(path = "/super" + "path") +public class SuperclassWithMappingPathWithStringConcatenationPerAttribute { +}