Skip to content
This repository was archived by the owner on Apr 5, 2024. It is now read-only.

Commit 973c044

Browse files
committed
Merge branch 'feature/fix_tests'
# Conflicts: # .run/RestApplication.run.xml # src/test/java/de/filefighter/rest/RestApplicationTests.java
2 parents c9ad381 + 8f858a3 commit 973c044

16 files changed

+250
-21
lines changed

.run/TESTS.run.xml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<component name="ProjectRunConfigurationManager">
2+
<configuration default="false" name="TESTS" type="MavenRunConfiguration" factoryName="Maven">
3+
<MavenSettings>
4+
<option name="myGeneralSettings" />
5+
<option name="myRunnerSettings" />
6+
<option name="myRunnerParameters">
7+
<MavenRunnerParameters>
8+
<option name="profiles">
9+
<set />
10+
</option>
11+
<option name="goals">
12+
<list>
13+
<option value="clean" />
14+
<option value="test" />
15+
</list>
16+
</option>
17+
<option name="pomFileName" value="pom.xml" />
18+
<option name="profilesMap">
19+
<map />
20+
</option>
21+
<option name="resolveToWorkspace" value="false" />
22+
<option name="workingDirPath" value="$PROJECT_DIR$" />
23+
</MavenRunnerParameters>
24+
</option>
25+
</MavenSettings>
26+
<method v="2" />
27+
</configuration>
28+
</component>

src/main/java/de/filefighter/rest/config/SwaggerConfiguration.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ private ApiInfo apiInfo() {
3030
"REST-API of the FileFighter application.",
3131
"0.1",
3232
"terms of service url",
33-
new Contact("FileFighter Dev-Team", "https://github.com/filefighter/", "comming soon"),
33+
new Contact("FileFighter Dev-Team", "https://github.com/filefighter/", "[email protected]"),
3434
"MIT License",
3535
"https://github.com/filefighter/restapi/blob/master/LICENSE",
3636
Collections.emptyList()

src/main/java/de/filefighter/rest/health/business/SystemHealthBusinessService.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,20 @@
88
@Service
99
public class SystemHealthBusinessService {
1010

11-
private final long serverStartedAt = Instant.now().getEpochSecond();
11+
private final long serverStartedAt;
12+
13+
public SystemHealthBusinessService() {
14+
this.serverStartedAt = this.getCurrentEpochSeconds();
15+
}
1216

1317
public SystemHealth getCurrentSystemHealthInfo(){
14-
long currentEpoch = Instant.now().getEpochSecond();
18+
long currentEpoch = getCurrentEpochSeconds();
1519
return SystemHealth.builder()
1620
.uptimeInSeconds(currentEpoch - serverStartedAt)
1721
.create();
1822
}
23+
24+
public long getCurrentEpochSeconds(){
25+
return Instant.now().getEpochSecond();
26+
}
1927
}

src/main/java/de/filefighter/rest/health/business/SystemHealthModelAssembler.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package de.filefighter.rest.health.business;
22

33
import de.filefighter.rest.health.data.SystemHealth;
4-
import de.filefighter.rest.health.rest.HealthRestController;
4+
import de.filefighter.rest.health.rest.SystemHealthRestController;
55
import org.jetbrains.annotations.NotNull;
66
import org.springframework.hateoas.EntityModel;
77
import org.springframework.hateoas.server.RepresentationModelAssembler;
@@ -16,6 +16,6 @@ public class SystemHealthModelAssembler implements RepresentationModelAssembler<
1616
@Override
1717
public @NotNull EntityModel<SystemHealth> toModel(@NotNull SystemHealth entity) {
1818
return EntityModel.of(entity,
19-
linkTo(methodOn(HealthRestController.class).getSystemHealthInfo()).withSelfRel());
19+
linkTo(methodOn(SystemHealthRestController.class).getSystemHealthInfo()).withSelfRel());
2020
}
2121
}
Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
package de.filefighter.rest.health.data;
22

33
import lombok.Builder;
4-
import lombok.Data;
4+
import lombok.Getter;
55

