Skip to content

Commit 2829090

Browse files
feat: Add testing for matching service
Tests currently fail. Will be fixed in next commit
1 parent 2afda4d commit 2829090

5 files changed

Lines changed: 181 additions & 2 deletions

File tree

.github/workflows/java_tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
strategy:
1616
matrix:
1717
# Add any future services relative paths from . here
18-
service: [user]
18+
service: [user, matching]
1919

2020
steps:
2121

deployment/debug/compose.yml

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
# This file is used to deploy the microservices using Docker Compose.
2+
# It defines the services, their images, build context, and ports.
3+
4+
services:
5+
gateway-service:
6+
build: ../../server/gateway
7+
container_name: meetatmensa-gateway
8+
ports:
9+
- "8080:80"
10+
depends_on:
11+
- matching-service
12+
- user-service
13+
- genai-service
14+
networks:
15+
- backend
16+
17+
matching-service:
18+
build: ../../server/matching
19+
container_name: meetatmensa-matching
20+
expose:
21+
- "80"
22+
ports:
23+
- "8081:80"
24+
depends_on:
25+
- match-database
26+
networks:
27+
- backend
28+
29+
user-service:
30+
build: ../../server/user
31+
container_name: meetatmensa-user
32+
expose:
33+
- "80"
34+
ports:
35+
- "8082:80"
36+
depends_on:
37+
- user-database
38+
networks:
39+
- backend
40+
41+
genai-service:
42+
build: ../../server/genai
43+
container_name: meetatmensa-genai
44+
expose:
45+
- "80"
46+
ports:
47+
- "8083:80"
48+
networks:
49+
- backend
50+
51+
client-service:
52+
build: ../../client
53+
container_name: meetatmensa-client
54+
ports:
55+
- "80:80"
56+
57+
match-database:
58+
build: ../../server/database/matchdb
59+
container_name: meetatmensa-matchdb
60+
# TODO: Implement password passed via secret
61+
environment:
62+
- MYSQL_ROOT_PASSWORD=root
63+
volumes:
64+
- matchdb_data:/var/lib/mysql
65+
expose:
66+
- "3306"
67+
networks:
68+
- backend
69+
70+
user-database:
71+
build: ../../server/database/userdb
72+
container_name: meetatmensa-userdb
73+
# TODO: Implement password passed via secret
74+
environment:
75+
- MYSQL_ROOT_PASSWORD=root
76+
volumes:
77+
- userdb_data:/var/lib/mysql
78+
expose:
79+
- "3306"
80+
networks:
81+
- backend
82+
83+
networks:
84+
backend:
85+
driver: bridge
86+
87+
volumes:
88+
matchdb_data:
89+
userdb_data:

server/matching/build.gradle

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ dependencies {
2323
implementation 'org.springframework.boot:spring-boot-starter-web'
2424
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
2525
testImplementation 'org.springframework.boot:spring-boot-starter-test'
26+
testImplementation 'org.testcontainers:testcontainers:1.21.3'
27+
testImplementation 'org.testcontainers:mysql:1.21.3'
28+
testImplementation "org.testcontainers:junit-jupiter:1.21.3"
2629
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
2730
runtimeOnly 'com.mysql:mysql-connector-j:9.3.0'
2831
}

server/matching/src/test/java/meet_at_mensa/matching/MatchingApplicationTests.java

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,31 @@
22

33
import org.junit.jupiter.api.Test;
44
import org.springframework.boot.test.context.SpringBootTest;
5+
import org.springframework.test.context.DynamicPropertyRegistry;
6+
import org.springframework.test.context.DynamicPropertySource;
7+
import org.testcontainers.containers.MySQLContainer;
8+
import org.testcontainers.junit.jupiter.Container;
9+
import org.testcontainers.junit.jupiter.Testcontainers;
510

