| 1 | package edu.ucsb.cs156.organic.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.organic.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 | @ConfigurationProperties | |
| 18 | @PropertySources({ | |
| 19 | @PropertySource("classpath:git.properties") | |
| 20 | }) | |
| 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.sourceRepo}") | |
| 30 | private String sourceRepo; | |
| 31 | ||
| 32 | @Value("${git.commit.message.short:unknown}") | |
| 33 | private String commitMessage; | |
| 34 | ||
| 35 | @Value("${git.commit.id.abbrev:unknown}") | |
| 36 | private String commitId; | |
| 37 | ||
| 38 | public static String githubUrl(String repo, String commit) { | |
| 39 |
3
1. githubUrl : negated conditional → KILLED 2. githubUrl : negated conditional → KILLED 3. githubUrl : replaced return value with "" for edu/ucsb/cs156/organic/services/SystemInfoServiceImpl::githubUrl → KILLED |
return commit != null && repo != null ? repo + "/commit/" + commit : null; |
| 40 | } | |
| 41 | ||
| 42 | public SystemInfo getSystemInfo() { | |
| 43 | SystemInfo si = SystemInfo.builder() | |
| 44 | .springH2ConsoleEnabled(this.springH2ConsoleEnabled) | |
| 45 | .showSwaggerUILink(this.showSwaggerUILink) | |
| 46 | .sourceRepo(this.sourceRepo) | |
| 47 | .commitMessage(this.commitMessage) | |
| 48 | .commitId(this.commitId) | |
| 49 | .githubUrl(githubUrl(sourceRepo, commitId)) | |
| 50 | .build(); | |
| 51 | log.info("getSystemInfo returns {}",si); | |
| 52 |
1
1. getSystemInfo : replaced return value with null for edu/ucsb/cs156/organic/services/SystemInfoServiceImpl::getSystemInfo → KILLED |
return si; |
| 53 | } | |
| 54 | ||
| 55 | } | |
Mutations | ||
| 39 |
1.1 2.2 3.3 |
|
| 52 |
1.1 |