JokeController.java

1
package edu.ucsb.cs156.spring.backenddemo.controllers;
2
3
import org.springframework.web.bind.annotation.RestController;
4
5
import edu.ucsb.cs156.spring.backenddemo.services.JokeQueryService;
6
import lombok.extern.slf4j.Slf4j;
7
8
import org.springframework.web.bind.annotation.GetMapping;
9
import org.springframework.web.bind.annotation.RequestMapping;
10
import org.springframework.web.bind.annotation.RequestParam;
11
import org.springframework.beans.factory.annotation.Autowired;
12
import org.springframework.http.ResponseEntity;
13
14
import com.fasterxml.jackson.core.JsonProcessingException;
15
import com.fasterxml.jackson.databind.ObjectMapper;
16
17
import io.swagger.v3.oas.annotations.Operation;
18
import io.swagger.v3.oas.annotations.Parameter;
19
import io.swagger.v3.oas.annotations.tags.Tag;
20
21
@Tag(name="Jokes")
22
@Slf4j
23
@RestController
24
@RequestMapping("/api/jokes")
25
public class JokeController {
26
    
27
    ObjectMapper mapper = new ObjectMapper();
28
29
    @Autowired
30
    JokeQueryService jokeQueryService;
31
32
    @Operation(summary = "Get some amount of jokes based on a category", description = "Jokes are from https://v2.jokeapi.dev/")
33
    @GetMapping("/get")
34
    public ResponseEntity<String> getJokes(
35
        @Parameter(name="numJokes", description="numJokes", example="2") @RequestParam String category,
36
        @Parameter(name="category", description="category", example="Programming") @RequestParam String numJokes
37
    ) throws JsonProcessingException {
38
        log.info("getJokes: category={} numJokes={}", category, numJokes);
39
        String result = jokeQueryService.getJSON(category, numJokes);
40 1 1. getJokes : replaced return value with null for edu/ucsb/cs156/spring/backenddemo/controllers/JokeController::getJokes → KILLED
        return ResponseEntity.ok().body(result);
41
    }
42
43
}
44

Mutations

40

1.1
Location : getJokes
Killed by : edu.ucsb.cs156.spring.backenddemo.controllers.JokeControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.spring.backenddemo.controllers.JokeControllerTests]/[method:test_getJokes()]
replaced return value with null for edu/ucsb/cs156/spring/backenddemo/controllers/JokeController::getJokes → KILLED

Active mutators

Tests examined


Report generated by PIT 1.7.3