611
@SpringBootTest
7-
// MatchingApplicationTests is a test class for the matching application
12+
@Testcontainers
13+
// MatchingpplicationTests is a test class for the matching application
814
class MatchingApplicationTests {
915

16+
@Container
17+
static MySQLContainer<?> matchdb = new MySQLContainer<>("mysql:8.0")
18+
.withDatabaseName("matchdb")
19+
.withInitScript("init_matchdb_test.sql")
20+
.withUsername("root")
21+
.withPassword("root");
22+
23+
@DynamicPropertySource
24+
static void overrideProps(DynamicPropertyRegistry registry) {
25+
registry.add("spring.datasource.url", matchdb::getJdbcUrl);
26+
registry.add("spring.datasource.username", matchdb::getUsername);
27+
registry.add("spring.datasource.password", matchdb::getPassword);
28+
}
29+
1030
@Test
1131
void contextLoads() {
1232
}
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
-- matches table
2+
-- which user has been matched with which group
3+
-- match_id: UUID of the match, primary key
4+
-- user_id: UUID of the matched user
5+
-- group_id: UUID of group the user has been matched to
6+
-- invite_status: Has the user RSVP'd?
7+
CREATE TABLE IF NOT EXISTS `matches` (
8+
match_id VARBINARY(16) PRIMARY KEY,
9+
user_id VARBINARY(16) NOT NULL,
10+
group_id VARBINARY(16) NOT NULL,
11+
invite_status VARCHAR(255) NOT NULL
12+
);
13+
14+
-- groups table
15+
-- information about groups
16+
-- group_id: UUID of the group
17+
-- meet_date: date a group is set to meet
18+
-- meet_timeslot: time a group is set to meet, encoded as Integer
19+
-- meet_location: mensa a group is set to meet at
20+
CREATE TABLE IF NOT EXISTS `groups` (
21+
group_id VARBINARY(16) PRIMARY KEY,
22+
meet_date DATE NOT NULL,
23+
meet_timeslot INT NOT NULL,
24+
meet_location VARCHAR(255) NOT NULL
25+
);
26+
27+
-- prompts table
28+
-- contains conversation starters
29+
-- prompt_id: UUID of the prompt
30+
-- group_id: UUID of the group this conversation starter prompt belongs to
31+
-- prompt: prompt itself
32+
CREATE TABLE IF NOT EXISTS `prompts` (
33+
prompt_id VARBINARY(16) PRIMARY KEY,
34+
group_id VARBINARY(16) NOT NULL,
35+
prompt VARCHAR(1023) NOT NULL
36+
);
37+
38+
-- match requests table
39+
-- individual match requests
40+
-- request_id: UUID of the request, primary key
41+
-- user_id: UUID of user making the request
42+
-- group_id: UUID of the group the user was matched to. Null if Unmatched
43+
-- request_date: date the user would like to be matched
44+
-- degree_pref: does user prefer matches with same degree?
45+
-- age_pref: does user prefer matches with same age?
46+
-- gender_pref: does user prefer matches with same gender?
47+
CREATE TABLE IF NOT EXISTS `match_requests` (
48+
request_id VARBINARY(16) PRIMARY KEY,
49+
user_id VARBINARY(16) NOT NULL,
50+
request_date DATE NOT NULL,
51+
request_location VARCHAR(255) NOT NULL,
52+
degree_pref BIT NOT NULL,
53+
age_pref BIT NOT NULL,
54+
gender_pref BIT NOT NULL,
55+
request_status VARCHAR(255) NOT NULL
56+
);
57+
58+
-- match timeslot table
59+
-- What time-slots has a user selected in their requests
60+
-- timeslot_id: UUID primary key (Unique)
61+
-- request_id: UUID of the corresponding request
62+
-- time_slot time slot (encoded as integer)
63+
CREATE TABLE IF NOT EXISTS `match_timeslots` (
64+
timeslot_id VARBINARY(16) PRIMARY KEY,
65+
request_id VARBINARY(16) NOT NULL,
66+
request_timeslot INT NOT NULL
67+
);

0 commit comments

Comments
 (0)