An open API service indexing awesome lists of open source software.

https://github.com/andylvua/FlowerStore

Lab 5, 7, 8 and 9 assignment of OOP course
https://github.com/andylvua/FlowerStore

ci-cd java maven oop unit-testing

Last synced: 7 months ago
JSON representation

Lab 5, 7, 8 and 9 assignment of OOP course

Awesome Lists containing this project

README

          

# Flower Store

[![Java CI](https://github.com/andylvua/FlowerStore/actions/workflows/ci.yaml/badge.svg)](https://github.com/andylvua/FlowerStore/actions/workflows/ci.yaml)
![Heroku](https://img.shields.io/static/v1?message=deployed&logo=Heroku&color=32CD32&label=Heroku)

## Description

Simple flower store application for Labs 5-8 assignment of OOP course.

## Lab 5 Task

- [x] Implement a class Flower or system of classes that implement the essence of Rose, Chamomile, and Tulip in a flower store. The class or classes should have attributes sepalLength, color, and price.
- [x] Submit a project to GitHub.
- [x] Add SuperLinter to the project and fix all issues.
- [x] Propose an approach to represent flower color (explore the proposed tests).
- [x] Add all next changes in a separate branch flower-bucket and merge them into the main branch with Pull Request.
- [x] Implement FlowerPack class with attributes flower and amount. Implement method getPrice in it.
- [x] Implement FlowerBucket class that will aggregate several FlowerPack. Implement method price in it.
- [x] Implement class Store and method search in it.
- [x] Add tests to the project.
- [x] Setup GitHub Actions for this project that would run your tests.
- [x] Send a link to your GitHub here.

## Lab 7 Task

- [x] Initialize simple web
- [x] Add `@RestController` to a `DemoApplication.java` and implement methods with `@GetMapping` to return a list of objects.
- [x] Migrate `Flower` to this project and implement an endpoint that will return `List.of(Flower)`.
- [x] Refactor `FlowerController`: move to separate package and add `@RequestMapping`.
- [x] Implement `Order` that will implement client order.
- [x] Implement `Item` that will represent the basic element of `Order`.
- [x] Implement different payment strategies with an interface `Payment` and several implementations of it `CreditCardPaymentStrategy`, `PayPalPaymentStrategy`. Use Strategy pattern.
- [x] Implement several `Delivery` strategies: `PostDeliveryStrategy`, `DHLDeliveryStrategy`.
- [x] Cover delivery and payment packages with tests and endpoints for them.
- [x] Set up GitHub Actions for this project that would run your tests.
- [x] Send a link to your GitHub here.

### Results of Lab 7

#### api/flowerstore

Here we can see welcoming message with simple usage instructions.

image

#### api/flowerstore/help

This endpoint returns a list of all available endpoints.

image

#### api/flowerstore/all

We can go to the endpoint `api/flowerstore/all` to see all flowers in the store. Flower store is being automatically initialized with random flower objects.

image

### Lab 8 Task

- [x] Refactor business logic of `getFlowers` to `FlowerService`
- [x] Use `@Autowired` and `@Servic`e for Dependency Injection.
- [x] Setup DB with Docker `docker run --name oop-course -e POSTGRES_PASSWORD=postgres -d -p 5432:5432 postgres`
- [x] Add flowers DB via Database viewer (Intellj IDEA Ultimate or DBViewer)
- [x] Add JPA config. See application.properties attached.
- [x] Add `FlowerRepository` interface and inject it instance in `FlowerService`. Inject several record in DB. Check whether the endpoint will return all the records from DB.
- [x] Add `addFlower` method to API and Service layers. Implement `@PostMapping` with `@RequestBody` extraction.
- [x] Test GET and POST with test.http.
- [x] Implement `AbstractDecorator` that will implement basic decorator behavior.
- [x] Implement decorators based on attached diagram. This implementation should follow `Decorator Pattern`.
- [x] Cover decorators with tests.
- [x] Set up GitHub Actions for this project that would run your tests.
- [x] Send a link to your GitHub here.

### Results of Lab 8

#### GET request
We can add a several flower instances to the database using IntelliJ IDEA Database Viewer.

image

Now, let's send a GET request to the endpoint `api/flowerstore/database/view` to see all flowers in the store's database.

image

We can see that all flower instances were successfully added to the database and returned by the endpoint.

image

#### POST request
Now, let's send a several POST requests to the endpoint `api/flowerstore/database/add` to add a new flower instance to the store's database.

image

As we can see, the server responded with a status code 200 and the flower instances were successfully added to the database:

image
image
image

Now, sending a GET request to the endpoint `api/flowerstore/database/view` yields the following result:

image

## License

The [MIT](https://choosealicense.com/licenses/mit/) License (MIT)

Copyright © 2022. Andrii Yaroshevych