ZipCodeController.java

1
package edu.ucsb.cs156.spring.backenddemo.controllers;
2
3
import org.springframework.beans.factory.annotation.Autowired;
4
import org.springframework.http.ResponseEntity;
5
import org.springframework.web.bind.annotation.GetMapping;
6
import org.springframework.web.bind.annotation.RequestMapping;
7
import org.springframework.web.bind.annotation.RequestParam;
8
import org.springframework.web.bind.annotation.RestController;
9
10
import lombok.extern.slf4j.Slf4j;
11
12
import com.fasterxml.jackson.core.JsonProcessingException;
13
import com.fasterxml.jackson.databind.ObjectMapper;
14
15
import edu.ucsb.cs156.spring.backenddemo.services.EarthquakeQueryService;
16
import edu.ucsb.cs156.spring.backenddemo.services.ZipCodeQueryService;
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="Zipcode Info")
22
@Slf4j
23
@RestController
24
@RequestMapping("/api/zipcode")
25
public class ZipCodeController {
26
    ObjectMapper mapper = new ObjectMapper();
27
28
    @Autowired
29
    ZipCodeQueryService zipCodeQueryService;
30
31
    @Operation(summary = "Get info about a zipcode", description = "JSON return format documented here: https://api.zippopotam.us")
32
    @GetMapping("/get")
33
    public ResponseEntity<String> getZipCode(
34
        @Parameter(name="zipcode", description="", example="93117") @RequestParam String zipcode
35
    ) throws JsonProcessingException {
36
        log.info("getZipCode: zipcode={}", zipcode);
37
        String result = zipCodeQueryService.getJSON(zipcode);
38 1 1. getZipCode : replaced return value with null for edu/ucsb/cs156/spring/backenddemo/controllers/ZipCodeController::getZipCode → KILLED
        return ResponseEntity.ok().body(result);
39
    }
40
}

Mutations

38

1.1
Location : getZipCode
Killed by : edu.ucsb.cs156.spring.backenddemo.controllers.ZipCodeControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.spring.backenddemo.controllers.ZipCodeControllerTests]/[method:test_getZipCode()]
replaced return value with null for edu/ucsb/cs156/spring/backenddemo/controllers/ZipCodeController::getZipCode → KILLED

Active mutators

Tests examined


Report generated by PIT 1.7.3