package base.course;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;

@RestController
@RequestMapping("/course")
public class CourseController {

    @Autowired
    private CourseRepository courseRepository;

    @GetMapping
    public ArrayList<Course> listAll() {
        ArrayList<Course> courses = new ArrayList<>();
        courseRepository.findAll().forEach(course -> courses.add(course));
        return courses;
    }

    @GetMapping("{name}")
    public Course find(@PathVariable String name) {
        return courseRepository.findByName(name.toUpperCase());
    }

    @GetMapping("/prefix/{prefix}")
    public ArrayList<Course> listAllPrefix(@PathVariable String prefix) {
        ArrayList<Course> courses = new ArrayList<>();
        courseRepository.findByPrefix(prefix.toUpperCase()).forEach(course -> courses.add(course));
        return courses;
    }

}

@@ -78,16 +78,108 @@
 owired;%0A
+import org.springframework.http.HttpStatus;%0Aimport org.springframework.http.ResponseEntity;%0A
 import o
@@ -604,32 +604,47 @@
 ping%0A    public 
+ResponseEntity%3C
 ArrayList%3CCourse
@@ -636,32 +636,33 @@
 rrayList%3CCourse%3E
+%3E
  listAll() %7B%0A   
@@ -788,39 +788,206 @@
 urse));%0A
-        return courses;
+%0A        if (courses.size() == 0) %7B%0A            return new ResponseEntity%3C%3E(HttpStatus.NOT_FOUND);%0A        %7D else %7B%0A            return new ResponseEntity%3C%3E(courses, HttpStatus.OK);%0A        %7D
 %0A    %7D%0A%0A
@@ -1023,22 +1023,38 @@
  public 
+ResponseEntity%3C
 Course
+%3E
  find(@P
@@ -1084,30 +1084,39 @@
 ) %7B%0A        
-return
+Course course =
  courseRepos
@@ -1152,16 +1152,201 @@
 Case());
+%0A%0A        if (course == null) %7B%0A            return new ResponseEntity%3C%3E(HttpStatus.NOT_FOUND);%0A        %7D else %7B%0A            return new ResponseEntity%3C%3E(course, HttpStatus.OK);%0A        %7D
 %0A    %7D%0A%0A
@@ -1392,16 +1392,31 @@
  public 
+ResponseEntity%3C
 ArrayLis
@@ -1424,16 +1424,17 @@
 %3CCourse%3E
+%3E
  listAll
@@ -1630,31 +1630,198 @@
 ));%0A
-        return courses;
+%0A        if (courses.size() == 0) %7B%0A            return new ResponseEntity%3C%3E(HttpStatus.NOT_FOUND);%0A        %7D else %7B%0A            return new ResponseEntity%3C%3E(courses, HttpStatus.OK);%0A        %7D
 %0A   

Add HttpStatus 404 return for courses not found