CourseByInstructorController.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
import io.swagger.annotations.ApiParam;
9
import lombok.extern.slf4j.Slf4j;
10
11
import org.slf4j.Logger;
12
import org.slf4j.LoggerFactory;
13
import org.springframework.beans.factory.annotation.Autowired;
14
import org.springframework.http.ResponseEntity;
15
import org.springframework.web.bind.annotation.GetMapping;
16
import org.springframework.web.bind.annotation.RequestMapping;
17
import org.springframework.web.bind.annotation.RequestParam;
18
import org.springframework.web.bind.annotation.RestController;
19
20
import com.fasterxml.jackson.core.JsonProcessingException;
21
import com.fasterxml.jackson.databind.ObjectMapper;
22
23
@RestController
24
@Slf4j
25
@RequestMapping("/api/public/coursebyinstructor")
26
public class CourseByInstructorController {
27
28
    private ObjectMapper mapper = new ObjectMapper();
29
30
	@Autowired
31
	ConvertedSectionCollection convertedSectionCollection;
32
33
	@ApiOperation(value = "Get a list of courses by instructor over time")
34
	@GetMapping(value = "/search", produces = "application/json")
35
	public ResponseEntity<String> search(
36
		@ApiParam(name = "startQtr", type = "String", value = "Start quarter in YYYYQ format", example = "20221", required = true) @RequestParam String startQtr,
37
		@ApiParam(name = "endQtr", type = "String", value = "End quarter in YYYYQ format", example = "20222", required = true) @RequestParam String endQtr,
38
		@ApiParam(name = "instructor", type = "String", value = "Instructor name", example = "CONRAD P T", required = true) @RequestParam String instructor,
39
		@ApiParam(name = "lectureOnly", type = "boolean", value = "Lectures only", example = "true", required = true) @RequestParam boolean lectureOnly
40
	) throws JsonProcessingException {
41
		List<ConvertedSection> courseResults;
42 1 1. search : negated conditional → KILLED
		if (lectureOnly) {
43
			courseResults = convertedSectionCollection.findByQuarterRangeAndInstructor(
44
				startQtr,
45
				endQtr,
46
				"^"+instructor.toUpperCase(),
47
				"^(Teaching and in charge)");
48
		} else {
49
			courseResults = convertedSectionCollection.findByQuarterRangeAndInstructor(
50
				startQtr,
51
				endQtr,
52
				"^"+instructor.toUpperCase(),
53
				"^.*");
54
		}
55
		String body = mapper.writeValueAsString(courseResults);
56
		log.info("body={}", body);
57 1 1. search : replaced return value with null for edu/ucsb/cs156/courses/controllers/CourseByInstructorController::search → KILLED
		return ResponseEntity.ok().body(body);
58
	}
59
}

Mutations

42

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

57

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

Active mutators

Tests examined


Report generated by PIT 1.7.3