CourseOverTimeInstructorController.java

1
package edu.ucsb.cs156.courses.controllers;
2
3
import com.fasterxml.jackson.core.JsonProcessingException;
4
import com.fasterxml.jackson.databind.ObjectMapper;
5
import edu.ucsb.cs156.courses.collections.ConvertedSectionCollection;
6
import edu.ucsb.cs156.courses.documents.ConvertedSection;
7
import io.swagger.v3.oas.annotations.Operation;
8
import io.swagger.v3.oas.annotations.Parameter;
9
import java.util.List;
10
import org.springframework.beans.factory.annotation.Autowired;
11
import org.springframework.http.ResponseEntity;
12
import org.springframework.web.bind.annotation.GetMapping;
13
import org.springframework.web.bind.annotation.RequestMapping;
14
import org.springframework.web.bind.annotation.RequestParam;
15
import org.springframework.web.bind.annotation.RestController;
16
17
@RestController
18
@RequestMapping("/api/public/courseovertime")
19
public class CourseOverTimeInstructorController {
20
  private ObjectMapper mapper = new ObjectMapper();
21
22
  @Autowired ConvertedSectionCollection convertedSectionCollection;
23
24
  @Operation(summary = "Get a list of courses over time, filtered by instructor name")
25
  @GetMapping(value = "/instructorsearch", produces = "application/json")
26
  public ResponseEntity<String> search(
27
      @Parameter(
28
              name = "startQtr",
29
              description =
30
                  "Starting quarter in yyyyq format, e.g. 20231 for W23, 20232 for S23, etc. (1=Winter, 2=Spring, 3=Summer, 4=Fall)",
31
              example = "20231",
32
              required = true)
33
          @RequestParam
34
          String startQtr,
35
      @Parameter(
36
              name = "endQtr",
37
              description =
38
                  "Ending quarter in yyyyq format, e.g. 20231 for W23, 20232 for S23, etc. (1=Winter, 2=Spring, 3=Summer, 4=Fall)",
39
              example = "20231",
40
              required = true)
41
          @RequestParam
42
          String endQtr,
43
      @Parameter(
44
              name = "instructor",
45
              description = "Instructor name; e.g. 'conrad' or 'CONRAD' or 'CONRAD P T'",
46
              example = "CONRAD",
47
              required = true)
48
          @RequestParam
49
          String instructor,
50
      @Parameter(
51
              name = "lectureOnly",
52
              description = "Lectures only",
53
              example = "true",
54
              required = true)
55
          @RequestParam
56
          boolean lectureOnly)
57
      throws JsonProcessingException {
58
    List<ConvertedSection> courseResults;
59 1 1. search : negated conditional → KILLED
    if (lectureOnly) {
60
      courseResults =
61
          convertedSectionCollection.findByQuarterRangeAndInstructor(
62
              startQtr, endQtr, "^" + instructor.toUpperCase(), "^(Teaching and in charge)");
63
    } else {
64
      courseResults =
65
          convertedSectionCollection.findByQuarterRangeAndInstructor(
66
              startQtr, endQtr, "^" + instructor.toUpperCase(), "^.*");
67
    }
68
    String body = mapper.writeValueAsString(courseResults);
69 1 1. search : replaced return value with null for edu/ucsb/cs156/courses/controllers/CourseOverTimeInstructorController::search → KILLED
    return ResponseEntity.ok().body(body);
70
  }
71
}

Mutations

59

1.1
Location : search
Killed by : edu.ucsb.cs156.courses.controllers.CourseOverTimeInstructorControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.courses.controllers.CourseOverTimeInstructorControllerTests]/[method:test_search_validRequestWithoutSuffix()]
negated conditional → KILLED

69

1.1
Location : search
Killed by : edu.ucsb.cs156.courses.controllers.CourseOverTimeInstructorControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.courses.controllers.CourseOverTimeInstructorControllerTests]/[method:test_search_emptyRequest()]
replaced return value with null for edu/ucsb/cs156/courses/controllers/CourseOverTimeInstructorController::search → KILLED

Active mutators

Tests examined


Report generated by PIT 1.7.3