6-
@Data
6+
/**
7+
* This class is a representation of the json model.
8+
*/
9+
10+
@Getter
711
@Builder(buildMethodName = "create")
812
public class SystemHealth {
9-
private long uptimeInSeconds;
13+
private final long uptimeInSeconds;
1014
}

src/main/java/de/filefighter/rest/health/rest/HealthRestController.java renamed to src/main/java/de/filefighter/rest/health/rest/SystemHealthRestController.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,15 @@
44
import io.swagger.annotations.Api;
55
import org.springframework.hateoas.EntityModel;
66
import org.springframework.web.bind.annotation.GetMapping;
7-
import org.springframework.web.bind.annotation.RequestMapping;
87
import org.springframework.web.bind.annotation.RestController;
98

109
@RestController
1110
@Api(value = "System Health", tags = { "SystemHealth" })
12-
public class HealthRestController {
11+
public class SystemHealthRestController {
1312

14-
private final HealthRestInterface healthRestService;
13+
private final SystemHealthRestInterface healthRestService;
1514

16-
public HealthRestController(HealthRestInterface healthRestService) {
15+
public SystemHealthRestController(SystemHealthRestInterface healthRestService) {
1716
this.healthRestService = healthRestService;
1817
}
1918

src/main/java/de/filefighter/rest/health/rest/HealthRestInterface.java renamed to src/main/java/de/filefighter/rest/health/rest/SystemHealthRestInterface.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@
33
import de.filefighter.rest.health.data.SystemHealth;
44
import org.springframework.hateoas.EntityModel;
55

6-
public interface HealthRestInterface {
6+
public interface SystemHealthRestInterface {
77
EntityModel<SystemHealth> getSystemHealth();
88
}

src/main/java/de/filefighter/rest/health/rest/HealthRestService.java renamed to src/main/java/de/filefighter/rest/health/rest/SystemHealthRestService.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@
77
import org.springframework.stereotype.Service;
88

99
@Service
10-
public class HealthRestService implements HealthRestInterface{
10+
public class SystemHealthRestService implements SystemHealthRestInterface {
1111

1212
private final SystemHealthBusinessService systemHealthBusinessService;
1313
private final SystemHealthModelAssembler systemHealthModelAssembler;
1414

15-
public HealthRestService(SystemHealthBusinessService systemHealthBusinessService, SystemHealthModelAssembler systemHealthModelAssembler) {
15+
public SystemHealthRestService(SystemHealthBusinessService systemHealthBusinessService, SystemHealthModelAssembler systemHealthModelAssembler) {
1616
this.systemHealthBusinessService = systemHealthBusinessService;
1717
this.systemHealthModelAssembler = systemHealthModelAssembler;
1818
}

src/main/java/de/filefighter/rest/rest/RestErrorController.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,15 @@
1010
@RestController
1111
public class RestErrorController implements ErrorController {
1212

13-
private static final String DEFAULT_PATH = "/error";
13+
public static final String DEFAULT_ERROR_PATH = "/error";
1414

15-
@RequestMapping(value = DEFAULT_PATH)
15+
@RequestMapping(value = DEFAULT_ERROR_PATH)
1616
public EntityModel<ServerResponse> error() {
1717
return new ServerResponse("denied", "This endpoint does not exist.").toModel();
1818
}
1919

2020
@Override
2121
public String getErrorPath() {
22-
return DEFAULT_PATH;
22+
return DEFAULT_ERROR_PATH;
2323
}
2424
}

src/main/java/de/filefighter/rest/rest/ServerResponse.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
package de.filefighter.rest.rest;
22

33
import lombok.Data;
4+
import lombok.Getter;
45
import org.springframework.hateoas.EntityModel;
56

6-
@Data
7+
@Getter
78
public class ServerResponse {
8-
private String message;
9-
private String status;
9+
private final String message;
10+
private final String status;
1011

1112
public ServerResponse(String status, String message) {
1213
this.status = status;

0 commit comments

Comments
 (0)