| 1 | package edu.ucsb.cs156.dining.services; | |
| 2 | ||
| 3 | ||
| 4 | import edu.ucsb.cs156.dining.models.SystemInfo; | |
| 5 | import lombok.extern.slf4j.Slf4j; | |
| 6 | import org.springframework.beans.factory.annotation.Value; | |
| 7 | import org.springframework.boot.context.properties.ConfigurationProperties; | |
| 8 | import org.springframework.context.annotation.PropertySource; | |
| 9 | import org.springframework.context.annotation.PropertySources; | |
| 10 | import org.springframework.stereotype.Service; | |
| 11 | ||
| 12 | /** | |
| 13 |  * This is a service for getting information about the system. | |
| 14 |  *  | |
| 15 |  * This class relies on property values. For hints on testing, see: <a href= | |
| 16 |  * "https://www.baeldung.com/spring-boot-testing-configurationproperties">https://www.baeldung.com/spring-boot-testing-configurationproperties</a> | |
| 17 |  *  | |
| 18 |  */ | |
| 19 | ||
| 20 | @Slf4j | |
| 21 | @Service("systemInfo") | |
| 22 | @ConfigurationProperties | |
| 23 | @PropertySources( | |
| 24 |   @PropertySource("classpath:git.properties") | |
| 25 | ) | |
| 26 | public class SystemInfoServiceImpl extends SystemInfoService { | |
| 27 | ||
| 28 |   @Value("${spring.h2.console.enabled:false}") | |
| 29 |   private boolean springH2ConsoleEnabled; | |
| 30 | ||
| 31 |   @Value("${app.showSwaggerUILink:false}") | |
| 32 |   private boolean showSwaggerUILink; | |
| 33 | ||
| 34 |   @Value("${app.oauth.login:/oauth2/authorization/google}") | |
| 35 |   private String oauthLogin; | |
| 36 | ||
| 37 |   @Value("${app.sourceRepo:https://github.com/ucsb-cs156/proj-dining}") | |
| 38 |   private String sourceRepo; | |
| 39 | ||
| 40 |   @Value("${git.commit.message.short:unknown}") | |
| 41 |   private String commitMessage; | |
| 42 | ||
| 43 |   @Value("${git.commit.id.abbrev:unknown}") | |
| 44 |   private String commitId; | |
| 45 | ||
| 46 |   public static String githubUrl(String repo, String commit) { | |
| 47 | 
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; | 
| 48 |   } | |
| 49 | ||
| 50 |   /** | |
| 51 |    * This method returns the system information. | |
| 52 |    * @see edu.ucsb.cs156.dining.models.SystemInfo | |
| 53 |    * @return the system information | |
| 54 |    */ | |
| 55 |   public SystemInfo getSystemInfo() { | |
| 56 |     SystemInfo si = SystemInfo.builder() | |
| 57 |         .springH2ConsoleEnabled(this.springH2ConsoleEnabled) | |
| 58 |         .showSwaggerUILink(this.showSwaggerUILink) | |
| 59 |         .oauthLogin(this.oauthLogin) | |
| 60 |         .sourceRepo(this.sourceRepo) | |
| 61 |         .commitMessage(this.commitMessage) | |
| 62 |         .commitId(this.commitId) | |
| 63 |         .githubUrl(githubUrl(this.sourceRepo, this.commitId)) | |
| 64 |         .build(); | |
| 65 |     log.info("getSystemInfo returns {}", si); | |
| 66 | 
1
1. getSystemInfo : replaced return value with null for edu/ucsb/cs156/dining/services/SystemInfoServiceImpl::getSystemInfo → KILLED | 
    return si; | 
| 67 |   } | |
| 68 | ||
| 69 | } | |
Mutations | ||
| 47 | 
 
 1.1 2.2 3.3  | 
|
| 66 | 
 
 1.1  |