| 1 | package edu.ucsb.cs156.courses.services; | |
| 2 | ||
| 3 | import edu.ucsb.cs156.courses.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 | // This class relies on property values | |
| 10 | // For hints on testing, see: https://www.baeldung.com/spring-boot-testing-configurationproperties | |
| 11 | ||
| 12 | @Slf4j | |
| 13 | @Service("systemInfo") | |
| 14 | @ConfigurationProperties | |
| 15 | public class SystemInfoServiceImpl extends SystemInfoService { | |
| 16 | ||
| 17 | @Value("${spring.h2.console.enabled:false}") | |
| 18 | private boolean springH2ConsoleEnabled; | |
| 19 | ||
| 20 | @Value("${app.showSwaggerUILink:false}") | |
| 21 | private boolean showSwaggerUILink; | |
| 22 | ||
| 23 | @Value("${app.startQtrYYYYQ:20221}") | |
| 24 | private String startQtrYYYYQ; | |
| 25 | ||
| 26 | @Value("${app.endQtrYYYYQ:20222}") | |
| 27 | private String endQtrYYYYQ; | |
| 28 | ||
| 29 | @Value("${app.sourceRepo:https://github.com/ucsb-cs156/proj-courses}") | |
| 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 : replaced return value with "" for edu/ucsb/cs156/courses/services/SystemInfoServiceImpl::githubUrl → KILLED 2. githubUrl : negated conditional → KILLED 3. githubUrl : negated conditional → KILLED |
return commit != null && repo != null ? repo + "/commit/" + commit : null; |
| 40 | } | |
| 41 | ||
| 42 | public SystemInfo getSystemInfo() { | |
| 43 | SystemInfo si = | |
| 44 | SystemInfo.builder() | |
| 45 | .springH2ConsoleEnabled(this.springH2ConsoleEnabled) | |
| 46 | .showSwaggerUILink(this.showSwaggerUILink) | |
| 47 | .startQtrYYYYQ(this.startQtrYYYYQ) | |
| 48 | .endQtrYYYYQ(this.endQtrYYYYQ) | |
| 49 | .sourceRepo(this.sourceRepo) | |
| 50 | .commitMessage(this.commitMessage) | |
| 51 | .commitId(this.commitId) | |
| 52 | .githubUrl(githubUrl(this.sourceRepo, this.commitId)) | |
| 53 | .build(); | |
| 54 | log.info("getSystemInfo returns {}", si); | |
| 55 |
1
1. getSystemInfo : replaced return value with null for edu/ucsb/cs156/courses/services/SystemInfoServiceImpl::getSystemInfo → KILLED |
return si; |
| 56 | } | |
| 57 | } | |
Mutations | ||
| 39 |
1.1 2.2 3.3 |
|
| 55 |
1.1 |