Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion .github/workflows/maven-manual.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,11 @@ jobs:
echo "
test-secret=secret
" >> src/test/resources/secret.properties
- name: Start Unit Test DB
run: |
docker compose up --build -d
- name: Build & Test
run: mvn clean test
run: mvn clean test
- name: Docker Compose Down
if: always()
run: docker compose down -v
6 changes: 6 additions & 0 deletions .github/workflows/maven-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,18 @@ jobs:
echo "
test-secret=secret
" >> src/test/resources/secret.properties
- name: Start Unit Test DB
run: |
docker compose up --build -d
- name: Build, Test & Publish
uses: ncipollo/release-action@v1
with:
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 -v
- name: Publish to the Maven Central Repository
run: |
mvn \
Expand Down
8 changes: 7 additions & 1 deletion .github/workflows/maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,11 @@ jobs:
echo "
test-secret=secret
" >> src/test/resources/secret.properties
- name: Start Unit Test DB
run: |
docker compose up --build -d
- name: Build & Test
run: mvn clean test
run: mvn clean test
- name: Compose Down
if: always()
run: docker compose down -v
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,3 @@ POM-Framework.iml
src/test/resources/secret.properties
/target/
mongo-init.js
docker-compose.yml
25 changes: 25 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
services:

mongodb:
image: zanmaster/custom-mongo:1.0
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:1.0
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
42 changes: 29 additions & 13 deletions src/test/java/AppTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand All @@ -26,6 +26,19 @@ public void before(){
log.success("nice-user authentication is successful!");
}

@After
public void after(){
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"));
Expand Down Expand Up @@ -114,7 +127,6 @@ public void getNiceUserTest() {

@Test
public void addFoodTest() {
FoodPlanner.Auth foodPlannerAuth = new FoodPlanner.Auth(ContextStore.get("jwtToken"));
String randomFoodName = StringUtilities.generateRandomString(
"food",
7,
Expand All @@ -126,16 +138,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!");
Expand All @@ -148,6 +151,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();
Expand Down Expand Up @@ -208,5 +225,4 @@ public void logoutTest() {
} catch (FailedCallException e) { log.success("logoutTest PASSED!");}

}
*/
}