SystemInfoServiceImpl.java

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

Mutations

45

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

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

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

64

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

Active mutators

Tests examined


Report generated by PIT 1.7.3