SystemInfoServiceImpl.java

1
package edu.ucsb.cs156.frontiers.services;
2
3
import edu.ucsb.cs156.frontiers.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
/**
10
 * This is a service for getting information about the system.
11
 *
12
 * <p>This class relies on property values. For hints on testing, see: <a href=
13
 * "https://www.baeldung.com/spring-boot-testing-configurationproperties">https://www.baeldung.com/spring-boot-testing-configurationproperties</a>
14
 */
15
@Slf4j
16
@Service("systemInfo")
17
@ConfigurationProperties
18
public class SystemInfoServiceImpl extends SystemInfoService {
19
20
  @Value("${spring.h2.console.enabled:false}")
21
  private boolean springH2ConsoleEnabled;
22
23
  @Value("${app.showSwaggerUILink:false}")
24
  private boolean showSwaggerUILink;
25
26
  @Value("${spring.security.oauth2.client.registration.azure-dev.provider:#{null}}")
27
  private String microsoftEnabled;
28
29
  @Value("${app.oauth.login:/oauth2/authorization/google}")
30
  private String oauthLogin;
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 : negated conditional → KILLED
2. githubUrl : negated conditional → KILLED
3. githubUrl : replaced return value with "" for edu/ucsb/cs156/frontiers/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.frontiers.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
63 1 1. getSystemInfo : negated conditional → KILLED
    if (this.microsoftEnabled != null) {
64 1 1. getSystemInfo : removed call to edu/ucsb/cs156/frontiers/models/SystemInfo::setActiveDirectoryUrl → KILLED
      si.setActiveDirectoryUrl("/oauth2/authorization/azure-dev");
65
    }
66
    log.info("getSystemInfo returns {}", si);
67 1 1. getSystemInfo : replaced return value with null for edu/ucsb/cs156/frontiers/services/SystemInfoServiceImpl::getSystemInfo → KILLED
    return si;
68
  }
69
}

Mutations

42

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

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

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

63

1.1
Location : getSystemInfo
Killed by : edu.ucsb.cs156.frontiers.services.SystemInfoServiceImplTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.frontiers.services.SystemInfoServiceImplTests]/[nested-class:MicrosoftEnabledInfoServiceTests]/[method:displaysMicrosoftProvider()]
negated conditional → KILLED

64

1.1
Location : getSystemInfo
Killed by : edu.ucsb.cs156.frontiers.services.SystemInfoServiceImplTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.frontiers.services.SystemInfoServiceImplTests]/[nested-class:MicrosoftEnabledInfoServiceTests]/[method:displaysMicrosoftProvider()]
removed call to edu/ucsb/cs156/frontiers/models/SystemInfo::setActiveDirectoryUrl → KILLED

67

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

Active mutators

Tests examined


Report generated by PIT 1.17.0