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.Value;
6
import org.springframework.boot.context.properties.ConfigurationProperties;
7
import org.springframework.stereotype.Service;
8
9
// This class relies on property values
10
// For hints on testing, see: https://www.baeldung.com/spring-boot-testing-configurationproperties
11
12
@Slf4j
13
@Service("systemInfo")
14
@ConfigurationProperties
15
public class SystemInfoServiceImpl extends SystemInfoService {
16
17
  private final UCSBAPIQuarterService ucsbapiQuarterService;
18
19
  public SystemInfoServiceImpl(UCSBAPIQuarterService ucsbapiQuarterService) {
20
    this.ucsbapiQuarterService = ucsbapiQuarterService;
21
  }
22
23
  @Value("${spring.h2.console.enabled:false}")
24
  private boolean springH2ConsoleEnabled;
25
26
  @Value("${app.showSwaggerUILink:false}")
27
  private boolean showSwaggerUILink;
28
29
  @Value("${app.startQtrYYYYQ:20221}")
30
  private String startQtrYYYYQ;
31
32
  @Value("${app.sourceRepo:https://github.com/ucsb-cs156/proj-courses}")
33
  private String sourceRepo;
34
35
  @Value("${git.commit.message.short:unknown}")
36
  private String commitMessage;
37
38
  @Value("${git.commit.id.abbrev:unknown}")
39
  private String commitId;
40
41
  public static String githubUrl(String repo, String commit) {
42 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;
43
  }
44
45
  public SystemInfo getSystemInfo() {
46
47
    String endQtrYYYYQ;
48
49
    try {
50
      endQtrYYYYQ = this.ucsbapiQuarterService.getCurrentEndQuarterYYYYQ();
51
    } catch (Exception e) {
52
      log.error("Can't get current quarter from UCSBAPIQuarterService: ", e);
53
      endQtrYYYYQ = this.startQtrYYYYQ;
54
    }
55
56
    SystemInfo si =
57
        SystemInfo.builder()
58
            .springH2ConsoleEnabled(this.springH2ConsoleEnabled)
59
            .showSwaggerUILink(this.showSwaggerUILink)
60
            .startQtrYYYYQ(this.startQtrYYYYQ)
61
            .endQtrYYYYQ(endQtrYYYYQ)
62
            .sourceRepo(this.sourceRepo)
63
            .commitMessage(this.commitMessage)
64
            .commitId(this.commitId)
65
            .githubUrl(githubUrl(this.sourceRepo, this.commitId))
66
            .build();
67
    log.info("getSystemInfo returns {}", si);
68 1 1. getSystemInfo : replaced return value with null for edu/ucsb/cs156/courses/services/SystemInfoServiceImpl::getSystemInfo → KILLED
    return si;
69
  }
70
}

Mutations

42

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

68

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