Skip to content

g0ng0n12/cuddly-octo-happiness

Repository files navigation

KMarket


Requirements

For building and running the application you need:


Endpoints

Swagger-UI

App Health-Check

Postman

  • KMARKET.postman_collection.json file... this file is a Postman Collection v2.1

Checkout Enpoint


Running the application locally

There are several ways to start the application Locally

For development purposes you can use the Spring Boot Maven plugin like so: in the command line from the root path of the project run:

mvn spring-boot:run -Dspring-boot.run.profiles=develop

This will fire up the application with an H2 on-memory database loaded. When you start the app you can access the h2 db using this url: http://localhost:8090/h2-console the user and pass are the default

to check the status of the application please use this url: http://localhost:8090/actuator/health

to see the API endpoints documentation you please check the swagger ui URL: http://localhost:8090/swagger-ui/#

Build and Run a Release with Docker and Docker-compose in your LocalHost

You can use docker-compose to load the app with a MYSQL db. All the environment variables for docker were place in the .env-sample file. To generate a build and run with docker you need to create a .env file and copy and paste the vars from the .env-sample file into the new .env file

in the command line from the root path of the project run:

docker-compose up
to check the status of the application please use this url: http://localhost:8090/actuator/health
to see the API endpoints documentation you please check the swagger ui URL: http://localhost:8090/swagger-ui.html

if you need to re-run (without delete and stop all the process) the build and deploy new changes you can run in the command line from the root path:

docker-compose up --build

in order to stop the containers you should run in the command line from the root path:

docker-compose down --rmi local

this will stop the containers and remove the images from your computer.

Other Docker tips

When you use the build using the docker-compose file you will see that for every build you are going to generate a new image... so in order to delete the unused image please use this command:

docker image prune -f

Running the Integration Tests

In This case the Integration tests lifts all the spring context, and the tests are in the KmarketApplicationIT File I added one integration test that contains the special conditions required

  • The CEO is a big fan of buy-one-get-one-free offers and of green tea. He wants us to add a rule to do this
  • The COO, though, likes low prices and wants people buying strawberries to get a price discount for bulk purchases. If you buy 3 or more strawberries, the price should drop to £4.50 per strawberry.
  • The CTO is a coffee addict. If you buy 3 or more coffees, the price of all coffees should drop to two thirds of the original price.

Also the Integration tests runs the unit tests. in order to run the integration tests you should run in the command line from the root path:

 mvn -DSPRING_PROFILE_ACTIVE=integration-test integration-test verify  

When integration-test ends you will see this.

[INFO] Tests run: 5, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 8.385 s - in com.fx.kmarket.it.KmarketApplicationIT

Running Unint Tests

In this case the Unit tests are in the CartServiceTest File In order to run Unit Tests with mocks you should run in the command line from the root path:

mvn -DSPRING_PROFILE_ACTIVE=test test

When Finished OK you will see this:

[INFO] Tests run: 5, Failures: 0, Errors: 0, Skipped: 0

Common Issues

1. When you run docker-compose up... if you see warnings like this: WARN[0000] The "MYSQL_USER" variable, you should create the .env file
2. we need to improve the Docker Creation for the Release, since we're having SQL issues.

Implementations

1. In the main branch the offers business logic is handle in an enum
2. In the strategy-offer branch the offers business logic is handle using a strategy pattern.
2. In the functional-implementation branch the offers business logic is handle using java functional features (Work in progress)

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published