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

Mutations

40

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_getZipCodes()]
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