From 9396bd6a35c0363e85fcd7cef95dccad010b7281 Mon Sep 17 00:00:00 2001 From: egecan <118941751+egecansen@users.noreply.github.com> Date: Sun, 6 Jul 2025 18:31:49 +0300 Subject: [PATCH 1/5] docker-compose added --- .github/workflows/maven-manual.yml | 4 ++++ .github/workflows/maven-publish.yml | 4 ++++ .github/workflows/maven.yml | 4 ++++ .gitignore | 1 - docker-compose.yml | 25 +++++++++++++++++++++++++ src/test/java/AppTest.java | 3 +-- 6 files changed, 38 insertions(+), 3 deletions(-) create mode 100644 docker-compose.yml diff --git a/.github/workflows/maven-manual.yml b/.github/workflows/maven-manual.yml index d3ed678..425e4a2 100644 --- a/.github/workflows/maven-manual.yml +++ b/.github/workflows/maven-manual.yml @@ -27,5 +27,9 @@ jobs: echo " test-secret=secret " >> src/test/resources/secret.properties + - name: Run docker compose + uses: hoverkraft-tech/compose-action@v2.0.1 + with: + compose-file: "./docker-compose.yml" - name: Build & Test run: mvn clean test \ No newline at end of file diff --git a/.github/workflows/maven-publish.yml b/.github/workflows/maven-publish.yml index c371827..3816a77 100644 --- a/.github/workflows/maven-publish.yml +++ b/.github/workflows/maven-publish.yml @@ -25,6 +25,10 @@ jobs: echo " test-secret=secret " >> src/test/resources/secret.properties + - name: Run docker compose + uses: hoverkraft-tech/compose-action@v2.0.1 + with: + compose-file: "./docker-compose.yml" - name: Build, Test & Publish uses: ncipollo/release-action@v1 with: diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index 85c79c9..e1528d4 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -30,5 +30,9 @@ jobs: echo " test-secret=secret " >> src/test/resources/secret.properties + - name: Run docker compose + uses: hoverkraft-tech/compose-action@v2.0.1 + with: + compose-file: "./docker-compose.yml" - name: Build & Test run: mvn clean test \ No newline at end of file diff --git a/.gitignore b/.gitignore index 9b68a57..6125b25 100644 --- a/.gitignore +++ b/.gitignore @@ -8,4 +8,3 @@ POM-Framework.iml src/test/resources/secret.properties /target/ mongo-init.js -docker-compose.yml diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..3c3268f --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,25 @@ +services: + + mongodb: + image: zanmaster/custom-mongo:latest + container_name: mongodb + restart: always + environment: + MONGO_INITDB_ROOT_USERNAME: test + MONGO_INITDB_ROOT_PASSWORD: Secret-123 + MONGO_INITDB_DATABASE: food-planner-db + + ports: + - 27017:27017 + + food-planner: + image: zanmaster/food-planner:latest + container_name: food-planner + environment: + - SPRING_DATA_MONGODB_URI=mongodb://test:Secret-123@mongodb:27017/food-planner-db?authSource=admin + - SERVER_PORT=5001 + depends_on: + - mongodb + ports: + - "5001:5001" + restart: unless-stopped \ No newline at end of file diff --git a/src/test/java/AppTest.java b/src/test/java/AppTest.java index 3f15502..36c8be4 100644 --- a/src/test/java/AppTest.java +++ b/src/test/java/AppTest.java @@ -10,7 +10,7 @@ public class AppTest { static Printer log = new Printer(AppTest.class); FoodPlanner foodPlanner = new FoodPlanner(); -/* + @Before public void before(){ ContextStore.loadProperties("test.properties", "secret.properties"); @@ -208,5 +208,4 @@ public void logoutTest() { } catch (FailedCallException e) { log.success("logoutTest PASSED!");} } -*/ } From 8741a854298db897b3645faa0804676c41568102 Mon Sep 17 00:00:00 2001 From: egecan <118941751+egecansen@users.noreply.github.com> Date: Sun, 6 Jul 2025 18:33:46 +0300 Subject: [PATCH 2/5] docker-compose added --- .github/workflows/maven-manual.yml | 4 ++++ .github/workflows/maven-publish.yml | 4 ++++ .github/workflows/maven.yml | 4 ++++ .gitignore | 1 - docker-compose.yml | 25 +++++++++++++++++++++++++ src/test/java/AppTest.java | 3 +-- 6 files changed, 38 insertions(+), 3 deletions(-) create mode 100644 docker-compose.yml diff --git a/.github/workflows/maven-manual.yml b/.github/workflows/maven-manual.yml index d3ed678..425e4a2 100644 --- a/.github/workflows/maven-manual.yml +++ b/.github/workflows/maven-manual.yml @@ -27,5 +27,9 @@ jobs: echo " test-secret=secret " >> src/test/resources/secret.properties + - name: Run docker compose + uses: hoverkraft-tech/compose-action@v2.0.1 + with: + compose-file: "./docker-compose.yml" - name: Build & Test run: mvn clean test \ No newline at end of file diff --git a/.github/workflows/maven-publish.yml b/.github/workflows/maven-publish.yml index c371827..3816a77 100644 --- a/.github/workflows/maven-publish.yml +++ b/.github/workflows/maven-publish.yml @@ -25,6 +25,10 @@ jobs: echo " test-secret=secret " >> src/test/resources/secret.properties + - name: Run docker compose + uses: hoverkraft-tech/compose-action@v2.0.1 + with: + compose-file: "./docker-compose.yml" - name: Build, Test & Publish uses: ncipollo/release-action@v1 with: diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index 85c79c9..e1528d4 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -30,5 +30,9 @@ jobs: echo " test-secret=secret " >> src/test/resources/secret.properties + - name: Run docker compose + uses: hoverkraft-tech/compose-action@v2.0.1 + with: + compose-file: "./docker-compose.yml" - name: Build & Test run: mvn clean test \ No newline at end of file diff --git a/.gitignore b/.gitignore index 9b68a57..6125b25 100644 --- a/.gitignore +++ b/.gitignore @@ -8,4 +8,3 @@ POM-Framework.iml src/test/resources/secret.properties /target/ mongo-init.js -docker-compose.yml diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..3c3268f --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,25 @@ +services: + + mongodb: + image: zanmaster/custom-mongo:latest + container_name: mongodb + restart: always + environment: + MONGO_INITDB_ROOT_USERNAME: test + MONGO_INITDB_ROOT_PASSWORD: Secret-123 + MONGO_INITDB_DATABASE: food-planner-db + + ports: + - 27017:27017 + + food-planner: + image: zanmaster/food-planner:latest + container_name: food-planner + environment: + - SPRING_DATA_MONGODB_URI=mongodb://test:Secret-123@mongodb:27017/food-planner-db?authSource=admin + - SERVER_PORT=5001 + depends_on: + - mongodb + ports: + - "5001:5001" + restart: unless-stopped \ No newline at end of file diff --git a/src/test/java/AppTest.java b/src/test/java/AppTest.java index 3f15502..36c8be4 100644 --- a/src/test/java/AppTest.java +++ b/src/test/java/AppTest.java @@ -10,7 +10,7 @@ public class AppTest { static Printer log = new Printer(AppTest.class); FoodPlanner foodPlanner = new FoodPlanner(); -/* + @Before public void before(){ ContextStore.loadProperties("test.properties", "secret.properties"); @@ -208,5 +208,4 @@ public void logoutTest() { } catch (FailedCallException e) { log.success("logoutTest PASSED!");} } -*/ } From d1f754f250caf751c5c6cdf35a7c31c709d26a28 Mon Sep 17 00:00:00 2001 From: egecan <118941751+egecansen@users.noreply.github.com> Date: Sun, 6 Jul 2025 19:06:58 +0300 Subject: [PATCH 3/5] workflow update --- .github/workflows/maven-manual.yml | 5 +++- .github/workflows/maven-publish.yml | 3 +++ .github/workflows/maven.yml | 7 +++-- src/test/java/AppTest.java | 42 +++++++++++++++++++++-------- 4 files changed, 43 insertions(+), 14 deletions(-) diff --git a/.github/workflows/maven-manual.yml b/.github/workflows/maven-manual.yml index 425e4a2..4f77480 100644 --- a/.github/workflows/maven-manual.yml +++ b/.github/workflows/maven-manual.yml @@ -32,4 +32,7 @@ jobs: with: compose-file: "./docker-compose.yml" - name: Build & Test - run: mvn clean test \ No newline at end of file + run: mvn clean test + - name: Docker Compose Down + if: always() + run: docker-compose down \ No newline at end of file diff --git a/.github/workflows/maven-publish.yml b/.github/workflows/maven-publish.yml index 3816a77..b6760c4 100644 --- a/.github/workflows/maven-publish.yml +++ b/.github/workflows/maven-publish.yml @@ -35,6 +35,9 @@ jobs: allowUpdates: true artifacts: "${{ github.workspace }}/out/artifacts/wasapi_jar/*.jar" token: ${{ secrets.GITHUB_TOKEN }} + - name: Docker Compose Down # check if it's in the right place + if: always() + run: docker-compose down - name: Publish to the Maven Central Repository run: | mvn \ diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index e1528d4..6281a54 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -30,9 +30,12 @@ jobs: echo " test-secret=secret " >> src/test/resources/secret.properties - - name: Run docker compose + - name: Run Docker Compose uses: hoverkraft-tech/compose-action@v2.0.1 with: compose-file: "./docker-compose.yml" - name: Build & Test - run: mvn clean test \ No newline at end of file + run: mvn clean test + - name: Docker Compose Down + if: always() + run: docker-compose down \ No newline at end of file diff --git a/src/test/java/AppTest.java b/src/test/java/AppTest.java index 36c8be4..0e143f2 100644 --- a/src/test/java/AppTest.java +++ b/src/test/java/AppTest.java @@ -26,6 +26,22 @@ public void before(){ log.success("nice-user authentication is successful!"); } + + @After + public void after(){ + ContextStore.loadProperties("test.properties", "secret.properties"); + + log.info("nice-user authentication is in progress..."); + UserAuthRequestModel userAuthRequestModel = new UserAuthRequestModel( + "nice-user", + "Test-123" + ); + UserAuthResponseModel userAuthResponse = foodPlanner.signIn(userAuthRequestModel); + log.info(userAuthResponse.getJwtToken()); + ContextStore.put("jwtToken", userAuthResponse.getJwtToken()); + log.success("nice-user authentication is successful!"); + } + @Test public void deleteUserTest() { FoodPlanner.Auth foodPlannerAuth = new FoodPlanner.Auth(ContextStore.get("jwtToken")); @@ -114,7 +130,6 @@ public void getNiceUserTest() { @Test public void addFoodTest() { - FoodPlanner.Auth foodPlannerAuth = new FoodPlanner.Auth(ContextStore.get("jwtToken")); String randomFoodName = StringUtilities.generateRandomString( "food", 7, @@ -126,16 +141,7 @@ public void addFoodTest() { 1, "1" ); - GetUserResponseModel.Food food = new GetUserResponseModel.Food( - randomFoodName, - "randomFood", - List.of(ingredient), - List.of("Pasta"), - "Main", - true, - "test recipe 01" - ); - GetUserResponseModel responseModel = foodPlannerAuth.addFood(food); + GetUserResponseModel responseModel = addOrUpdateFood(ingredient, randomFoodName); Assert.assertEquals("Username does not match!", "nice-user", responseModel.getUsername()); log.success("Username verified!"); @@ -148,6 +154,20 @@ public void addFoodTest() { log.success("addFoodTest PASSED!"); } + public GetUserResponseModel addOrUpdateFood(GetUserResponseModel.Food.Ingredient ingredient, String foodName) { + FoodPlanner.Auth foodPlannerAuth = new FoodPlanner.Auth(ContextStore.get("jwtToken")); + GetUserResponseModel.Food food = new GetUserResponseModel.Food( + foodName, + "randomFood", + List.of(ingredient), + List.of("Pasta"), + "Main", + true, + "test recipe 01" + ); + return foodPlannerAuth.addFood(food); + } + @Test public void logoutTest() { FoodPlanner foodPlanner = new FoodPlanner(); From 407ecc5f7497e4cf1038e64f72a99d162f51d14b Mon Sep 17 00:00:00 2001 From: egecan <118941751+egecansen@users.noreply.github.com> Date: Sun, 6 Jul 2025 19:08:41 +0300 Subject: [PATCH 4/5] docker compose down -v --- .github/workflows/maven-manual.yml | 2 +- .github/workflows/maven-publish.yml | 2 +- .github/workflows/maven.yml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/maven-manual.yml b/.github/workflows/maven-manual.yml index 4f77480..657f11b 100644 --- a/.github/workflows/maven-manual.yml +++ b/.github/workflows/maven-manual.yml @@ -35,4 +35,4 @@ jobs: run: mvn clean test - name: Docker Compose Down if: always() - run: docker-compose down \ No newline at end of file + run: docker compose down -v \ No newline at end of file diff --git a/.github/workflows/maven-publish.yml b/.github/workflows/maven-publish.yml index b6760c4..2389882 100644 --- a/.github/workflows/maven-publish.yml +++ b/.github/workflows/maven-publish.yml @@ -37,7 +37,7 @@ jobs: token: ${{ secrets.GITHUB_TOKEN }} - name: Docker Compose Down # check if it's in the right place if: always() - run: docker-compose down + run: docker compose down -v - name: Publish to the Maven Central Repository run: | mvn \ diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index 6281a54..154e7be 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -38,4 +38,4 @@ jobs: run: mvn clean test - name: Docker Compose Down if: always() - run: docker-compose down \ No newline at end of file + run: docker compose down -v \ No newline at end of file From 276d53943c60faef949e4aa5b79d6b60c0a4af1c Mon Sep 17 00:00:00 2001 From: egecan <118941751+egecansen@users.noreply.github.com> Date: Tue, 8 Jul 2025 14:16:14 +0300 Subject: [PATCH 5/5] workflow update --- .github/workflows/maven-manual.yml | 7 +++---- .github/workflows/maven-publish.yml | 7 +++---- .github/workflows/maven.yml | 9 ++++----- src/test/java/AppTest.java | 3 --- 4 files changed, 10 insertions(+), 16 deletions(-) diff --git a/.github/workflows/maven-manual.yml b/.github/workflows/maven-manual.yml index 657f11b..09dcb8e 100644 --- a/.github/workflows/maven-manual.yml +++ b/.github/workflows/maven-manual.yml @@ -27,10 +27,9 @@ jobs: echo " test-secret=secret " >> src/test/resources/secret.properties - - name: Run docker compose - uses: hoverkraft-tech/compose-action@v2.0.1 - with: - compose-file: "./docker-compose.yml" + - name: Start Unit Test DB + run: | + docker compose up --build -d - name: Build & Test run: mvn clean test - name: Docker Compose Down diff --git a/.github/workflows/maven-publish.yml b/.github/workflows/maven-publish.yml index 2389882..4621dc1 100644 --- a/.github/workflows/maven-publish.yml +++ b/.github/workflows/maven-publish.yml @@ -25,10 +25,9 @@ jobs: echo " test-secret=secret " >> src/test/resources/secret.properties - - name: Run docker compose - uses: hoverkraft-tech/compose-action@v2.0.1 - with: - compose-file: "./docker-compose.yml" + - name: Start Unit Test DB + run: | + docker compose up --build -d - name: Build, Test & Publish uses: ncipollo/release-action@v1 with: diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index 154e7be..a63a34a 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -30,12 +30,11 @@ jobs: echo " test-secret=secret " >> src/test/resources/secret.properties - - name: Run Docker Compose - uses: hoverkraft-tech/compose-action@v2.0.1 - with: - compose-file: "./docker-compose.yml" + - name: Start Unit Test DB + run: | + docker compose up --build -d - name: Build & Test run: mvn clean test - - name: Docker Compose Down + - name: Compose Down if: always() run: docker compose down -v \ No newline at end of file diff --git a/src/test/java/AppTest.java b/src/test/java/AppTest.java index 0e143f2..f3eef99 100644 --- a/src/test/java/AppTest.java +++ b/src/test/java/AppTest.java @@ -26,11 +26,8 @@ public void before(){ log.success("nice-user authentication is successful!"); } - @After public void after(){ - ContextStore.loadProperties("test.properties", "secret.properties"); - log.info("nice-user authentication is in progress..."); UserAuthRequestModel userAuthRequestModel = new UserAuthRequestModel( "nice-user",