Skip to content

Commit c0b7684

Browse files
authored
Add Test and utility classes to create a jdt-ls workspace and test the commands (#174)
* Add a test utility class able to load a java application: maven or gradle and create some test classes to test the command able to find an annotation. #171 Signed-off-by: Charles Moulliard <[email protected]> * Revert from public to protected and move the test classes to the same package as SampleDelegateCommandHandler Signed-off-by: Charles Moulliard <[email protected]> * Changed the method to log the stream of the results from logInfo() to debugTrace(). Add the property <showEclipseLog> to true to see the runtime messages Signed-off-by: Charles Moulliard <[email protected]> --------- Signed-off-by: Charles Moulliard <[email protected]>
1 parent 43af7f2 commit c0b7684

File tree

34 files changed

+2805
-54
lines changed

34 files changed

+2805
-54
lines changed

.vscode/settings.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
{
2-
"java.configuration.updateBuildConfiguration": "automatic"
2+
"java.configuration.updateBuildConfiguration": "automatic",
3+
"java.debug.settings.onBuildFailureProceed": true
34
}

java-analyzer-bundle.core/.classpath

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<classpath>
3-
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-17"/>
3+
<!--<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-17"/>-->
4+
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
45
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
56
<classpathentry kind="src" path="src/main/java/"/>
67
<classpathentry kind="output" path="target/classes"/>

java-analyzer-bundle.core/src/main/java/io/konveyor/tackle/core/internal/SampleDelegateCommandHandler.java

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
package io.konveyor.tackle.core.internal;
22

33
import static java.lang.String.format;
4+
import static org.eclipse.jdt.ls.core.internal.JavaLanguageServerPlugin.debugTrace;
45
import static org.eclipse.jdt.ls.core.internal.JavaLanguageServerPlugin.logInfo;
56

67
import java.util.ArrayList;
78
import java.util.List;
89
import java.util.regex.Matcher;
910
import java.util.regex.Pattern;
11+
import java.util.stream.Collectors;
1012

1113
import org.eclipse.core.runtime.IPath;
1214
import org.eclipse.core.runtime.IProgressMonitor;
@@ -150,7 +152,7 @@ private static SearchPattern mapLocationToSearchPatternLocation(int location, St
150152
* "import": 8,
151153
* "variable_declaration": 9,
152154
* "type": 10,
153-
* "package": 11,
155+
* "package": 1
154156
* "field": 12,
155157
* "method_declaration": 13,
156158
* "class_declaration": 14,
@@ -199,7 +201,7 @@ private static SearchPattern getPatternSingleQuery(int location, String query) t
199201
throw new Exception("unable to create search pattern");
200202
}
201203

202-
private static List<SymbolInformation> search(String projectName, ArrayList<String> includedPaths, String query, AnnotationQuery annotationQuery, int location, String analysisMode,
204+
protected static List<SymbolInformation> search(String projectName, ArrayList<String> includedPaths, String query, AnnotationQuery annotationQuery, int location, String analysisMode,
203205
boolean includeOpenSourceLibraries, String mavenLocalRepoPath, String mavenIndexPath, IProgressMonitor monitor) throws Exception {
204206
IJavaProject[] targetProjects;
205207
IJavaProject project = ProjectUtils.getJavaProject(projectName);
@@ -209,7 +211,7 @@ private static List<SymbolInformation> search(String projectName, ArrayList<Stri
209211
targetProjects = ProjectUtils.getJavaProjects();
210212
}
211213

212-
logInfo("Searching in target project: " + targetProjects);
214+
logInfo("KONVEYOR_LOG: Searching in target project: " + targetProjects);
213215

214216
// For Partial results, we are going to filter out based on a list in the engine
215217
int s = IJavaSearchScope.SOURCES | IJavaSearchScope.REFERENCED_PROJECTS | IJavaSearchScope.APPLICATION_LIBRARIES;
@@ -399,10 +401,18 @@ private static List<SymbolInformation> search(String projectName, ArrayList<Stri
399401
}
400402
}
401403

402-
logInfo("KONVEYOR_LOG: got: " + requestor.getAllSearchMatches() +
403-
" search matches for " + query +
404-
" location " + location
405-
+ " matches" + requestor.getSymbols().size());
404+
logInfo("KONVEYOR_LOG: Got: " + requestor.getAllSearchMatches() +
405+
" Number of search matching the query: \"" + query + "\"" +
406+
" and location type: " + location);
407+
408+
logInfo("KONVEYOR_LOG: Results size: " + requestor.getSymbols().size());
409+
410+
String result = requestor.getSymbols().stream()
411+
.map(si ->
412+
String.format("\n-------------------------\nSymbol name: %s\nkind: %s\nLocation: %s",si.getName(), si.getKind(), si.getLocation())
413+
)
414+
.collect(Collectors.joining());
415+
debugTrace("KONVEYOR_DEBUG: " + result);
406416

407417
return symbols;
408418

java-analyzer-bundle.test/.classpath

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<classpath>
3-
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-11"/>
3+
<!--<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-17"/>-->
4+
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
45
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
56
<classpathentry kind="src" path="src/main/java/">
67
<attributes>

java-analyzer-bundle.test/META-INF/MANIFEST.MF

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ Bundle-Version: 1.0.0.qualifier
66
Fragment-Host: java-analyzer-bundle.core;bundle-version="1.0.0"
77
Bundle-RequiredExecutionEnvironment: JavaSE-17
88
Require-Bundle: org.eclipse.jdt.junit4.runtime;bundle-version="1.1.0",
9-
org.junit;bundle-version="4.12",
10-
org.eclipse.m2e.core
11-
9+
org.apache.commons.io,
10+
org.apache.commons.lang3,
11+
org.junit;bundle-version="4.12",
12+
org.eclipse.m2e.core,
13+
org.eclipse.buildship.core
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<projectDescription>
3+
<name>springboot-todo</name>
4+
<comment></comment>
5+
<projects>
6+
</projects>
7+
<buildSpec>
8+
<buildCommand>
9+
<name>org.eclipse.jdt.core.javabuilder</name>
10+
<arguments>
11+
</arguments>
12+
</buildCommand>
13+
<buildCommand>
14+
<name>org.eclipse.m2e.core.maven2Builder</name>
15+
<arguments>
16+
</arguments>
17+
</buildCommand>
18+
</buildSpec>
19+
<natures>
20+
<nature>org.eclipse.jdt.core.javanature</nature>
21+
<nature>org.eclipse.m2e.core.maven2Nature</nature>
22+
</natures>
23+
</projectDescription>
Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
# Awesome To-Do App
2+
3+
## Overview
4+
5+
**Awesome To-Do App** is a versatile task management application tailored to assist users in organizing tasks, managing deadlines, and prioritizing activities. The app offers an intuitive user interface complete with a spectrum of features including task creation, deletion, pagination, and advanced error handling.
6+
7+
In this README, you'll find a comprehensive guide that details your project, enumerates its key functionalities, lists the technologies employed, provides installation instructions, and articulates usage instructions.
8+
9+
![Tasks Empty](https://github.com/adampeer/spring-boot-todo-app/assets/90769663/aed896df-0c77-4fe2-845a-e12460ea5b2b)
10+
11+
![Tasks Full](https://github.com/adampeer/spring-boot-todo-app/assets/90769663/3bac6e08-6e5a-4c2c-a69a-520c5a8ff4ec)
12+
13+
## Features
14+
15+
### Task Management
16+
17+
- Create and manage tasks with essential details such as titles, descriptions, and due dates.
18+
- Tasks are elegantly presented in card format, enhancing visibility and comprehension.
19+
- Effortlessly delete tasks with permanent removal from the application.
20+
21+
### Pagination
22+
23+
- Enhance user experience by paginating tasks, ensuring a clutter-free view.
24+
- Navigate seamlessly through the task list with "Previous" and "Next" buttons for effortless organization.
25+
26+
### Error Handling
27+
28+
- Robust error handling, encompassing gracefully displayed custom error pages and user-friendly messages.
29+
- Guard against requests that seek pages beyond the total available count, offering a polished and secure user experience.
30+
31+
### Advanced Features
32+
33+
- Responsive design adapting to diverse devices, guaranteeing a harmonious experience on any platform.
34+
- Intuitive pop-up modals for confirming task deletion, enriching user interaction.
35+
36+
## Technologies Used
37+
38+
**Frontend:**
39+
40+
- HTML
41+
- Thymeleaf (for server-side rendering)
42+
- JavaScript
43+
- jQuery
44+
- Bootstrap (for styling and modals)
45+
46+
**Backend:**
47+
48+
- Spring Boot (Java-based framework)
49+
- Spring MVC
50+
- Spring Data JPA (for database access)
51+
- MySQL (as the database)
52+
53+
## Installation
54+
55+
1. **Clone the Repository:**
56+
57+
```bash
58+
git clone https://github.com/adampeer/spring-boot-todo-app.git
59+
cd awesome-todo-app
60+
```
61+
62+
2. **Database Configuration:**
63+
64+
- Install MySQL and create a database.
65+
- Update the `application.properties` file with your database jdtLSConfiguration such as username, password, database name and port number.
66+
67+
3. **Build and Run the Application:**
68+
69+
```bash
70+
./mvnw clean package
71+
java -jar target/awesome-todo-app-0.1.jar
72+
```
73+
74+
4. **Access the Application:**
75+
76+
Open a web browser and go to `http://localhost:8080` or whatever port you've set in application.properties file.
77+
78+
## Usage
79+
80+
1. **Create a Task:**
81+
82+
- Fill out the task creation form, providing a title, description, and due date.
83+
- Click the "Create Task" button.
84+
85+
2. **Pagination:**
86+
87+
- Use the "Previous" and "Next" buttons to navigate through your task list.
88+
- Each page typically displays 6 tasks.
89+
90+
3. **Delete a Task:**
91+
92+
- Each task card includes a "Delete" button.
93+
- Click the "Delete" button to trigger a confirmation modal.
94+
- Confirm the task deletion by clicking "Yes" in the modal.
95+
96+
4. **Error Handling:**
97+
98+
- Error pages and messages are displayed for various error scenarios.
99+
- Friendly error messages are shown to users.
100+
101+
5. **Advanced Features:**
102+
103+
- Responsive design ensures a seamless experience on different devices.
104+
- Confirmation modal for task deletion adds a layer of user interaction.
105+
106+
## Feedback and Support
107+
108+
We welcome your feedback and suggestions. If you encounter any issues or have ideas for improvements, please open an issue on our GitHub repository.
109+
110+
## License
111+
112+
This project is licensed under the MIT License. Feel free to use it, modify it, and share it as you see fit.
113+
114+
## Author
115+
116+
- [Adam Peer](https://github.com/adampeer)
117+
118+
---

0 commit comments

Comments
 (0)