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