SystemInfoServiceImpl.java

1
package edu.ucsb.cs156.courses.services;
2
3
import edu.ucsb.cs156.courses.models.SystemInfo;
4
import lombok.extern.slf4j.Slf4j;
5
import org.springframework.beans.factory.annotation.Autowired;
6
import org.springframework.beans.factory.annotation.Value;
7
import org.springframework.boot.context.properties.ConfigurationProperties;
8
import org.springframework.stereotype.Service;
9
10
// This class relies on property values
11
// For hints on testing, see: https://www.baeldung.com/spring-boot-testing-configurationproperties
12
13
@Slf4j
14
@Service("systemInfo")
15
@ConfigurationProperties
16
public class SystemInfoServiceImpl extends SystemInfoService {
17
18
  @Value("${spring.h2.console.enabled:false}")
19
  private boolean springH2ConsoleEnabled;
20
21
  @Value("${app.showSwaggerUILink:false}")
22
  private boolean showSwaggerUILink;
23
24
  @Value("${app.startQtrYYYYQ:20221}")
25
  private String startQtrYYYYQ;
26
27
  @Autowired private UCSBAPIQuarterService ucsbApiQuarterService;
28
29
  @Value("${app.sourceRepo:https://github.com/ucsb-cs156/proj-courses}")
30
  private String sourceRepo;
31
32
  @Value("${git.commit.message.short:unknown}")
33
  private String commitMessage;
34
35
  @Value("${git.commit.id.abbrev:unknown}")
36
  private String commitId;
37
38
  public static String githubUrl(String repo, String commit) {
39 3 1. githubUrl : replaced return value with "" for edu/ucsb/cs156/courses/services/SystemInfoServiceImpl::githubUrl → KILLED
2. githubUrl : negated conditional → KILLED
3. githubUrl : negated conditional → KILLED
    return commit != null && repo != null ? repo + "/commit/" + commit : null;
40
  }
41
42
  public SystemInfo getSystemInfo() {
43
    String endQtr = null;
44
    try {
45
      // prefer runtime-computed END_QTR when available
46
      endQtr = ucsbApiQuarterService.getEndQtrYYYYQ();
47
    } catch (Exception e) {
48
      log.warn("Unable to compute runtime endQtrYYYYQ; END_QTR config is deprecated", e);
49
    }
50
51
    SystemInfo si =
52
        SystemInfo.builder()
53
            .springH2ConsoleEnabled(this.springH2ConsoleEnabled)
54
            .showSwaggerUILink(this.showSwaggerUILink)
55
            .startQtrYYYYQ(this.startQtrYYYYQ)
56
            .endQtrYYYYQ(endQtr)
57
            .sourceRepo(this.sourceRepo)
58
            .commitMessage(this.commitMessage)
59
            .commitId(this.commitId)
60
            .githubUrl(githubUrl(this.sourceRepo, this.commitId))
61
            .build();
62
    log.info("getSystemInfo returns {}", si);
63 1 1. getSystemInfo : replaced return value with null for edu/ucsb/cs156/courses/services/SystemInfoServiceImpl::getSystemInfo → KILLED
    return si;
64
  }
65
}

Mutations

39

1.1
Location : githubUrl
Killed by : edu.ucsb.cs156.courses.services.SystemInfoServiceImplTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.courses.services.SystemInfoServiceImplTests]/[method:test_githubUrl()]
replaced return value with "" for edu/ucsb/cs156/courses/services/SystemInfoServiceImpl::githubUrl → KILLED

2.2
Location : githubUrl
Killed by : edu.ucsb.cs156.courses.services.SystemInfoServiceImplTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.courses.services.SystemInfoServiceImplTests]/[method:test_githubUrl()]
negated conditional → KILLED

3.3
Location : githubUrl
Killed by : edu.ucsb.cs156.courses.services.SystemInfoServiceImplTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.courses.services.SystemInfoServiceImplTests]/[method:test_githubUrl()]
negated conditional → KILLED

63

1.1
Location : getSystemInfo
Killed by : edu.ucsb.cs156.courses.services.SystemInfoServiceImplTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.courses.services.SystemInfoServiceImplTests]/[method:test_getSystemInfo_when_quarter_service_fails_returns_null_end_qtr()]
replaced return value with null for edu/ucsb/cs156/courses/services/SystemInfoServiceImpl::getSystemInfo → KILLED

Active mutators

Tests examined


Report generated by PIT 1.17.0