SystemInfoServiceImpl.java

1
package edu.ucsb.cs156.dining.services;
2
3
import edu.ucsb.cs156.dining.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.context.annotation.PropertySource;
8
import org.springframework.context.annotation.PropertySources;
9
import org.springframework.stereotype.Service;
10
11
/**
12
 * This is a service for getting information about the system.
13
 *
14
 * <p>This class relies on property values. For hints on testing, see: <a href=
15
 * "https://www.baeldung.com/spring-boot-testing-configurationproperties">https://www.baeldung.com/spring-boot-testing-configurationproperties</a>
16
 */
17
@Slf4j
18
@Service("systemInfo")
19
@ConfigurationProperties
20
@PropertySources(@PropertySource("classpath:git.properties"))
21
public class SystemInfoServiceImpl extends SystemInfoService {
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.oauth.login:/oauth2/authorization/google}")
30
  private String oauthLogin;
31
32
  @Value("${app.sourceRepo:https://github.com/ucsb-cs156/proj-dining}")
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 : negated conditional → KILLED
2. githubUrl : negated conditional → KILLED
3. githubUrl : replaced return value with "" for edu/ucsb/cs156/dining/services/SystemInfoServiceImpl::githubUrl → KILLED
    return commit != null && repo != null ? repo + "/commit/" + commit : null;
43
  }
44
45
  /**
46
   * This method returns the system information.
47
   *
48
   * @see edu.ucsb.cs156.dining.models.SystemInfo
49
   * @return the system information
50
   */
51
  public SystemInfo getSystemInfo() {
52
    SystemInfo si =
53
        SystemInfo.builder()
54
            .springH2ConsoleEnabled(this.springH2ConsoleEnabled)
55
            .showSwaggerUILink(this.showSwaggerUILink)
56
            .oauthLogin(this.oauthLogin)
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/dining/services/SystemInfoServiceImpl::getSystemInfo → KILLED
    return si;
64
  }
65
}

Mutations

42

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

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

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

63

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

Active mutators

Tests examined


Report generated by PIT 1.17.0