JokeController.java

1
package edu.ucsb.cs156.spring.backenddemo.controllers;
2
3
import edu.ucsb.cs156.spring.backenddemo.services.JokeQueryService;
4
import lombok.extern.slf4j.Slf4j;
5
6
import org.springframework.web.bind.annotation.GetMapping;
7
import org.springframework.web.bind.annotation.RequestMapping;
8
import org.springframework.web.bind.annotation.RequestParam;
9
import org.springframework.web.bind.annotation.RestController;
10
import org.springframework.beans.factory.annotation.Autowired;
11
import org.springframework.http.ResponseEntity;
12
13
import com.fasterxml.jackson.core.JsonProcessingException;
14
import com.fasterxml.jackson.databind.ObjectMapper;
15
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
22
@Tag(name="Jokes from https://v2.jokeapi.dev/")
23
@Slf4j
24
@RestController
25
@RequestMapping("/api/jokes")
26
public class JokeController {
27
28
    ObjectMapper mapper = new ObjectMapper();
29
30
    @Autowired
31
    JokeQueryService JokeQueryService;
32
33
    @Operation(summary = "Get jokes from a given category and amount", 
34
    description = "JSON return format documented here:  https://v2.jokeapi.dev/")
35
    
36
    @GetMapping("/get")
37
38
    public ResponseEntity<String> getJokesQuery(
39
        @Parameter(name="category", example="Programming") @RequestParam String category,
40
        @Parameter(name="numJokes", example="2") @RequestParam String numJokes
41
    ) throws JsonProcessingException {
42
        log.info("getJokesQuery: category={}, numJokes={}", category,numJokes);
43
        String result = JokeQueryService.getJSON(category, numJokes);
44 1 1. getJokesQuery : replaced return value with null for edu/ucsb/cs156/spring/backenddemo/controllers/JokeController::getJokesQuery → KILLED
        return ResponseEntity.ok().body(result);
45
    }
46
}
47

Mutations

44

1.1
Location : getJokesQuery
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::getJokesQuery → KILLED

Active mutators

Tests examined


Report generated by PIT 1.7.3