Refine request mappings
This commit is contained in:
@@ -132,4 +132,802 @@ public class RequestMappingLiveHoverTest {
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDeleteMappingHoverHintMethod1() throws Exception {
|
||||
|
||||
File directory = new File(
|
||||
ProjectsHarness.class.getResource("/test-projects/test-request-mapping-live-hover/").toURI());
|
||||
String docUri = "file://" +directory.getAbsolutePath() + "/src/main/java/example/RestApi.java";
|
||||
|
||||
|
||||
// Build a mock running boot app
|
||||
mockAppProvider.builder()
|
||||
.isSpringBootApp(true)
|
||||
.port("999")
|
||||
.processId("76543")
|
||||
.host("cfapps.io")
|
||||
.processName("test-request-mapping-live-hover")
|
||||
// Ugly, but this is real JSON copied from a real live running app. We want the
|
||||
// mock app to return realistic results if possible
|
||||
.getRequestMappings(
|
||||
"{\"{[/greetings],methods=[DELETE]}\": {\"bean\": \"requestMappingHandlerMapping\", \"method\":\"public void com.example.RestApi.deleteGreetings()\"}}")
|
||||
. build();
|
||||
|
||||
harness.intialize(directory);
|
||||
|
||||
Editor editor = harness.newEditor(LanguageId.JAVA,
|
||||
"package com.example;\n" +
|
||||
"\n" +
|
||||
"import org.springframework.stereotype.Controller;\n" +
|
||||
"import org.springframework.web.bind.annotation.DeleteMapping;\n" +
|
||||
"\n" +
|
||||
"@Controller\n" +
|
||||
"public class RestApi {\n" +
|
||||
"\n" +
|
||||
"@DeleteMapping(\"/greetings\")\n" +
|
||||
"public void deleteGreetings() {\n" +
|
||||
"}\n" +
|
||||
"\n" +
|
||||
"}",
|
||||
docUri);
|
||||
|
||||
editor.assertHoverContains("@DeleteMapping(\"/greetings\")", "Path: [/greetings](http://cfapps.io:999/greetings)\n" +
|
||||
"\n" +
|
||||
"Process ID: 76543\n" +
|
||||
"\n" +
|
||||
"Process Name: test-request-mapping-live-hover");
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testDeleteMappingHoverHintMethod2() throws Exception {
|
||||
|
||||
File directory = new File(
|
||||
ProjectsHarness.class.getResource("/test-projects/test-request-mapping-live-hover/").toURI());
|
||||
String docUri = "file://" +directory.getAbsolutePath() + "/src/main/java/example/RestApi.java";
|
||||
|
||||
|
||||
// Build a mock running boot app
|
||||
mockAppProvider.builder()
|
||||
.isSpringBootApp(true)
|
||||
.port("999")
|
||||
.processId("76543")
|
||||
.host("cfapps.io")
|
||||
.processName("test-request-mapping-live-hover")
|
||||
// Ugly, but this is real JSON copied from a real live running app. We want the
|
||||
// mock app to return realistic results if possible
|
||||
.getRequestMappings(
|
||||
"{\"{[/greetings],methods=[GET]}\": {\"bean\": \"requestMappingHandlerMapping\", \"method\":\"public java.lang.String com.example.RestApi.deleteGreetings()\"}}")
|
||||
. build();
|
||||
|
||||
harness.intialize(directory);
|
||||
|
||||
Editor editor = harness.newEditor(LanguageId.JAVA,
|
||||
"package com.example;\n" +
|
||||
"\n" +
|
||||
"import org.springframework.stereotype.Controller;\n" +
|
||||
"import org.springframework.web.bind.annotation.DeleteMapping;\n" +
|
||||
"\n" +
|
||||
"@Controller\n" +
|
||||
"public class RestApi {\n" +
|
||||
"\n" +
|
||||
"@DeleteMapping(\"/greetings\")\n" +
|
||||
"public void deleteGreetings() {\n" +
|
||||
"}\n" +
|
||||
"\n" +
|
||||
"}",
|
||||
docUri);
|
||||
|
||||
editor.assertNoHover("@DeleteMapping(\"/greetings\")");
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetMappingHoverHintMethod1() throws Exception {
|
||||
|
||||
File directory = new File(
|
||||
ProjectsHarness.class.getResource("/test-projects/test-request-mapping-live-hover/").toURI());
|
||||
String docUri = "file://" +directory.getAbsolutePath() + "/src/main/java/example/RestApi.java";
|
||||
|
||||
|
||||
// Build a mock running boot app
|
||||
mockAppProvider.builder()
|
||||
.isSpringBootApp(true)
|
||||
.port("999")
|
||||
.processId("76543")
|
||||
.host("cfapps.io")
|
||||
.processName("test-request-mapping-live-hover")
|
||||
// Ugly, but this is real JSON copied from a real live running app. We want the
|
||||
// mock app to return realistic results if possible
|
||||
.getRequestMappings(
|
||||
"{\"{[/greetings],methods=[GET]}\": {\"bean\": \"requestMappingHandlerMapping\", \"method\":\"public java.lang.String com.example.RestApi.greetings()\"}}")
|
||||
. build();
|
||||
|
||||
harness.intialize(directory);
|
||||
|
||||
Editor editor = harness.newEditor(LanguageId.JAVA,
|
||||
"package com.example;\n" +
|
||||
"\n" +
|
||||
"import java.lang.String;\n" +
|
||||
"import org.springframework.stereotype.Controller;\n" +
|
||||
"import org.springframework.web.bind.annotation.GetMapping;\n" +
|
||||
"\n" +
|
||||
"@Controller\n" +
|
||||
"public class RestApi {\n" +
|
||||
"\n" +
|
||||
"@GetMapping(\"/greetings\")\n" +
|
||||
"public String greetings() {\n" +
|
||||
"return \"Greetings!\";\n" +
|
||||
"}\n" +
|
||||
"\n" +
|
||||
"}",
|
||||
docUri);
|
||||
|
||||
editor.assertHoverContains("@GetMapping(\"/greetings\")", "Path: [/greetings](http://cfapps.io:999/greetings)\n" +
|
||||
"\n" +
|
||||
"Process ID: 76543\n" +
|
||||
"\n" +
|
||||
"Process Name: test-request-mapping-live-hover");
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetMappingHoverHintMethod2() throws Exception {
|
||||
|
||||
File directory = new File(
|
||||
ProjectsHarness.class.getResource("/test-projects/test-request-mapping-live-hover/").toURI());
|
||||
String docUri = "file://" +directory.getAbsolutePath() + "/src/main/java/example/RestApi.java";
|
||||
|
||||
|
||||
// Build a mock running boot app
|
||||
mockAppProvider.builder()
|
||||
.isSpringBootApp(true)
|
||||
.port("999")
|
||||
.processId("76543")
|
||||
.host("cfapps.io")
|
||||
.processName("test-request-mapping-live-hover")
|
||||
// Ugly, but this is real JSON copied from a real live running app. We want the
|
||||
// mock app to return realistic results if possible
|
||||
.getRequestMappings(
|
||||
"{\"{[/greetings],methods=[DELETE]}\": {\"bean\": \"requestMappingHandlerMapping\", \"method\":\"public java.lang.String com.example.RestApi.greetings()\"}}")
|
||||
. build();
|
||||
|
||||
harness.intialize(directory);
|
||||
|
||||
Editor editor = harness.newEditor(LanguageId.JAVA,
|
||||
"package com.example;\n" +
|
||||
"\n" +
|
||||
"import java.lang.String;\n" +
|
||||
"import org.springframework.stereotype.Controller;\n" +
|
||||
"import org.springframework.web.bind.annotation.GetMapping;\n" +
|
||||
"\n" +
|
||||
"@Controller\n" +
|
||||
"public class RestApi {\n" +
|
||||
"\n" +
|
||||
"@GetMapping(\"/greetings\")\n" +
|
||||
"public String greetings() {\n" +
|
||||
"return \"Greetings!\";\n" +
|
||||
"}\n" +
|
||||
"\n" +
|
||||
"}",
|
||||
docUri);
|
||||
|
||||
editor.assertNoHover("@GetMapping(\"/greetings\")");
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPostMappingHoverHintMethod1() throws Exception {
|
||||
|
||||
File directory = new File(
|
||||
ProjectsHarness.class.getResource("/test-projects/test-request-mapping-live-hover/").toURI());
|
||||
String docUri = "file://" +directory.getAbsolutePath() + "/src/main/java/example/RestApi.java";
|
||||
|
||||
|
||||
// Build a mock running boot app
|
||||
mockAppProvider.builder()
|
||||
.isSpringBootApp(true)
|
||||
.port("999")
|
||||
.processId("76543")
|
||||
.host("cfapps.io")
|
||||
.processName("test-request-mapping-live-hover")
|
||||
// Ugly, but this is real JSON copied from a real live running app. We want the
|
||||
// mock app to return realistic results if possible
|
||||
.getRequestMappings(
|
||||
"{\"{[/greetings],methods=[POST]}\": {\"bean\": \"requestMappingHandlerMapping\", \"method\":\"public void com.example.RestApi.createGreetings()\"}}")
|
||||
. build();
|
||||
|
||||
harness.intialize(directory);
|
||||
|
||||
Editor editor = harness.newEditor(LanguageId.JAVA,
|
||||
"package com.example;\n" +
|
||||
"\n" +
|
||||
"import org.springframework.stereotype.Controller;\n" +
|
||||
"import org.springframework.web.bind.annotation.PostMapping;\n" +
|
||||
"\n" +
|
||||
"@Controller\n" +
|
||||
"public class RestApi {\n" +
|
||||
"\n" +
|
||||
"@PostMapping(\"/greetings\")\n" +
|
||||
"public void createGreetings() {\n" +
|
||||
"}\n" +
|
||||
"\n" +
|
||||
"}",
|
||||
docUri);
|
||||
|
||||
editor.assertHoverContains("@PostMapping(\"/greetings\")", "Path: [/greetings](http://cfapps.io:999/greetings)\n" +
|
||||
"\n" +
|
||||
"Process ID: 76543\n" +
|
||||
"\n" +
|
||||
"Process Name: test-request-mapping-live-hover");
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPostMappingHoverHintMethod2() throws Exception {
|
||||
|
||||
File directory = new File(
|
||||
ProjectsHarness.class.getResource("/test-projects/test-request-mapping-live-hover/").toURI());
|
||||
String docUri = "file://" +directory.getAbsolutePath() + "/src/main/java/example/RestApi.java";
|
||||
|
||||
|
||||
// Build a mock running boot app
|
||||
mockAppProvider.builder()
|
||||
.isSpringBootApp(true)
|
||||
.port("999")
|
||||
.processId("76543")
|
||||
.host("cfapps.io")
|
||||
.processName("test-request-mapping-live-hover")
|
||||
// Ugly, but this is real JSON copied from a real live running app. We want the
|
||||
// mock app to return realistic results if possible
|
||||
.getRequestMappings(
|
||||
"{\"{[/greetings],methods=[GET]}\": {\"bean\": \"requestMappingHandlerMapping\", \"method\":\"public java.lang.String com.example.RestApi.createGreetings()\"}}")
|
||||
. build();
|
||||
|
||||
harness.intialize(directory);
|
||||
|
||||
Editor editor = harness.newEditor(LanguageId.JAVA,
|
||||
"package com.example;\n" +
|
||||
"\n" +
|
||||
"import org.springframework.stereotype.Controller;\n" +
|
||||
"import org.springframework.web.bind.annotation.PostMapping;\n" +
|
||||
"\n" +
|
||||
"@Controller\n" +
|
||||
"public class RestApi {\n" +
|
||||
"\n" +
|
||||
"@PostMapping(\"/greetings\")\n" +
|
||||
"public void createGreetings() {\n" +
|
||||
"}\n" +
|
||||
"\n" +
|
||||
"}",
|
||||
docUri);
|
||||
|
||||
editor.assertNoHover("@PostMapping(\"/greetings\")");
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPutMappingHoverHintMethod1() throws Exception {
|
||||
|
||||
File directory = new File(
|
||||
ProjectsHarness.class.getResource("/test-projects/test-request-mapping-live-hover/").toURI());
|
||||
String docUri = "file://" +directory.getAbsolutePath() + "/src/main/java/example/RestApi.java";
|
||||
|
||||
|
||||
// Build a mock running boot app
|
||||
mockAppProvider.builder()
|
||||
.isSpringBootApp(true)
|
||||
.port("999")
|
||||
.processId("76543")
|
||||
.host("cfapps.io")
|
||||
.processName("test-request-mapping-live-hover")
|
||||
// Ugly, but this is real JSON copied from a real live running app. We want the
|
||||
// mock app to return realistic results if possible
|
||||
.getRequestMappings(
|
||||
"{\"{[/greetings],methods=[PUT]}\": {\"bean\": \"requestMappingHandlerMapping\", \"method\":\"public void com.example.RestApi.updateGreetings()\"}}")
|
||||
. build();
|
||||
|
||||
harness.intialize(directory);
|
||||
|
||||
Editor editor = harness.newEditor(LanguageId.JAVA,
|
||||
"package com.example;\n" +
|
||||
"\n" +
|
||||
"import org.springframework.stereotype.Controller;\n" +
|
||||
"import org.springframework.web.bind.annotation.PutMapping;\n" +
|
||||
"\n" +
|
||||
"@Controller\n" +
|
||||
"public class RestApi {\n" +
|
||||
"\n" +
|
||||
"@PutMapping(\"/greetings\")\n" +
|
||||
"public void updateGreetings() {\n" +
|
||||
"}\n" +
|
||||
"\n" +
|
||||
"}",
|
||||
docUri);
|
||||
|
||||
editor.assertHoverContains("@PutMapping(\"/greetings\")", "Path: [/greetings](http://cfapps.io:999/greetings)\n" +
|
||||
"\n" +
|
||||
"Process ID: 76543\n" +
|
||||
"\n" +
|
||||
"Process Name: test-request-mapping-live-hover");
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPutMappingHoverHintMethod2() throws Exception {
|
||||
|
||||
File directory = new File(
|
||||
ProjectsHarness.class.getResource("/test-projects/test-request-mapping-live-hover/").toURI());
|
||||
String docUri = "file://" +directory.getAbsolutePath() + "/src/main/java/example/RestApi.java";
|
||||
|
||||
|
||||
// Build a mock running boot app
|
||||
mockAppProvider.builder()
|
||||
.isSpringBootApp(true)
|
||||
.port("999")
|
||||
.processId("76543")
|
||||
.host("cfapps.io")
|
||||
.processName("test-request-mapping-live-hover")
|
||||
// Ugly, but this is real JSON copied from a real live running app. We want the
|
||||
// mock app to return realistic results if possible
|
||||
.getRequestMappings(
|
||||
"{\"{[/greetings],methods=[GET]}\": {\"bean\": \"requestMappingHandlerMapping\", \"method\":\"public java.lang.String com.example.RestApi.updateGreetings()\"}}")
|
||||
. build();
|
||||
|
||||
harness.intialize(directory);
|
||||
|
||||
Editor editor = harness.newEditor(LanguageId.JAVA,
|
||||
"package com.example;\n" +
|
||||
"\n" +
|
||||
"import org.springframework.stereotype.Controller;\n" +
|
||||
"import org.springframework.web.bind.annotation.PutMapping;\n" +
|
||||
"\n" +
|
||||
"@Controller\n" +
|
||||
"public class RestApi {\n" +
|
||||
"\n" +
|
||||
"@PutMapping(\"/greetings\")\n" +
|
||||
"public void updateGreetings() {\n" +
|
||||
"}\n" +
|
||||
"\n" +
|
||||
"}",
|
||||
docUri);
|
||||
|
||||
editor.assertNoHover("@PutMapping(\"/greetings\")");
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPatchMappingHoverHintMethod1() throws Exception {
|
||||
|
||||
File directory = new File(
|
||||
ProjectsHarness.class.getResource("/test-projects/test-request-mapping-live-hover/").toURI());
|
||||
String docUri = "file://" +directory.getAbsolutePath() + "/src/main/java/example/RestApi.java";
|
||||
|
||||
|
||||
// Build a mock running boot app
|
||||
mockAppProvider.builder()
|
||||
.isSpringBootApp(true)
|
||||
.port("999")
|
||||
.processId("76543")
|
||||
.host("cfapps.io")
|
||||
.processName("test-request-mapping-live-hover")
|
||||
// Ugly, but this is real JSON copied from a real live running app. We want the
|
||||
// mock app to return realistic results if possible
|
||||
.getRequestMappings(
|
||||
"{\"{[/greetings],methods=[PATCH]}\": {\"bean\": \"requestMappingHandlerMapping\", \"method\":\"public void com.example.RestApi.patchGreetings()\"}}")
|
||||
. build();
|
||||
|
||||
harness.intialize(directory);
|
||||
|
||||
Editor editor = harness.newEditor(LanguageId.JAVA,
|
||||
"package com.example;\n" +
|
||||
"\n" +
|
||||
"import org.springframework.stereotype.Controller;\n" +
|
||||
"import org.springframework.web.bind.annotation.PatchMapping;\n" +
|
||||
"\n" +
|
||||
"@Controller\n" +
|
||||
"public class RestApi {\n" +
|
||||
"\n" +
|
||||
"@PatchMapping(\"/greetings\")\n" +
|
||||
"public void patchGreetings() {\n" +
|
||||
"}\n" +
|
||||
"\n" +
|
||||
"}",
|
||||
docUri);
|
||||
|
||||
editor.assertHoverContains("@PatchMapping(\"/greetings\")", "Path: [/greetings](http://cfapps.io:999/greetings)\n" +
|
||||
"\n" +
|
||||
"Process ID: 76543\n" +
|
||||
"\n" +
|
||||
"Process Name: test-request-mapping-live-hover");
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPatchMappingHoverHintMethod2() throws Exception {
|
||||
|
||||
File directory = new File(
|
||||
ProjectsHarness.class.getResource("/test-projects/test-request-mapping-live-hover/").toURI());
|
||||
String docUri = "file://" +directory.getAbsolutePath() + "/src/main/java/example/RestApi.java";
|
||||
|
||||
|
||||
// Build a mock running boot app
|
||||
mockAppProvider.builder()
|
||||
.isSpringBootApp(true)
|
||||
.port("999")
|
||||
.processId("76543")
|
||||
.host("cfapps.io")
|
||||
.processName("test-request-mapping-live-hover")
|
||||
// Ugly, but this is real JSON copied from a real live running app. We want the
|
||||
// mock app to return realistic results if possible
|
||||
.getRequestMappings(
|
||||
"{\"{[/greetings],methods=[GET]}\": {\"bean\": \"requestMappingHandlerMapping\", \"method\":\"public java.lang.String com.example.RestApi.patchGreetings()\"}}")
|
||||
. build();
|
||||
|
||||
harness.intialize(directory);
|
||||
|
||||
Editor editor = harness.newEditor(LanguageId.JAVA,
|
||||
"package com.example;\n" +
|
||||
"\n" +
|
||||
"import org.springframework.stereotype.Controller;\n" +
|
||||
"import org.springframework.web.bind.annotation.PatchMapping;\n" +
|
||||
"\n" +
|
||||
"@Controller\n" +
|
||||
"public class RestApi {\n" +
|
||||
"\n" +
|
||||
"@PatchMapping(\"/greetings\")\n" +
|
||||
"public void patchGreetings() {\n" +
|
||||
"}\n" +
|
||||
"\n" +
|
||||
"}",
|
||||
docUri);
|
||||
|
||||
editor.assertNoHover("@PatchMapping(\"/greetings\")");
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMultiRequestMethodMappingHoverHintMethod1() throws Exception {
|
||||
|
||||
File directory = new File(
|
||||
ProjectsHarness.class.getResource("/test-projects/test-request-mapping-live-hover/").toURI());
|
||||
String docUri = "file://" +directory.getAbsolutePath() + "/src/main/java/example/RestApi.java";
|
||||
|
||||
|
||||
// Build a mock running boot app
|
||||
mockAppProvider.builder()
|
||||
.isSpringBootApp(true)
|
||||
.port("999")
|
||||
.processId("76543")
|
||||
.host("cfapps.io")
|
||||
.processName("test-request-mapping-live-hover")
|
||||
// Ugly, but this is real JSON copied from a real live running app. We want the
|
||||
// mock app to return realistic results if possible
|
||||
.getRequestMappings(
|
||||
"{\"{[/greetings],methods=[POST,PUT]}\": {\"bean\": \"requestMappingHandlerMapping\", \"method\":\"public void com.example.RestApi.updateGreetings()\"}}")
|
||||
. build();
|
||||
|
||||
harness.intialize(directory);
|
||||
|
||||
Editor editor = harness.newEditor(LanguageId.JAVA,
|
||||
"package com.example;\n" +
|
||||
"\n" +
|
||||
"import org.springframework.stereotype.Controller;\n" +
|
||||
"import org.springframework.web.bind.annotation.RequestMapping;\n" +
|
||||
"import org.springframework.web.bind.annotation.RequestMethod.*;\n" +
|
||||
"\n" +
|
||||
"@Controller\n" +
|
||||
"public class RestApi {\n" +
|
||||
"\n" +
|
||||
"@RequestMapping(value=\"/greetings\", method={POST, PUT})\n" +
|
||||
"public void updateGreetings() {\n" +
|
||||
"}\n" +
|
||||
"\n" +
|
||||
"}",
|
||||
docUri);
|
||||
|
||||
editor.assertHoverContains("@RequestMapping(value=\"/greetings\", method={POST, PUT})", "Path: [/greetings](http://cfapps.io:999/greetings)\n" +
|
||||
"\n" +
|
||||
"Process ID: 76543\n" +
|
||||
"\n" +
|
||||
"Process Name: test-request-mapping-live-hover");
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMultiRequestMethodMappingHoverHintMethod2() throws Exception {
|
||||
|
||||
File directory = new File(
|
||||
ProjectsHarness.class.getResource("/test-projects/test-request-mapping-live-hover/").toURI());
|
||||
String docUri = "file://" +directory.getAbsolutePath() + "/src/main/java/example/RestApi.java";
|
||||
|
||||
|
||||
// Build a mock running boot app
|
||||
mockAppProvider.builder()
|
||||
.isSpringBootApp(true)
|
||||
.port("999")
|
||||
.processId("76543")
|
||||
.host("cfapps.io")
|
||||
.processName("test-request-mapping-live-hover")
|
||||
// Ugly, but this is real JSON copied from a real live running app. We want the
|
||||
// mock app to return realistic results if possible
|
||||
.getRequestMappings(
|
||||
"{\"{[/greetings],methods=[POST,PUT,PATCH]}\": {\"bean\": \"requestMappingHandlerMapping\", \"method\":\"public java.lang.String com.example.RestApi.updateGreetings()\"}}")
|
||||
. build();
|
||||
|
||||
harness.intialize(directory);
|
||||
|
||||
Editor editor = harness.newEditor(LanguageId.JAVA,
|
||||
"package com.example;\n" +
|
||||
"\n" +
|
||||
"import org.springframework.stereotype.Controller;\n" +
|
||||
"import org.springframework.web.bind.annotation.RequestMapping;\n" +
|
||||
"import org.springframework.web.bind.annotation.RequestMethod.*;\n" +
|
||||
"\n" +
|
||||
"@Controller\n" +
|
||||
"public class RestApi {\n" +
|
||||
"\n" +
|
||||
"@RequestMapping(value=\"/greetings\", method={POST, PUT})\n" +
|
||||
"public void updateGreetings() {\n" +
|
||||
"}\n" +
|
||||
"\n" +
|
||||
"}",
|
||||
docUri);
|
||||
|
||||
editor.assertNoHover("@RequestMapping(value=\"/greetings\", method={POST, PUT})");
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMultiPathMappingHoverHintMethod1() throws Exception {
|
||||
|
||||
File directory = new File(
|
||||
ProjectsHarness.class.getResource("/test-projects/test-request-mapping-live-hover/").toURI());
|
||||
String docUri = "file://" +directory.getAbsolutePath() + "/src/main/java/example/RestApi.java";
|
||||
|
||||
|
||||
// Build a mock running boot app
|
||||
mockAppProvider.builder()
|
||||
.isSpringBootApp(true)
|
||||
.port("999")
|
||||
.processId("76543")
|
||||
.host("cfapps.io")
|
||||
.processName("test-request-mapping-live-hover")
|
||||
// Ugly, but this is real JSON copied from a real live running app. We want the
|
||||
// mock app to return realistic results if possible
|
||||
.getRequestMappings(
|
||||
"{\"{[/greetings || /hello],methods=[GET]}\": {\"bean\": \"requestMappingHandlerMapping\", \"method\":\"public java.lang.String com.example.RestApi.greetings()\"}}")
|
||||
. build();
|
||||
|
||||
harness.intialize(directory);
|
||||
|
||||
Editor editor = harness.newEditor(LanguageId.JAVA,
|
||||
"package com.example;\n" +
|
||||
"\n" +
|
||||
"import org.springframework.stereotype.Controller;\n" +
|
||||
"import org.springframework.web.bind.annotation.RequestMapping;\n" +
|
||||
"import org.springframework.web.bind.annotation.RequestMethod.*;\n" +
|
||||
"\n" +
|
||||
"@Controller\n" +
|
||||
"public class RestApi {\n" +
|
||||
"\n" +
|
||||
"@RequestMapping(value={\"/greetings\", \"/hello\"}, method=GET)\n" +
|
||||
"public String greetings() {\n" +
|
||||
"}\n" +
|
||||
"\n" +
|
||||
"}",
|
||||
docUri);
|
||||
|
||||
editor.assertHoverContains("@RequestMapping(value={\"/greetings\", \"/hello\"}, method=GET)", "Path: [/greetings](http://cfapps.io:999/greetings)\n" +
|
||||
"Path: [/hello](http://cfapps.io:999/hello)\n" +
|
||||
"\n" +
|
||||
"Process ID: 76543\n" +
|
||||
"\n" +
|
||||
"Process Name: test-request-mapping-live-hover");
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMultiPathMappingHoverHintMethod2() throws Exception {
|
||||
|
||||
File directory = new File(
|
||||
ProjectsHarness.class.getResource("/test-projects/test-request-mapping-live-hover/").toURI());
|
||||
String docUri = "file://" +directory.getAbsolutePath() + "/src/main/java/example/RestApi.java";
|
||||
|
||||
|
||||
// Build a mock running boot app
|
||||
mockAppProvider.builder()
|
||||
.isSpringBootApp(true)
|
||||
.port("999")
|
||||
.processId("76543")
|
||||
.host("cfapps.io")
|
||||
.processName("test-request-mapping-live-hover")
|
||||
// Ugly, but this is real JSON copied from a real live running app. We want the
|
||||
// mock app to return realistic results if possible
|
||||
.getRequestMappings(
|
||||
"{\"{[/greetings || /hello || /helloAgain],methods=[GET]}\": {\"bean\": \"requestMappingHandlerMapping\", \"method\":\"public java.lang.String com.example.RestApi.greetings()\"}}")
|
||||
. build();
|
||||
|
||||
harness.intialize(directory);
|
||||
|
||||
Editor editor = harness.newEditor(LanguageId.JAVA,
|
||||
"package com.example;\n" +
|
||||
"\n" +
|
||||
"import org.springframework.stereotype.Controller;\n" +
|
||||
"import org.springframework.web.bind.annotation.RequestMapping;\n" +
|
||||
"import org.springframework.web.bind.annotation.RequestMethod.*;\n" +
|
||||
"\n" +
|
||||
"@Controller\n" +
|
||||
"public class RestApi {\n" +
|
||||
"\n" +
|
||||
"@RequestMapping(value={\"/greetings\", \"/hello\"}, method=GET)\n" +
|
||||
"public String greetings() {\n" +
|
||||
"}\n" +
|
||||
"\n" +
|
||||
"}",
|
||||
docUri);
|
||||
|
||||
editor.assertNoHover("@RequestMapping(value={\"/greetings\", \"/hello\"}, method=GET)");
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMethodMatchingHoverHintMethod1() throws Exception {
|
||||
|
||||
File directory = new File(
|
||||
ProjectsHarness.class.getResource("/test-projects/test-request-mapping-live-hover/").toURI());
|
||||
String docUri = "file://" +directory.getAbsolutePath() + "/src/main/java/example/RestApi.java";
|
||||
|
||||
|
||||
// Build a mock running boot app
|
||||
mockAppProvider.builder()
|
||||
.isSpringBootApp(true)
|
||||
.port("999")
|
||||
.processId("76543")
|
||||
.host("cfapps.io")
|
||||
.processName("test-request-mapping-live-hover")
|
||||
// Ugly, but this is real JSON copied from a real live running app. We want the
|
||||
// mock app to return realistic results if possible
|
||||
.getRequestMappings(
|
||||
"{\"{[/find],methods=[GET]}\": {\"bean\": \"requestMappingHandlerMapping\", \"method\":\"public org.springframework.http.ResponseEntity<?> com.example.RestApi.find(java.lang.String,java.util.Date,java.lang.String)\"}}")
|
||||
. build();
|
||||
|
||||
harness.intialize(directory);
|
||||
|
||||
Editor editor = harness.newEditor(LanguageId.JAVA,
|
||||
"package com.example;\n" +
|
||||
"\n" +
|
||||
"import org.springframework.http.ResponseEntity;\n" +
|
||||
"import java.lang.String;\n" +
|
||||
"import java.util.Date;\n" +
|
||||
"import org.springframework.stereotype.Controller;\n" +
|
||||
"import org.springframework.web.bind.annotation.RequestMapping;\n" +
|
||||
"import org.springframework.web.bind.annotation.RequestMethod.*;\n" +
|
||||
"\n" +
|
||||
"@Controller\n" +
|
||||
"public class RestApi {\n" +
|
||||
"\n" +
|
||||
"@RequestMapping(value=\"/find\", method=GET)\n" +
|
||||
"public ResponseEntity<?> find(String p1, Date p2, String p3) {\n" +
|
||||
"return null;\n" +
|
||||
"}\n" +
|
||||
"\n" +
|
||||
"}",
|
||||
docUri);
|
||||
|
||||
editor.assertHoverContains("@RequestMapping(value=\"/find\", method=GET)", "Path: [/find](http://cfapps.io:999/find)\n" +
|
||||
"\n" +
|
||||
"Process ID: 76543\n" +
|
||||
"\n" +
|
||||
"Process Name: test-request-mapping-live-hover");
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMethodMatchingHoverHintMethod2() throws Exception {
|
||||
|
||||
File directory = new File(
|
||||
ProjectsHarness.class.getResource("/test-projects/test-request-mapping-live-hover/").toURI());
|
||||
String docUri = "file://" +directory.getAbsolutePath() + "/src/main/java/example/RestApi.java";
|
||||
|
||||
|
||||
// Build a mock running boot app
|
||||
mockAppProvider.builder()
|
||||
.isSpringBootApp(true)
|
||||
.port("999")
|
||||
.processId("76543")
|
||||
.host("cfapps.io")
|
||||
.processName("test-request-mapping-live-hover")
|
||||
// Ugly, but this is real JSON copied from a real live running app. We want the
|
||||
// mock app to return realistic results if possible
|
||||
.getRequestMappings(
|
||||
"{\"{[/find],methods=[GET]}\": {\"bean\": \"requestMappingHandlerMapping\", \"method\":\"public java.lang.Object com.example.RestApi.set(java.lang.String,java.util.Map<java.lang.String, java.lang.String>)\"}}")
|
||||
. build();
|
||||
|
||||
harness.intialize(directory);
|
||||
|
||||
Editor editor = harness.newEditor(LanguageId.JAVA,
|
||||
"package com.example;\n" +
|
||||
"\n" +
|
||||
"import org.springframework.http.ResponseEntity;\n" +
|
||||
"import java.lang.String;\n" +
|
||||
"import java.util.Map;\n" +
|
||||
"import org.springframework.stereotype.Controller;\n" +
|
||||
"import org.springframework.web.bind.annotation.RequestMapping;\n" +
|
||||
"import org.springframework.web.bind.annotation.RequestMethod.*;\n" +
|
||||
"\n" +
|
||||
"@Controller\n" +
|
||||
"public class RestApi {\n" +
|
||||
"\n" +
|
||||
"@RequestMapping(value=\"/find\", method=GET)\n" +
|
||||
"public Object set(String p1, Map<String, String> p2) {\n" +
|
||||
"return null;\n" +
|
||||
"}\n" +
|
||||
"\n" +
|
||||
"}",
|
||||
docUri);
|
||||
|
||||
editor.assertHoverContains("@RequestMapping(value=\"/find\", method=GET)", "Path: [/find](http://cfapps.io:999/find)\n" +
|
||||
"\n" +
|
||||
"Process ID: 76543\n" +
|
||||
"\n" +
|
||||
"Process Name: test-request-mapping-live-hover");
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMethodMatchingHoverHintMethod3() throws Exception {
|
||||
|
||||
File directory = new File(
|
||||
ProjectsHarness.class.getResource("/test-projects/test-request-mapping-live-hover/").toURI());
|
||||
String docUri = "file://" +directory.getAbsolutePath() + "/src/main/java/example/RestApi.java";
|
||||
|
||||
|
||||
// Build a mock running boot app
|
||||
mockAppProvider.builder()
|
||||
.isSpringBootApp(true)
|
||||
.port("999")
|
||||
.processId("76543")
|
||||
.host("cfapps.io")
|
||||
.processName("test-request-mapping-live-hover")
|
||||
// Ugly, but this is real JSON copied from a real live running app. We want the
|
||||
// mock app to return realistic results if possible
|
||||
.getRequestMappings(
|
||||
"{\"{[/find],methods=[GET]}\": {\"bean\": \"requestMappingHandlerMapping\", \"method\":\"public java.lang.Object com.example.RestApi.set(java.lang.String,java.util.Map<java.lang.String, java.util.Map<java.lang.String, java.lang.Integer>>)\"}}")
|
||||
. build();
|
||||
|
||||
harness.intialize(directory);
|
||||
|
||||
Editor editor = harness.newEditor(LanguageId.JAVA,
|
||||
"package com.example;\n" +
|
||||
"\n" +
|
||||
"import org.springframework.http.ResponseEntity;\n" +
|
||||
"import java.lang.String;\n" +
|
||||
"import java.lang.Integer;\n" +
|
||||
"import java.util.Map;\n" +
|
||||
"import org.springframework.stereotype.Controller;\n" +
|
||||
"import org.springframework.web.bind.annotation.RequestMapping;\n" +
|
||||
"import org.springframework.web.bind.annotation.RequestMethod.*;\n" +
|
||||
"\n" +
|
||||
"@Controller\n" +
|
||||
"public class RestApi {\n" +
|
||||
"\n" +
|
||||
"@RequestMapping(value=\"/find\", method=GET)\n" +
|
||||
"public Object set(String p1, Map<String, Map<String, Integer>> p2) {\n" +
|
||||
"return null;\n" +
|
||||
"}\n" +
|
||||
"\n" +
|
||||
"}",
|
||||
docUri);
|
||||
|
||||
editor.assertHoverContains("@RequestMapping(value=\"/find\", method=GET)", "Path: [/find](http://cfapps.io:999/find)\n" +
|
||||
"\n" +
|
||||
"Process ID: 76543\n" +
|
||||
"\n" +
|
||||
"Process Name: test-request-mapping-live-hover");
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1,58 +0,0 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2017 Pivotal, Inc.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Pivotal, Inc. - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.springframework.ide.vscode.boot.java.requestmapping.test;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.springframework.ide.vscode.boot.java.requestmapping.UrlUtil;
|
||||
|
||||
/**
|
||||
* @author Martin Lippert
|
||||
*/
|
||||
public class UrlUtilTest {
|
||||
|
||||
@Test
|
||||
public void testSplitPathWithoutDuplicate() {
|
||||
String path = "/superpath";
|
||||
String[] splitPath = UrlUtil.splitPath(path);
|
||||
assertEquals(1, splitPath.length);
|
||||
assertEquals("/superpath", splitPath[0]);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSplitPathSimpleCaseWithEmptyOr() {
|
||||
String path = "/superpath/mypath || ";
|
||||
String[] splitPath = UrlUtil.splitPath(path);
|
||||
assertEquals(1, splitPath.length);
|
||||
assertEquals("/superpath/mypath", splitPath[0]);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSplitPathSimpleCase() {
|
||||
String path = "/superpath/mypath || mypath.json";
|
||||
String[] splitPath = UrlUtil.splitPath(path);
|
||||
assertEquals(2, splitPath.length);
|
||||
assertEquals("/superpath/mypath", splitPath[0]);
|
||||
assertEquals("/superpath/mypath.json", splitPath[1]);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSplitPathMultipleCases() {
|
||||
String path = "/superpath/mypath || mypath.json || somethingelse.what";
|
||||
String[] splitPath = UrlUtil.splitPath(path);
|
||||
assertEquals(3, splitPath.length);
|
||||
assertEquals("/superpath/mypath", splitPath[0]);
|
||||
assertEquals("/superpath/mypath.json", splitPath[1]);
|
||||
assertEquals("/superpath/somethingelse.what", splitPath[2]);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -19,8 +19,8 @@ import java.util.Collection;
|
||||
import org.mockito.Mockito;
|
||||
import org.springframework.ide.vscode.boot.java.handlers.RunningAppProvider;
|
||||
import org.springframework.ide.vscode.commons.boot.app.cli.SpringBootApp;
|
||||
import org.springframework.ide.vscode.commons.boot.app.cli.requestmappings.RequestMapping;
|
||||
import org.springframework.ide.vscode.commons.util.ExceptionUtil;
|
||||
import org.springframework.ide.vscode.project.harness.BootLanguageServerHarness.Builder;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
@@ -97,7 +97,8 @@ public class MockRunningAppProvider {
|
||||
}
|
||||
|
||||
public MockAppBuilder getRequestMappings(String mappings) throws Exception {
|
||||
when(app.getRequestMappings()).thenReturn(mappings);
|
||||
Collection<RequestMapping> requestMappings = SpringBootApp.parseRequestMappingsJson(mappings);
|
||||
when(app.getRequestMappings()).thenReturn(requestMappings);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user