PublicHolidayQueryService.java

1
package edu.ucsb.cs156.spring.backenddemo.services;
2
3
import org.springframework.web.client.RestTemplate;
4
5
import lombok.extern.slf4j.Slf4j;
6
7
import java.util.List;
8
import java.util.Map;
9
10
import org.springframework.boot.web.client.RestTemplateBuilder;
11
import org.springframework.http.HttpEntity;
12
import org.springframework.http.HttpHeaders;
13
import org.springframework.http.HttpMethod;
14
import org.springframework.http.MediaType;
15
import org.springframework.http.ResponseEntity;
16
import org.springframework.stereotype.Service;
17
import org.springframework.web.client.HttpClientErrorException;
18
19
@Slf4j
20
@Service
21
public class PublicHolidayQueryService {
22
23
24
    private final RestTemplate restTemplate;
25
26
    public PublicHolidayQueryService(RestTemplateBuilder restTemplateBuilder) {
27
        restTemplate = restTemplateBuilder.build();
28
    }
29
30
    public static final String ENDPOINT = "https://date.nager.at/api/v2/publicholidays/{year}/{countryCode}";
31
32
    public String getJSON(String year, String countryCode) throws HttpClientErrorException {
33
        log.info("year={}, countryCode={}", year, countryCode);
34
        HttpHeaders headers = new HttpHeaders();
35 1 1. getJSON : removed call to org/springframework/http/HttpHeaders::setAccept → KILLED
        headers.setAccept(List.of(MediaType.APPLICATION_JSON));
36 1 1. getJSON : removed call to org/springframework/http/HttpHeaders::setContentType → KILLED
        headers.setContentType(MediaType.APPLICATION_JSON);
37
38
        HttpEntity<String> entity = new HttpEntity<>(headers);
39
40
        Map<String, String> uriVariables = Map.of("year", year, "countryCode", countryCode);
41
42
        ResponseEntity<String> re = restTemplate.exchange(ENDPOINT, HttpMethod.GET, entity, String.class,
43
                uriVariables);
44 1 1. getJSON : replaced return value with "" for edu/ucsb/cs156/spring/backenddemo/services/PublicHolidayQueryService::getJSON → KILLED
        return re.getBody();
45
    }
46
}

Mutations

35

1.1
Location : getJSON
Killed by : edu.ucsb.cs156.spring.backenddemo.services.PublicHolidayQueryServiceTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.spring.backenddemo.services.PublicHolidayQueryServiceTests]/[method:test_getJSON()]
removed call to org/springframework/http/HttpHeaders::setAccept → KILLED

36

1.1
Location : getJSON
Killed by : edu.ucsb.cs156.spring.backenddemo.services.PublicHolidayQueryServiceTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.spring.backenddemo.services.PublicHolidayQueryServiceTests]/[method:test_getJSON()]
removed call to org/springframework/http/HttpHeaders::setContentType → KILLED

44

1.1
Location : getJSON
Killed by : edu.ucsb.cs156.spring.backenddemo.services.PublicHolidayQueryServiceTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.spring.backenddemo.services.PublicHolidayQueryServiceTests]/[method:test_getJSON()]
replaced return value with "" for edu/ucsb/cs156/spring/backenddemo/services/PublicHolidayQueryService::getJSON → KILLED

Active mutators

Tests examined


Report generated by PIT 1.7.3