CourseOverTimeController.java

1
package edu.ucsb.cs156.courses.controllers;
2
3
import java.util.List;
4
5
import edu.ucsb.cs156.courses.collections.ConvertedSectionCollection;
6
import edu.ucsb.cs156.courses.documents.ConvertedSection;
7
import io.swagger.annotations.ApiOperation;
8
9
import org.springframework.beans.factory.annotation.Autowired;
10
import org.springframework.http.ResponseEntity;
11
import org.springframework.web.bind.annotation.GetMapping;
12
import org.springframework.web.bind.annotation.RequestMapping;
13
import org.springframework.web.bind.annotation.RequestParam;
14
import org.springframework.web.bind.annotation.RestController;
15
16
import com.fasterxml.jackson.core.JsonProcessingException;
17
import com.fasterxml.jackson.databind.ObjectMapper;
18
19
@RestController
20
@RequestMapping("/api/public/courseovertime")
21
public class CourseOverTimeController {
22
    private ObjectMapper mapper = new ObjectMapper();
23
24
    @Autowired
25
    ConvertedSectionCollection convertedSectionCollection;
26
27
    @ApiOperation(value = "Get a list of courses over time")
28
    @GetMapping(value = "/search", produces = "application/json")
29
    public ResponseEntity<String> search
30
    (
31
        @RequestParam String startQtr,
32
        @RequestParam String endQtr,
33
        @RequestParam String subjectArea,
34
        @RequestParam String courseNumber
35
    ) throws JsonProcessingException {
36
        List<ConvertedSection> courseResults = convertedSectionCollection.findByQuarterRangeAndCourseId(
37
            startQtr,
38
            endQtr,
39
            makeFormattedCourseId(subjectArea, courseNumber)
40
        );
41
        String body = mapper.writeValueAsString(courseResults);
42 1 1. search : replaced return value with null for edu/ucsb/cs156/courses/controllers/CourseOverTimeController::search → KILLED
        return ResponseEntity.ok().body(body);
43
    }
44
45
    String makeFormattedCourseId(String subjectArea, String courseNumber) {
46
        String[] nums = courseNumber.split("[a-zA-Z]+");
47
        String[] suffs = courseNumber.split("[0-9]+");
48 2 1. makeFormattedCourseId : changed conditional boundary → KILLED
2. makeFormattedCourseId : negated conditional → KILLED
        if (suffs.length < 2) { // no suffix
49 1 1. makeFormattedCourseId : replaced return value with "" for edu/ucsb/cs156/courses/controllers/CourseOverTimeController::makeFormattedCourseId → KILLED
            return
50
                  String.format( "%-8s", subjectArea                ) // 'CMPSC   '
51
                + String.format( "%3s" , nums[0]                    ) // '  8'
52
            ;
53
        }
54 1 1. makeFormattedCourseId : replaced return value with "" for edu/ucsb/cs156/courses/controllers/CourseOverTimeController::makeFormattedCourseId → KILLED
        return
55
              String.format( "%-8s", subjectArea                ) // 'CMPSC   '
56
            + String.format( "%3s" , nums[0]                    ) // '  8'
57
            + String.format( "%-2s", suffs[1]                   ) // 'A '
58
        ;
59
    }
60
    
61
}

Mutations

42

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

48

1.1
Location : makeFormattedCourseId
Killed by : edu.ucsb.cs156.courses.controllers.CourseOverTimeControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.courses.controllers.CourseOverTimeControllerTests]/[method:test_search_validRequestWithSuffix()]
changed conditional boundary → KILLED

2.2
Location : makeFormattedCourseId
Killed by : edu.ucsb.cs156.courses.controllers.CourseOverTimeControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.courses.controllers.CourseOverTimeControllerTests]/[method:test_search_validRequestWithSuffix()]
negated conditional → KILLED

49

1.1
Location : makeFormattedCourseId
Killed by : edu.ucsb.cs156.courses.controllers.CourseOverTimeControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.courses.controllers.CourseOverTimeControllerTests]/[method:test_search_validRequestWithoutSuffix()]
replaced return value with "" for edu/ucsb/cs156/courses/controllers/CourseOverTimeController::makeFormattedCourseId → KILLED

54

1.1
Location : makeFormattedCourseId
Killed by : edu.ucsb.cs156.courses.controllers.CourseOverTimeControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.courses.controllers.CourseOverTimeControllerTests]/[method:test_search_validRequestWithSuffix()]
replaced return value with "" for edu/ucsb/cs156/courses/controllers/CourseOverTimeController::makeFormattedCourseId → KILLED

Active mutators

Tests examined


Report generated by PIT 1.7.3