Skip to content

Commit 2f6ea46

Browse files
authored
Merge pull request #18 from BSStudio/feature/update_end_result_endpoint
update db entity, to new specifications
2 parents 43c0914 + fefe411 commit 2f6ea46

47 files changed

Lines changed: 1515 additions & 450 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,3 +163,5 @@ dist
163163
.yarn/install-state.gz
164164
.pnp.*
165165

166+
# Sdkman env config
167+
.sdkmanrc

Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
# Update gradle/gradle-wrapper.properties accordingly
2-
ARG GRADLE=gradle:6.7.1-jdk11
2+
ARG GRADLE=gradle:6.8.3-jdk11
33
ARG JDK=openjdk:11-slim
44

55
FROM $GRADLE as build
66
COPY . .
7-
RUN gradle build bootJar --parallel
7+
RUN gradle bootJar --parallel
88

99
FROM $JDK
1010
WORKDIR /home/spring
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package hu.bsstudio.robonaut.entity;
2+
3+
import lombok.Data;
4+
5+
@Data
6+
public class ScoreEntity {
7+
// speed
8+
private int speedScore;
9+
private int bestSpeedTime;
10+
11+
// calculated
12+
private int score;
13+
}

data/src/main/java/hu/bsstudio/robonaut/entity/TeamEntity.java

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@ public class TeamEntity {
2525
private boolean safetyCarWasFollowed;
2626

2727
// speed
28-
private int speedScore;
29-
private int speedBonusScore;
3028
private List<Integer> speedTimes;
3129

3230
// audience
@@ -36,8 +34,6 @@ public class TeamEntity {
3634
// qualification
3735
private int qualificationScore;
3836

39-
// calculated
40-
private int totalScore;
41-
private int rank;
42-
private int juniorRank;
37+
private ScoreEntity juniorScore;
38+
private ScoreEntity score;
4339
}

docker-compose.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ services:
1414
image: rabbitmq:management-alpine
1515
ports:
1616
- 127.0.0.1:5672:5672
17-
- 127.0.0.1:8081:15672
17+
- 127.0.0.1:8081:8081
1818
mongo:
1919
image: mongo:4.4.2-bionic
2020
ports:

gradle/wrapper/gradle-wrapper.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#Thu Mar 05 16:36:07 CET 2020
2-
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-all.zip
2+
distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.3-all.zip
33
distributionBase=GRADLE_USER_HOME
44
distributionPath=wrapper/dists
55
zipStorePath=wrapper/dists

integration/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,6 @@
1616
"@types/supertest": "^2.0.10"
1717
},
1818
"scripts": {
19-
"test": "jest"
19+
"test": "jest -i"
2020
}
2121
}

integration/src/amqp-operations.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@ const amqp = require('amqplib')
33

44
const AMQP_HOST = process.env.AMQP_HOST;
55

6+
function closeConnection(connection) {
7+
if (connection) connection.close()
8+
}
9+
610
const purgeQueue = (queue) => {
711
let _connection;
812
return amqp.connect(AMQP_HOST)
@@ -11,7 +15,7 @@ const purgeQueue = (queue) => {
1115
return connection.createChannel();
1216
})
1317
.then(channel => channel.purgeQueue(queue))
14-
.then(() => _connection.close())
18+
.finally(() => closeConnection(_connection))
1519
}
1620

17-
exports.purgeQueue = purgeQueue
21+
exports.purgeQueue = purgeQueue

integration/src/db-operations.js

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,10 @@ const {MongoClient} = require('mongodb')
44
const DB_URI = process.env.DB_HOST
55

66
const cleanDB = () => {
7-
const mongoClient = new MongoClient(DB_URI)
7+
const mongoClient = new MongoClient(DB_URI, { useUnifiedTopology: true })
88
return mongoClient.connect()
9-
.then(client => {
10-
return client.db().dropDatabase()
11-
})
12-
.then(() => mongoClient.close())
9+
.then(client => client.db().dropDatabase())
10+
.finally(() => mongoClient.close())
1311
}
1412

1513
const createDummyData = () => {
@@ -18,7 +16,7 @@ const createDummyData = () => {
1816
return {
1917
_id: i,
2018
year: 2022,
21-
teamName: "Budvári Sschönherz Stúdió",
19+
teamName: "Budvári Schönherz Stúdió",
2220
teamMembers: [
2321
"Boldizsár Márta",
2422
"Bence Csik"
@@ -49,7 +47,7 @@ const fill = () => {
4947
const dummyData = createDummyData();
5048
return collection.insertMany(dummyData);
5149
})
52-
.then(() => mongoClient.close())
50+
.finally(() => mongoClient.close())
5351
}
5452

5553
exports.cleanDB = cleanDB

integration/test/authorization.test.js

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
require('dotenv').config()
21
const request = require('supertest')
32

4-
const HOST = process.env.HOST_NAME;
3+
const {HOST_NAME} = process.env;
54

65
describe('Authorization test', () => {
76
const postEndpoint = [
@@ -13,30 +12,34 @@ describe('Authorization test', () => {
1312
'/api/speed/safetyCar/overtake',
1413
'/api/speed/timer',
1514
'/api/speed/lap',
16-
'/api/speed/result',
15+
'/api/speed/result/senior',
16+
'/api/speed/result/junior',
1717
'/api/scores/qualification',
1818
'/api/scores/audience',
19-
'/api/scores/endResult'
19+
'/api/scores/endResult/senior',
20+
'/api/scores/endResult/junior'
2021
];
2122
test.each(postEndpoint)('POST %p endpoint should return unauthorized', (endpoint) => {
22-
return request(HOST)
23+
return request(HOST_NAME)
2324
.post(endpoint)
2425
.then(response => {
2526
expect(response.status).toBe(401)
2627
});
2728
});
28-
2929
test('GET "/api/team" endpoint should return unauthorized', () => {
30-
return request(HOST)
31-
.post('/api/team')
30+
return request(HOST_NAME)
31+
.get('/api/team')
3232
.then(response => {
3333
expect(response.status).toBe(401)
3434
});
3535
});
36-
37-
test('PUT "/api/team" endpoint should return unauthorized', () => {
38-
return request(HOST)
39-
.post('/api/team')
36+
const putEndpoints = [
37+
'/api/admin/team',
38+
'/api/team',
39+
];
40+
test.each(putEndpoints)('PUT %p endpoint should return unauthorized', (endpoint) => {
41+
return request(HOST_NAME)
42+
.put(endpoint)
4043
.then(response => {
4144
expect(response.status).toBe(401)
4245
});

0 commit comments

Comments
 (0)