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

Commit e2d9f52

Browse files
committed
fixed pipelines, added integration test
1 parent faf749e commit e2d9f52

File tree

6 files changed

+89
-3
lines changed

6 files changed

+89
-3
lines changed

.github/workflows/feature_branch_tests.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,11 @@ jobs:
2121
with:
2222
java-version: '11.0.8'
2323
architecture: x64
24+
-
25+
name: Setup database for tests.
26+
run: |
27+
docker create -p 27017 --name FileFighterDB mongo:latest
28+
docker run FileFighterDB
2429
-
2530
name: Run all Tests
2631
run: mvn clean test -f pom.xml
@@ -46,6 +51,6 @@ jobs:
4651
IMAGE_ID=$(docker images rest -q)
4752
VERSION=${{ steps.vars.outputs.branch }}
4853
IFS=';' read -ra ADDR <<< "$VERSION"
49-
VERSION=ADDR[1]
54+
VERSION=$ADDR[1]
5055
docker tag $IMAGE_ID filefighter/rest:$VERSION
5156
docker push filefighter/rest:$VERSION

.github/workflows/latestRelease.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@ jobs:
2222
with:
2323
java-version: '11.0.8'
2424
architecture: x64
25+
-
26+
name: Setup database for tests.
27+
run: |
28+
docker create -p 27017 --name FileFighterDB mongo:latest
29+
docker run FileFighterDB
2530
-
2631
name: Run all Tests
2732
run: mvn clean test -f pom.xml

.github/workflows/stableRelease.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@ jobs:
1616
with:
1717
java-version: '11.0.8'
1818
architecture: x64
19+
-
20+
name: Setup database for tests.
21+
run: |
22+
docker create -p 27017 --name FileFighterDB mongo:latest
23+
docker run FileFighterDB
1924
-
2025
name: Run all Tests
2126
run: mvn clean test -f pom.xml

.run/RestApplication.run.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<component name="ProjectRunConfigurationManager">
22
<configuration default="false" name="RestApplication[DEV]" type="SpringBootApplicationConfigurationType" factoryName="Spring Boot">
3-
<module name="RestApi" />
3+
<module name="rest" />
44
<option name="SPRING_BOOT_MAIN_CLASS" value="de.filefighter.rest.RestApplication" />
55
<option name="ACTIVE_PROFILES" value="dev" />
66
<option name="ALTERNATIVE_JRE_PATH" />

.run/RestApplication[PROD].run.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<component name="ProjectRunConfigurationManager">
22
<configuration default="false" name="RestApplication[PROD]" type="SpringBootApplicationConfigurationType" factoryName="Spring Boot">
3-
<module name="RestApi" />
3+
<module name="rest" />
44
<option name="SPRING_BOOT_MAIN_CLASS" value="de.filefighter.rest.RestApplication" />
55
<option name="ACTIVE_PROFILES" value="prod" />
66
<option name="ALTERNATIVE_JRE_PATH" />
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
package de.filefighter.rest.domain.health.rest;
2+
3+
import de.filefighter.rest.domain.filesystem.data.persistance.FileSystemRepository;
4+
import de.filefighter.rest.domain.token.data.persistance.AccessTokenRepository;
5+
import de.filefighter.rest.domain.user.data.persistance.UserEntitiy;
6+
import de.filefighter.rest.domain.user.data.persistance.UserRepository;
7+
import org.junit.jupiter.api.BeforeEach;
8+
import org.junit.jupiter.api.Test;
9+
10+
import org.slf4j.Logger;
11+
import org.slf4j.LoggerFactory;
12+
import org.springframework.beans.factory.annotation.Autowired;
13+
import org.springframework.boot.test.context.SpringBootTest;
14+
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
15+
import org.springframework.boot.test.web.client.TestRestTemplate;
16+
import org.springframework.boot.web.server.LocalServerPort;
17+
18+
import static org.assertj.core.api.Assertions.assertThat;
19+
import static org.junit.Assert.assertTrue;
20+
21+
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT)
22+
public class SystemHealthRestIntegrationTest {
23+
24+
private final Logger LOG = LoggerFactory.getLogger(SystemHealthRestIntegrationTest.class);
25+
26+
@LocalServerPort
27+
private int port;
28+
29+
@Autowired
30+
private TestRestTemplate restTemplate;
31+
32+
@Autowired
33+
private UserRepository userRepository;
34+
35+
@Autowired
36+
private FileSystemRepository fileSystemRepository;
37+
38+
@Autowired
39+
private AccessTokenRepository accessTokenRepository;
40+
41+
42+
@BeforeEach
43+
public void cleanDbs(){
44+
LOG.info("Cleaning Databases.");
45+
userRepository.deleteAll();
46+
fileSystemRepository.deleteAll();
47+
accessTokenRepository.deleteAll();
48+
}
49+
50+
@Test
51+
public void healthCheckShouldReturnUptime() {
52+
LOG.info("Running: healthCheckShouldReturnUptime");
53+
String jsonString = this.restTemplate.getForObject("http://localhost:" + port + "/health", String.class);
54+
assertTrue(jsonString.contains("uptimeInSeconds"));
55+
}
56+
57+
@Test
58+
public void healthCheckShouldReturnUserCount() {
59+
LOG.info("Running: healthCheckShouldReturnUserCount");
60+
String jsonString = this.restTemplate.getForObject("http://localhost:" + port + "/health", String.class);
61+
assertTrue(jsonString.contains("userCount"));
62+
}
63+
64+
/*@Test
65+
public void healthCheckShouldReturnCorrectUserCount() {
66+
LOG.info("Running: healthCheckShouldReturnCorrectUserCount");
67+
LOG.info("Preloading default admin user: " + userRepository.save(new UserEntitiy(0L, "admin", "admin", "refreshToken1234", 0, 1)));
68+
String jsonString = this.restTemplate.getForObject("http://localhost:" + port + "/health", String.class);
69+
assertTrue(jsonString.contains("userCount") && jsonString.contains(":1"));
70+
}*/
71+
}

0 commit comments

Comments
 (0)