This repo contains a semi-finished state of the project you will be working on in this workshop. You will be creating a new Spring Boot application and then leveraging GitHub Copilot to build out the code changes.
- Install GitHub Copilot extensions. If using Visual Studio Code, install both
GitHub Copilot
andGitHub Copilot Chat
extensions. If using IntelliJ, install theGitHub Copilot
extension. - Log into the extension.
- Create a new (empty) Spring Boot application. If you're unable to create a new project, feel free to use the project in this repo, however you will need to delete the
model
,service
andcontroller
folders.
The following steps can be completed by writing prompts into GitHub Copilot. You'll see here we have the ability to author new code, generate business logic, refactor code and diagnose code. If you're encountering issues such as syntax errors or exceptions, remember you can use the /fix
commands in GitHub Copilot to help diagnose the issue.
- Create a
model
package with a class called Todo. Generate the class with the following properties:
* Id (string)
* Title (string)
* Description (string)
* Completed (boolean)
- Without using GitHub Copilot, create a
service
package with an interface called ITodoService:
public interface ITodoService {
List<Todo> getAllTodos();
Todo getTodoById(String id);
Todo createTodo(Todo todo);
Todo updateTodo(String id, Todo todo);
void deleteTodo(String id);
void deleteTodoById(String id);
}
-
Create an implementation of
ITodoService
calledMemoryTodoService
. Let all the implementation code be autogenerated. Make sure that the class is annotated with@Service
for dependency injection. -
Create a REST controller using the route
/api/todos
and have it implement all the methods ofITodoService
as CRUD operations. Make sure the constructor has been annotated with@Autowired
so that theMemoryTodoService
will be injected into the controller. -
Make sure there's a CORS policy allowing
*
on the REST controller.
-
Implement a health endpoint for the application to make sure the application is up and running.
-
Add default http handler redirecting any non API/health routes to a 404. The only active handlers should be implemented on the API/health routes as this project is a REST API microservice only.
-
Refactor the Todo class to incloude timestamps and deleted flag to the Todo items.
-
Implement testing framework of choice. Include tests (and implementation updates) for the following:
- Modify behaviour if required so the
MemoryTodoService
controls setting a new ID for each item. Do not allow upstream components to set the ID of the item being created. - Make sure on modification of Todo items, the ID cannot be changed.
- Any other tests you find relevant.