CourseOverTimeBuildingController.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 lombok.extern.slf4j.Slf4j;
11
import org.springframework.beans.factory.annotation.Autowired;
12
import org.springframework.http.ResponseEntity;
13
import org.springframework.web.bind.annotation.GetMapping;
14
import org.springframework.web.bind.annotation.RequestMapping;
15
import org.springframework.web.bind.annotation.RequestParam;
16
import org.springframework.web.bind.annotation.RestController;
17
18
@Slf4j
19
@RestController
20
@RequestMapping("/api/public/courseovertime")
21
public class CourseOverTimeBuildingController {
22
23
  private ObjectMapper mapper = new ObjectMapper();
24
25
  @Autowired ConvertedSectionCollection convertedSectionCollection;
26
27
  @Operation(summary = "Get a list of courses over time, filtered by (abbreviated) building code")
28
  @GetMapping(value = "/buildingsearch", produces = "application/json")
29
  public ResponseEntity<String> search(
30
      @Parameter(
31
              name = "startQtr",
32
              description =
33
                  "Starting quarter in yyyyq format, e.g. 20231 for W23, 20232 for S23, etc. (1=Winter, 2=Spring, 3=Summer, 4=Fall)",
34
              example = "20231",
35
              required = true)
36
          @RequestParam
37
          String startQtr,
38
      @Parameter(
39
              name = "endQtr",
40
              description =
41
                  "Ending quarter in yyyyq format, e.g. 20231 for W23, 20232 for S23, etc. (1=Winter, 2=Spring, 3=Summer, 4=Fall)",
42
              example = "20231",
43
              required = true)
44
          @RequestParam
45
          String endQtr,
46
      @Parameter(
47
              name = "buildingCode",
48
              description = "Building code such as PHELP for Phelps, GIRV for Girvetz",
49
              example = "GIRV",
50
              required = true)
51
          @RequestParam
52
          String buildingCode)
53
      throws JsonProcessingException {
54
    List<ConvertedSection> courseResults =
55
        convertedSectionCollection.findByQuarterRangeAndBuildingCode(
56
            startQtr, endQtr, buildingCode);
57
    String body = mapper.writeValueAsString(courseResults);
58 1 1. search : replaced return value with null for edu/ucsb/cs156/courses/controllers/CourseOverTimeBuildingController::search → KILLED
    return ResponseEntity.ok().body(body);
59
  }
60
}

Mutations

58

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

Active mutators

Tests examined


Report generated by PIT 1.7.3