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
  @Value("${app.sourceRepo:https://github.com/ucsb-cs156/proj-courses}")
28
  private String sourceRepo;
29
30
  @Value("${app.feedbackUrl:}")
31
  private String appFeedbackUrl;
32
33
  @Value("${git.commit.message.short:unknown}")
34
  private String commitMessage;
35
36
  @Value("${git.commit.id.abbrev:unknown}")
37
  private String commitId;
38
39
  @Autowired private UCSBAPIQuarterService ucsbAPIQuarterService;
40
41
  @Autowired private SystemMessagesService systemMessagesService;
42
43
  public static String githubUrl(String repo, String commit) {
44 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;
45
  }
46
47
  public SystemInfo getSystemInfo() {
48
    String endQtrYYYYQ = null;
49
    try {
50
      endQtrYYYYQ = ucsbAPIQuarterService.getEndQtrYYYYQ();
51
    } catch (Exception e) {
52
      log.error("Error in ucsbAPIQuarterService.getEndQtrYYYYQ():", e);
53
    }
54
55
    SystemInfo si =
56
        SystemInfo.builder()
57
            .springH2ConsoleEnabled(this.springH2ConsoleEnabled)
58
            .showSwaggerUILink(this.showSwaggerUILink)
59
            .startQtrYYYYQ(this.startQtrYYYYQ)
60
            .endQtrYYYYQ(endQtrYYYYQ)
61
            .sourceRepo(this.sourceRepo)
62
            .appFeedbackUrl(this.appFeedbackUrl)
63
            .commitMessage(this.commitMessage)
64
            .commitId(this.commitId)
65
            .githubUrl(githubUrl(this.sourceRepo, this.commitId))
66
            .systemMessages(systemMessagesService.getMessages())
67
            .build();
68
    log.info("getSystemInfo returns {}", si);
69 1 1. getSystemInfo : replaced return value with null for edu/ucsb/cs156/courses/services/SystemInfoServiceImpl::getSystemInfo → KILLED
    return si;
70
  }
71
}

Mutations

44

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

69

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