├── .idea ├── .gitignore ├── Software-Concepts.iml ├── modules.xml ├── vcs.xml └── workspace.xml ├── APIs └── GraphQL │ └── java │ └── sprint-boot │ └── wallet-service │ ├── .gitignore │ ├── HELP.md │ ├── mvnw │ ├── mvnw.cmd │ ├── pom.xml │ ├── src │ ├── main │ │ ├── java │ │ │ └── com │ │ │ │ └── rolandsall │ │ │ │ └── walletservice │ │ │ │ ├── WalletServiceApplication.java │ │ │ │ ├── api │ │ │ │ ├── CurrencyController │ │ │ │ │ └── CurrencyController.java │ │ │ │ └── WalletController │ │ │ │ │ └── WalletController.java │ │ │ │ ├── domain │ │ │ │ ├── Currency.java │ │ │ │ ├── Wallet.java │ │ │ │ └── WalletTransaction.java │ │ │ │ ├── dto │ │ │ │ └── AddWalletRequestDTO.java │ │ │ │ ├── enums │ │ │ │ └── TransactionType.java │ │ │ │ ├── exception │ │ │ │ └── GraphQLExceptionHandler.java │ │ │ │ ├── repositories │ │ │ │ ├── ICurrencyRepository.java │ │ │ │ ├── IWalletRepository.java │ │ │ │ └── IWalletTransactionRepository.java │ │ │ │ └── service │ │ │ │ ├── CurrencyService.java │ │ │ │ ├── ICurrencyService.java │ │ │ │ ├── IWalletService.java │ │ │ │ ├── IWalletTransactionService.java │ │ │ │ ├── WalletService.java │ │ │ │ └── WalletTransactionService.java │ │ └── resources │ │ │ ├── application.properties │ │ │ └── graphql │ │ │ └── schema.graphqls │ └── test │ │ └── java │ │ └── com │ │ └── rolandsall │ │ └── walletservice │ │ └── WalletServiceApplicationTests.java │ └── wallet-service.iml ├── LICENSE ├── README.md ├── SOLID ├── Dependency Inversion Principle │ └── README.md ├── Interface Segregation Principle │ ├── README.md │ └── java │ │ └── ISP │ │ └── src │ │ ├── Checkout.java │ │ ├── Payments.java │ │ ├── Stripe.java │ │ └── fixed │ │ ├── Checkout.java │ │ ├── Payments.java │ │ ├── Stripe.java │ │ └── TokenManager.java ├── Liskov Substitution Principle │ ├── README.md │ └── java │ │ └── LSP │ │ ├── .idea │ │ ├── .gitignore │ │ ├── misc.xml │ │ ├── modules.xml │ │ ├── uiDesigner.xml │ │ └── vcs.xml │ │ ├── LSP.iml │ │ └── src │ │ ├── FoodOrderApplication.java │ │ ├── Totters.java │ │ ├── Zomato.java │ │ └── fixed │ │ ├── ChatManager.java │ │ ├── PayDirectlyManager.java │ │ ├── RecommendationSystem.java │ │ ├── Totters.java │ │ └── Zomato.java ├── Open-Closed Principle │ ├── README.md │ ├── csharp │ │ └── OCP │ │ │ ├── ConsoleApp │ │ │ ├── ConsoleApp.csproj │ │ │ └── Program.cs │ │ │ ├── Domain │ │ │ ├── Accounts │ │ │ │ ├── IAccount.cs │ │ │ │ ├── StaffAccount.cs │ │ │ │ └── StudentAccount.cs │ │ │ ├── Domain.csproj │ │ │ ├── Employee.cs │ │ │ ├── Person.cs │ │ │ ├── Staff.cs │ │ │ └── Student.cs │ │ │ └── OCP.sln │ └── java │ │ └── OCP │ │ └── src │ │ ├── BMI.java │ │ ├── Human.java │ │ └── fixed │ │ ├── Female.java │ │ ├── Human.java │ │ └── Male.java ├── README.md └── Single Responsibility │ ├── README.md │ ├── csharp │ └── SRP │ │ ├── SRP.sln │ │ └── SRP │ │ ├── Person.cs │ │ ├── Program.cs │ │ ├── SRP.csproj │ │ └── alternative │ │ ├── Main.cs │ │ ├── Messages.cs │ │ ├── PersonData.cs │ │ ├── PersonValidator.cs │ │ └── UsernameGenerator.cs │ └── java │ └── SRP │ └── src │ ├── Student.java │ └── fixed │ ├── StudentEmails.java │ ├── StudentRegister.java │ └── StudentResult.java ├── articles └── README.md ├── design-patterns ├── Behavioral Pattern │ ├── Mediator-CQRS │ │ └── dotnet-core │ │ │ ├── global.json │ │ │ ├── mediator-cqrs.sln │ │ │ └── mediator-cqrs │ │ │ ├── .gitignore │ │ │ ├── Behaviors │ │ │ └── ValidationBehaviour.cs │ │ │ ├── Commands │ │ │ └── Product │ │ │ │ └── CreateProductCommand.cs │ │ │ ├── Controllers │ │ │ ├── CreateProductRequest.cs │ │ │ └── ProductController.cs │ │ │ ├── Folder.DotSettings.user │ │ │ ├── Handlers │ │ │ └── Product │ │ │ │ └── GetAllProductOrdersQueryHandler.cs │ │ │ ├── Program.cs │ │ │ ├── Properties │ │ │ └── launchSettings.json │ │ │ ├── Queries │ │ │ └── Product │ │ │ │ ├── GetAllOrdersQuery.cs │ │ │ │ └── GetProductById.cs │ │ │ ├── README.md │ │ │ ├── Repository │ │ │ ├── DummyProductRepo.cs │ │ │ └── IProductRepo.cs │ │ │ ├── Validation │ │ │ └── CreateProductCommandValidator.cs │ │ │ ├── appsettings.Development.json │ │ │ ├── appsettings.json │ │ │ ├── entities │ │ │ └── Product.cs │ │ │ ├── images │ │ │ └── MediatR-pipeline.png │ │ │ ├── mediator-cqrs.csproj │ │ │ └── mediator-cqrs.csproj.DotSettings │ └── Strategy │ │ ├── README.md │ │ ├── War │ │ ├── README.md │ │ └── src │ │ │ ├── Behavior │ │ │ └── Weapon │ │ │ │ ├── AxeBehavior.java │ │ │ │ ├── CrossbowBehavior.java │ │ │ │ ├── IWeaponBehavior.java │ │ │ │ ├── KnifeBehavior.java │ │ │ │ └── SwordBehavior.java │ │ │ ├── Domain │ │ │ ├── Character.java │ │ │ ├── Knight.java │ │ │ └── Troll.java │ │ │ └── main.java │ │ ├── duckExample │ │ └── src │ │ │ ├── Behaviours │ │ │ ├── DuckCallSystem.java │ │ │ ├── Fly │ │ │ │ ├── IFlyBehavior.java │ │ │ │ ├── NoFly.java │ │ │ │ └── SlowFly.java │ │ │ └── Quack │ │ │ │ ├── IQuackBehavior.java │ │ │ │ ├── MuteQuack.java │ │ │ │ └── NormalQuack.java │ │ │ ├── CityDuck.java │ │ │ ├── Duck.java │ │ │ └── main.java │ │ └── images │ │ ├── img1.PNG │ │ ├── img2.PNG │ │ └── img3.PNG ├── Creational Pattern │ ├── AbstractFactory │ │ └── java │ │ │ ├── AbstractFactoryDemo │ │ │ └── src │ │ │ │ ├── AbstractFactoryPatternDemo.java │ │ │ │ ├── Factory │ │ │ │ ├── AbstractFactory.java │ │ │ │ ├── FactoryProducer.java │ │ │ │ ├── RoundedShapeFactory.java │ │ │ │ └── ShapeFactory.java │ │ │ │ └── Shapes │ │ │ │ ├── IShape.java │ │ │ │ ├── Rectangle.java │ │ │ │ ├── RoundedRectangle.java │ │ │ │ ├── RoundedSquare.java │ │ │ │ └── Square.java │ │ │ ├── PizzaCompany │ │ │ └── src │ │ │ │ ├── Domain │ │ │ │ ├── CheesePizza.java │ │ │ │ ├── ChickenPizza.java │ │ │ │ ├── LebanonCheesePizza.java │ │ │ │ ├── LebanonChickenPizza.java │ │ │ │ ├── Pizza.java │ │ │ │ ├── USCheesePizza.java │ │ │ │ └── USChickenPizza.java │ │ │ │ ├── Factory │ │ │ │ └── SimplePizzaFactory.java │ │ │ │ ├── Store │ │ │ │ ├── LebanonPizzaStore.java │ │ │ │ ├── PizzaStore.java │ │ │ │ └── USPizzaStore.java │ │ │ │ └── main.java │ │ │ └── UFODemo │ │ │ └── src │ │ │ ├── EnemyShipBuilding.java │ │ │ ├── EnemyShipTesting.java │ │ │ ├── Engine │ │ │ ├── ESEngine.java │ │ │ ├── ESUFOBossEngine.java │ │ │ └── ESUFOEngine.java │ │ │ ├── Entity │ │ │ ├── EnemyShip.java │ │ │ ├── EnemyShipFactory.java │ │ │ ├── UFOBossEnemyShip.java │ │ │ └── UFOEnemyShip.java │ │ │ ├── Factories │ │ │ ├── UFOBossEnemyShipFactory.java │ │ │ └── UFOEnemyShipFactory.java │ │ │ ├── UFOEnemyShipBuilding.java │ │ │ └── Weapon │ │ │ ├── ESUFOBossGun.java │ │ │ ├── ESUFOGun.java │ │ │ └── ESWeapon.java │ ├── Factory │ │ ├── README.md │ │ └── java │ │ │ └── main │ │ │ ├── .idea │ │ │ └── workspace.xml │ │ │ ├── main.iml │ │ │ └── src │ │ │ ├── BigUFOEnemyShip.java │ │ │ ├── EnemyShip.java │ │ │ ├── EnemyShipFactory.java │ │ │ ├── RocketEnemyShip.java │ │ │ ├── UFOEnemyShip.java │ │ │ └── main.java │ ├── README.md │ ├── Singleton │ │ ├── README.md │ │ └── java │ │ │ ├── PatternDemo │ │ │ └── src │ │ │ │ ├── SingletonObject.java │ │ │ │ └── main.java │ │ │ └── PatternDemo2 │ │ │ └── src │ │ │ └── Singleton.java │ └── images │ │ ├── img1.PNG │ │ ├── img2.PNG │ │ └── img3.PNG ├── README.md └── Structual Pattern │ ├── Adapter │ └── README.md │ ├── Decorator │ ├── README.md │ └── java │ │ └── BeveragesExample │ │ ├── BeveragesExample.iml │ │ └── src │ │ ├── AddOnDecorator.java │ │ ├── Beverages.java │ │ ├── Espresso.java │ │ ├── HouseBlend.java │ │ ├── Mocha.java │ │ ├── Whip.java │ │ └── main.java │ └── Facade │ ├── README.md │ └── java │ ├── BankExample │ └── src │ │ ├── Bank │ │ ├── AccountNumberCheck.java │ │ ├── BankAccountFacade.java │ │ ├── BankAccountNotFound.java │ │ ├── FundCheck.java │ │ └── SecurityCodeCheck.java │ │ └── main.java │ └── EmployeeExample │ └── src │ ├── Employee │ ├── Developer.java │ ├── Employee.java │ ├── Facade │ │ ├── DeveloperFacade.java │ │ ├── EmployeeFacade.java │ │ ├── Facade.java │ │ └── TesterFacade.java │ ├── HourReporter.java │ ├── PayCalculator │ │ ├── EmployeePayCalculator.java │ │ ├── IPayCalculator.java │ │ ├── PayDeveloperCalculator.java │ │ └── PayTesterCalculator.java │ └── Tester.java │ └── main.java ├── event-driven-microservices └── java │ ├── README.md │ ├── images │ ├── CQRS-with-event-sourcing.png │ ├── asynchronous-communication.drawio.png │ ├── event-sourcing(1).png │ ├── microservie-architecture.drawio.png │ └── synchronous-communication.drawio.png │ └── templates │ └── cqrs-eventsourcing-axon │ ├── .gitignore │ ├── .mvn │ └── wrapper │ │ ├── maven-wrapper.jar │ │ └── maven-wrapper.properties │ ├── README.md │ ├── docker-compose.yml │ ├── images │ └── axon.PNG │ ├── mvnw │ ├── mvnw.cmd │ ├── pom.xml │ └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── rolandsall24 │ │ │ └── cqrseventsourcingaxon │ │ │ ├── CqrsEventsourcingAxonApplication.java │ │ │ ├── SwaggerConfig.java │ │ │ ├── commands │ │ │ └── product │ │ │ │ ├── aggregate │ │ │ │ └── ProductAggregate.java │ │ │ │ ├── commands │ │ │ │ ├── CreateProductCommand.java │ │ │ │ ├── ProductBaseCommand.java │ │ │ │ └── UpdateProductStatusCommand.java │ │ │ │ ├── enums │ │ │ │ └── ProductStatus.java │ │ │ │ └── events │ │ │ │ ├── ProductBaseEvent.java │ │ │ │ ├── ProductCreatedEvent.java │ │ │ │ └── UpdateProductStatusEvent.java │ │ │ ├── controller │ │ │ └── productController │ │ │ │ └── ProductController.java │ │ │ ├── dtos │ │ │ ├── CreateProductRequestDto.java │ │ │ └── UpdateProductDto.java │ │ │ └── model │ │ │ └── Product.java │ └── resources │ │ └── application.properties │ └── test │ └── java │ └── com │ └── rolandsall24 │ └── cqrseventsourcingaxon │ └── CqrsEventsourcingAxonApplicationTests.java ├── microservices ├── microservice-full-example-two │ ├── README.md │ └── food-ordering-system │ │ ├── .gitignore │ │ ├── common │ │ ├── common-domain │ │ │ ├── pom.xml │ │ │ └── src │ │ │ │ ├── main │ │ │ │ └── java │ │ │ │ │ └── com │ │ │ │ │ └── rolandsall │ │ │ │ │ └── food │ │ │ │ │ └── ordering │ │ │ │ │ └── system │ │ │ │ │ └── domain │ │ │ │ │ ├── entity │ │ │ │ │ ├── AggregateRoot.java │ │ │ │ │ └── BaseEntity.java │ │ │ │ │ ├── event │ │ │ │ │ ├── DomainEvent.java │ │ │ │ │ └── publisher │ │ │ │ │ │ └── DomainEventPublisher.java │ │ │ │ │ ├── exception │ │ │ │ │ └── DomainException.java │ │ │ │ │ └── valueobject │ │ │ │ │ ├── BaseId.java │ │ │ │ │ ├── CustomerId.java │ │ │ │ │ ├── Money.java │ │ │ │ │ ├── OrderApprovalStatus.java │ │ │ │ │ ├── OrderId.java │ │ │ │ │ ├── OrderStatus.java │ │ │ │ │ ├── PaymentStatus.java │ │ │ │ │ ├── ProductId.java │ │ │ │ │ └── RestaurantId.java │ │ │ │ └── test │ │ │ │ └── java │ │ │ │ └── com │ │ │ │ └── rolandsall │ │ │ │ └── AppTest.java │ │ └── pom.xml │ │ ├── infrastructure │ │ ├── docker-compose │ │ │ ├── .env │ │ │ ├── common.yml │ │ │ ├── kafka_cluster.yml │ │ │ └── zookeeper.yml │ │ └── pom.xml │ │ ├── order-service │ │ ├── order-application │ │ │ ├── pom.xml │ │ │ └── src │ │ │ │ ├── main │ │ │ │ └── java │ │ │ │ │ └── com │ │ │ │ │ └── rolandsall │ │ │ │ │ └── App.java │ │ │ │ └── test │ │ │ │ └── java │ │ │ │ └── com │ │ │ │ └── rolandsall │ │ │ │ └── AppTest.java │ │ ├── order-container │ │ │ ├── pom.xml │ │ │ └── src │ │ │ │ ├── main │ │ │ │ └── java │ │ │ │ │ └── com │ │ │ │ │ └── rolandsall │ │ │ │ │ └── App.java │ │ │ │ └── test │ │ │ │ └── java │ │ │ │ └── com │ │ │ │ └── rolandsall │ │ │ │ └── AppTest.java │ │ ├── order-dataaccess │ │ │ ├── pom.xml │ │ │ └── src │ │ │ │ ├── main │ │ │ │ └── java │ │ │ │ │ └── com │ │ │ │ │ └── rolandsall │ │ │ │ │ └── App.java │ │ │ │ └── test │ │ │ │ └── java │ │ │ │ └── com │ │ │ │ └── rolandsall │ │ │ │ └── AppTest.java │ │ ├── order-domain │ │ │ ├── order-application-service │ │ │ │ ├── pom.xml │ │ │ │ └── src │ │ │ │ │ ├── main │ │ │ │ │ └── java │ │ │ │ │ │ └── com │ │ │ │ │ │ └── rolandsall │ │ │ │ │ │ └── order │ │ │ │ │ │ └── service │ │ │ │ │ │ └── domain │ │ │ │ │ │ ├── dto │ │ │ │ │ │ ├── create │ │ │ │ │ │ │ ├── CreateOrderCommand.java │ │ │ │ │ │ │ ├── CreateOrderResponse.java │ │ │ │ │ │ │ ├── OrderAddress.java │ │ │ │ │ │ │ └── OrderItem.java │ │ │ │ │ │ ├── message │ │ │ │ │ │ │ ├── PaymentResponse.java │ │ │ │ │ │ │ └── RestaurantApprovalResponse.java │ │ │ │ │ │ └── track │ │ │ │ │ │ │ ├── TrackOrderQuery.java │ │ │ │ │ │ │ └── TrackOrderResponse.java │ │ │ │ │ │ ├── mapper │ │ │ │ │ │ └── OrderDataMapper.java │ │ │ │ │ │ ├── order │ │ │ │ │ │ ├── OrderApplicationServiceImpl.java │ │ │ │ │ │ ├── OrderCreateCommandHandler.java │ │ │ │ │ │ ├── OrderCreateHelper.java │ │ │ │ │ │ └── OrderTrackCommandHandler.java │ │ │ │ │ │ ├── payment │ │ │ │ │ │ └── PaymentResponseMessageListener.java │ │ │ │ │ │ ├── ports │ │ │ │ │ │ ├── input │ │ │ │ │ │ │ ├── message │ │ │ │ │ │ │ │ └── listener │ │ │ │ │ │ │ │ │ ├── payment │ │ │ │ │ │ │ │ │ └── IPaymentResponseMessageListener.java │ │ │ │ │ │ │ │ │ └── restaurantapproval │ │ │ │ │ │ │ │ │ └── IRestaurantApprovalResponseMessageListener.java │ │ │ │ │ │ │ └── service │ │ │ │ │ │ │ │ └── OrderApplicationService.java │ │ │ │ │ │ └── output │ │ │ │ │ │ │ ├── message │ │ │ │ │ │ │ └── publisher │ │ │ │ │ │ │ │ ├── payment │ │ │ │ │ │ │ │ ├── OrderCancelledPaymentRequestMessagePublisher.java │ │ │ │ │ │ │ │ └── OrderCreatedPaymentRequestMessagePublisher.java │ │ │ │ │ │ │ │ └── restaurantapproval │ │ │ │ │ │ │ │ └── OrderPaidRestaurantRequestMessagePublisher.java │ │ │ │ │ │ │ └── repository │ │ │ │ │ │ │ ├── CustomerRepository.java │ │ │ │ │ │ │ ├── OrderRepository.java │ │ │ │ │ │ │ └── RestaurantRepository.java │ │ │ │ │ │ └── restaurant │ │ │ │ │ │ └── RestaurantApprovalResponseMessageListener.java │ │ │ │ │ └── test │ │ │ │ │ └── java │ │ │ │ │ └── com │ │ │ │ │ └── rolandsall │ │ │ │ │ └── order │ │ │ │ │ └── service │ │ │ │ │ └── domain │ │ │ │ │ ├── OrderApplicationTest.java │ │ │ │ │ └── OrderTestConfiguration.java │ │ │ ├── order-domain-core │ │ │ │ ├── pom.xml │ │ │ │ └── src │ │ │ │ │ ├── main │ │ │ │ │ └── java │ │ │ │ │ │ └── com │ │ │ │ │ │ └── rolandsall │ │ │ │ │ │ └── order │ │ │ │ │ │ └── service │ │ │ │ │ │ └── domain │ │ │ │ │ │ ├── OrderDomainService.java │ │ │ │ │ │ ├── OrderDomainServiceImpl.java │ │ │ │ │ │ ├── entity │ │ │ │ │ │ ├── Customer.java │ │ │ │ │ │ ├── Order.java │ │ │ │ │ │ ├── OrderItem.java │ │ │ │ │ │ ├── Product.java │ │ │ │ │ │ └── Restaurant.java │ │ │ │ │ │ ├── event │ │ │ │ │ │ ├── OrderCancelledEvent.java │ │ │ │ │ │ ├── OrderCreatedEvent.java │ │ │ │ │ │ ├── OrderEvent.java │ │ │ │ │ │ └── OrderPaidEvent.java │ │ │ │ │ │ ├── exception │ │ │ │ │ │ ├── OrderDomainException.java │ │ │ │ │ │ └── OrderNotFoundException.java │ │ │ │ │ │ └── valueobject │ │ │ │ │ │ ├── OrderItemId.java │ │ │ │ │ │ ├── StreetAddress.java │ │ │ │ │ │ └── TrackingId.java │ │ │ │ │ └── test │ │ │ │ │ └── java │ │ │ │ │ └── com │ │ │ │ │ └── rolandsall │ │ │ │ │ └── AppTest.java │ │ │ └── pom.xml │ │ ├── order-messaging │ │ │ ├── pom.xml │ │ │ └── src │ │ │ │ ├── main │ │ │ │ └── java │ │ │ │ │ └── com │ │ │ │ │ └── rolandsall │ │ │ │ │ └── App.java │ │ │ │ └── test │ │ │ │ └── java │ │ │ │ └── com │ │ │ │ └── rolandsall │ │ │ │ └── AppTest.java │ │ └── pom.xml │ │ └── pom.xml └── microservice-full-example │ ├── README.md │ └── microservices │ ├── .gitignore │ ├── amqp │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── com │ │ └── rolandsall │ │ └── amqp │ │ ├── RabbitMQConfig.java │ │ └── RabbitMQMessageProducer.java │ ├── build.sh │ ├── client │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── com │ │ └── rolandsall │ │ └── client │ │ ├── fraud │ │ ├── FraudClient.java │ │ └── FraudResponse.java │ │ └── notification │ │ ├── NotificationClient.java │ │ └── NotificationRequest.java │ ├── customer │ ├── Dockerfile │ ├── pom.xml │ └── src │ │ ├── main │ │ ├── java │ │ │ └── com │ │ │ │ └── rolandsall │ │ │ │ └── customer │ │ │ │ ├── CustomerMainApplication.java │ │ │ │ ├── SwaggerConfig.java │ │ │ │ ├── api │ │ │ │ └── customer │ │ │ │ │ ├── CustomerController.java │ │ │ │ │ └── CustomerRegistrationRequest.java │ │ │ │ ├── configurations │ │ │ │ └── CustomerConfiguration.java │ │ │ │ ├── helper │ │ │ │ ├── FraudHandler.java │ │ │ │ └── NotificationHandler.java │ │ │ │ ├── models │ │ │ │ └── Customer.java │ │ │ │ ├── respositories │ │ │ │ └── customer │ │ │ │ │ └── ICustomerRepository.java │ │ │ │ └── services │ │ │ │ ├── CustomerService.java │ │ │ │ ├── ICustomerService.java │ │ │ │ ├── IFraudHandler.java │ │ │ │ └── INotificationHandler.java │ │ └── resources │ │ │ ├── application-docker.yml │ │ │ ├── application.yml │ │ │ └── banner.txt │ │ └── test │ │ ├── java │ │ └── com │ │ │ └── rolandsall │ │ │ └── customer │ │ │ ├── helper │ │ │ ├── FraudHandlerTest.java │ │ │ └── NotificationHandlerTest.java │ │ │ └── services │ │ │ └── CustomerServiceTest.java │ │ └── resources │ │ └── application.yml │ ├── delete_unused_images.sh │ ├── discovery │ ├── Dockerfile │ ├── pom.xml │ └── src │ │ └── main │ │ ├── java │ │ └── com │ │ │ └── rolandsall │ │ │ └── discovery │ │ │ └── DiscoveryMainApplication.java │ │ └── resources │ │ ├── application-docker.yml │ │ ├── application.yml │ │ └── banner.txt │ ├── docker-compose.yml │ ├── fraud │ ├── Dockerfile │ ├── pom.xml │ └── src │ │ └── main │ │ ├── java │ │ └── com │ │ │ └── rolandsall │ │ │ └── fraud │ │ │ ├── FraudMainApplication.java │ │ │ ├── SwaggerConfig.java │ │ │ ├── api │ │ │ └── FraudController.java │ │ │ ├── models │ │ │ └── FraudCheckHistory.java │ │ │ ├── repositories │ │ │ └── FraudCheckHistoryRepository.java │ │ │ └── services │ │ │ ├── FraudCheckService.java │ │ │ └── IFraudCheckService.java │ │ └── resources │ │ ├── application-docker.yml │ │ ├── application.yml │ │ └── banner.txt │ ├── gateway │ ├── Dockerfile │ ├── pom.xml │ └── src │ │ └── main │ │ ├── java │ │ └── com │ │ │ └── rolandsall │ │ │ └── gateway │ │ │ └── GatewayMainApplication.java │ │ └── resources │ │ ├── application-docker.yml │ │ ├── application.yml │ │ └── banner.txt │ ├── notification │ ├── Dockerfile │ ├── pom.xml │ └── src │ │ ├── main │ │ ├── java │ │ │ └── com │ │ │ │ └── rolandsall │ │ │ │ └── notification │ │ │ │ ├── NotificationMainApplication.java │ │ │ │ ├── SwaggerConfig.java │ │ │ │ ├── api │ │ │ │ └── NotificationController.java │ │ │ │ ├── configurations │ │ │ │ └── NotificationConfig.java │ │ │ │ ├── models │ │ │ │ └── Notification.java │ │ │ │ ├── rabbitmq │ │ │ │ └── NotificationConsumer.java │ │ │ │ ├── repositories │ │ │ │ └── INotificationRepository.java │ │ │ │ └── services │ │ │ │ ├── INotificationService.java │ │ │ │ └── NotificationService.java │ │ └── resources │ │ │ ├── application-docker.yml │ │ │ ├── application.yml │ │ │ └── banner.txt │ │ └── test │ │ └── java │ │ └── com │ │ └── rolandsall │ │ └── notification │ │ └── services │ │ └── NotificationServiceTest.java │ ├── pom.xml │ └── test.sh ├── object-oriented-design ├── README.md └── java │ ├── call-center │ ├── README.md │ └── src │ │ ├── Call.java │ │ ├── CallHandler.java │ │ └── Domain │ │ └── BaseEmployee.java │ ├── deck-of-cards │ ├── README.md │ └── src │ │ ├── BlackJackCard.java │ │ ├── BlackJackHand.java │ │ ├── Card.java │ │ ├── Deck.java │ │ ├── Hand.java │ │ ├── Suit.java │ │ └── main.java │ ├── library-management-system │ └── main │ │ ├── README.md │ │ └── src │ │ ├── Entities │ │ ├── Author.java │ │ ├── Book.java │ │ ├── BookItem.java │ │ ├── Client.java │ │ ├── Librarian.java │ │ ├── Library.java │ │ ├── Location.java │ │ ├── Rack.java │ │ ├── RentedBooks.java │ │ └── Staff.java │ │ ├── Enums │ │ └── BookCategory.java │ │ ├── Services │ │ ├── ILibraryService.java │ │ └── LibraryService.java │ │ └── main.java │ ├── music-player-v2-simplified │ ├── README.md │ └── src │ │ └── main.java │ ├── music-player │ ├── README.md │ └── src │ │ ├── DTOs │ │ ├── CreateSingerDto.java │ │ ├── CreateSongDto.java │ │ └── CreateUserDto.java │ │ ├── Strategy │ │ ├── IShuffleBehaviour.java │ │ ├── NormalShuffleBehavior.java │ │ └── RandomShuffleBehavior.java │ │ ├── entities │ │ ├── BaseUser.java │ │ ├── EmailNotification.java │ │ ├── Notification.java │ │ ├── PlayList.java │ │ ├── Pool.java │ │ ├── Singer.java │ │ ├── Song.java │ │ └── User.java │ │ ├── main.java │ │ ├── repos │ │ ├── IMusicSystemDbContext.java │ │ └── MusicSystemDbContext.java │ │ └── services │ │ ├── browse │ │ ├── BrowseService.java │ │ └── IBrowseService.java │ │ ├── notfication │ │ ├── INotificationManager.java │ │ └── NotificationManager.java │ │ ├── playList │ │ ├── IPlayListService.java │ │ └── PlayListService.java │ │ ├── registration │ │ ├── IRegistrationService.java │ │ └── RegistrationService.java │ │ └── singer │ │ ├── ISingerService.java │ │ └── SingerService.java │ └── vending-machibe │ └── src │ ├── Beverage.java │ ├── CoinType.java │ ├── Coke.java │ ├── Pepsi.java │ ├── Soda.java │ ├── Transaction.java │ └── VendingMachine.java ├── software-design └── DDD │ └── README.md └── testing └── unit-testing └── java └── junit ├── testing-demo-v1 ├── README.md └── main │ ├── java │ ├── calculator │ │ ├── Calculator.java │ │ └── SimpleCalculator.java │ ├── gpaCalculator │ │ ├── IGPACalculator.java │ │ └── LAUGPACalculator.java │ └── main.java │ └── test │ └── java │ ├── calculator │ └── SimpleCalculatorTest.java │ └── gpaCalculator │ └── LAUGPACalculatorTest.java └── testing-demo-v2 ├── .gitignore ├── mvnw ├── mvnw.cmd ├── pom.xml └── src ├── main ├── java │ └── com │ │ └── rolandsall │ │ └── testingdemov2 │ │ ├── SwaggerConfig.java │ │ ├── TestingDemoV2Application.java │ │ ├── controller │ │ └── StudentController.java │ │ ├── enums │ │ └── Gender.java │ │ ├── exceptions │ │ ├── BadRequestException.java │ │ └── StudentNotFoundException.java │ │ ├── models │ │ └── Student.java │ │ ├── repos │ │ └── IStudentRepository.java │ │ └── services │ │ ├── IStudentService.java │ │ └── StudentService.java └── resources │ └── application.properties └── test ├── java └── com │ └── rolandsall │ └── testingdemov2 │ ├── TestingDemoV2ApplicationTests.java │ ├── repos │ └── IStudentRepositoryTest.java │ └── services │ └── StudentServiceTest.java └── resources └── application.properties /.idea/.gitignore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RolandSall/Software-Concepts/c2623eac706a8bf998c246c1c4e5d4d3cfc9ed18/.idea/.gitignore -------------------------------------------------------------------------------- /.idea/Software-Concepts.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /APIs/GraphQL/java/sprint-boot/wallet-service/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/**/target/ 5 | !**/src/test/**/target/ 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | *.iws 19 | *.iml 20 | *.ipr 21 | 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /nbbuild/ 25 | /dist/ 26 | /nbdist/ 27 | /.nb-gradle/ 28 | build/ 29 | !**/src/main/**/build/ 30 | !**/src/test/**/build/ 31 | 32 | ### VS Code ### 33 | .vscode/ 34 | -------------------------------------------------------------------------------- /APIs/GraphQL/java/sprint-boot/wallet-service/src/main/java/com/rolandsall/walletservice/domain/Currency.java: -------------------------------------------------------------------------------- 1 | package com.rolandsall.walletservice.domain; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Builder; 5 | import lombok.Data; 6 | import lombok.NoArgsConstructor; 7 | 8 | import javax.persistence.Entity; 9 | import javax.persistence.Id; 10 | 11 | @Data 12 | @Builder 13 | @Entity 14 | @NoArgsConstructor 15 | @AllArgsConstructor 16 | public class Currency { 17 | 18 | @Id 19 | private String code; 20 | private String name; 21 | private String symbol; 22 | private Double salePrice; 23 | private Double purchasePrice; 24 | } 25 | -------------------------------------------------------------------------------- /APIs/GraphQL/java/sprint-boot/wallet-service/src/main/java/com/rolandsall/walletservice/domain/Wallet.java: -------------------------------------------------------------------------------- 1 | package com.rolandsall.walletservice.domain; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Builder; 5 | import lombok.Data; 6 | import lombok.NoArgsConstructor; 7 | 8 | import javax.persistence.*; 9 | import java.util.List; 10 | 11 | @Data 12 | @Builder 13 | @NoArgsConstructor 14 | @AllArgsConstructor 15 | @Entity 16 | public class Wallet { 17 | @Id 18 | private int id; 19 | private double balance; 20 | private Long createdAt; 21 | private int userId; 22 | @ManyToOne 23 | private Currency currency; 24 | 25 | @OneToMany(mappedBy = "wallet") 26 | private List walletTransactions; 27 | } 28 | -------------------------------------------------------------------------------- /APIs/GraphQL/java/sprint-boot/wallet-service/src/main/java/com/rolandsall/walletservice/domain/WalletTransaction.java: -------------------------------------------------------------------------------- 1 | package com.rolandsall.walletservice.domain; 2 | import com.rolandsall.walletservice.enums.TransactionType; 3 | import lombok.AllArgsConstructor; 4 | import lombok.Builder; 5 | import lombok.Data; 6 | import lombok.NoArgsConstructor; 7 | 8 | import javax.persistence.*; 9 | 10 | @Entity 11 | @Data 12 | @NoArgsConstructor 13 | @AllArgsConstructor 14 | @Builder 15 | public class WalletTransaction { 16 | 17 | @Id 18 | @GeneratedValue(strategy = GenerationType.IDENTITY) 19 | private long id; 20 | private Long timeStamp; 21 | private Double amount; 22 | @ManyToOne 23 | private Wallet wallet; 24 | @Enumerated(EnumType.STRING) 25 | private TransactionType type; 26 | 27 | } 28 | -------------------------------------------------------------------------------- /APIs/GraphQL/java/sprint-boot/wallet-service/src/main/java/com/rolandsall/walletservice/dto/AddWalletRequestDTO.java: -------------------------------------------------------------------------------- 1 | package com.rolandsall.walletservice.dto; 2 | 3 | import lombok.*; 4 | 5 | @NoArgsConstructor 6 | @AllArgsConstructor 7 | @Getter 8 | @Setter 9 | @Builder 10 | public class AddWalletRequestDTO { 11 | private Double balance; 12 | private String currencyCode; 13 | } -------------------------------------------------------------------------------- /APIs/GraphQL/java/sprint-boot/wallet-service/src/main/java/com/rolandsall/walletservice/enums/TransactionType.java: -------------------------------------------------------------------------------- 1 | package com.rolandsall.walletservice.enums; 2 | 3 | public enum TransactionType { 4 | DEBIT, 5 | CREDIT 6 | } 7 | -------------------------------------------------------------------------------- /APIs/GraphQL/java/sprint-boot/wallet-service/src/main/java/com/rolandsall/walletservice/repositories/ICurrencyRepository.java: -------------------------------------------------------------------------------- 1 | package com.rolandsall.walletservice.repositories; 2 | 3 | import com.rolandsall.walletservice.domain.Currency; 4 | import org.springframework.data.jpa.repository.JpaRepository; 5 | 6 | public interface ICurrencyRepository extends JpaRepository { 7 | 8 | } 9 | -------------------------------------------------------------------------------- /APIs/GraphQL/java/sprint-boot/wallet-service/src/main/java/com/rolandsall/walletservice/repositories/IWalletRepository.java: -------------------------------------------------------------------------------- 1 | package com.rolandsall.walletservice.repositories; 2 | 3 | import com.rolandsall.walletservice.domain.Wallet; 4 | import org.springframework.data.jpa.repository.JpaRepository; 5 | 6 | public interface IWalletRepository extends JpaRepository { 7 | } 8 | -------------------------------------------------------------------------------- /APIs/GraphQL/java/sprint-boot/wallet-service/src/main/java/com/rolandsall/walletservice/repositories/IWalletTransactionRepository.java: -------------------------------------------------------------------------------- 1 | package com.rolandsall.walletservice.repositories; 2 | 3 | import com.rolandsall.walletservice.domain.WalletTransaction; 4 | import org.springframework.data.jpa.repository.JpaRepository; 5 | 6 | public interface IWalletTransactionRepository extends JpaRepository { 7 | } 8 | -------------------------------------------------------------------------------- /APIs/GraphQL/java/sprint-boot/wallet-service/src/main/java/com/rolandsall/walletservice/service/CurrencyService.java: -------------------------------------------------------------------------------- 1 | package com.rolandsall.walletservice.service; 2 | 3 | 4 | import com.rolandsall.walletservice.domain.Currency; 5 | import com.rolandsall.walletservice.repositories.ICurrencyRepository; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.stereotype.Service; 8 | import org.springframework.transaction.annotation.Transactional; 9 | 10 | import java.util.List; 11 | 12 | @Service 13 | @Transactional 14 | public class CurrencyService implements ICurrencyService { 15 | 16 | private ICurrencyRepository currencyRepository; 17 | 18 | @Autowired 19 | public CurrencyService(ICurrencyRepository currencyRepository) { 20 | this.currencyRepository = currencyRepository; 21 | } 22 | 23 | @Override 24 | public void createCurrencies(List currency) { 25 | currencyRepository.saveAll(currency); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /APIs/GraphQL/java/sprint-boot/wallet-service/src/main/java/com/rolandsall/walletservice/service/ICurrencyService.java: -------------------------------------------------------------------------------- 1 | package com.rolandsall.walletservice.service; 2 | 3 | import com.rolandsall.walletservice.domain.Currency; 4 | 5 | import java.util.List; 6 | 7 | public interface ICurrencyService { 8 | void createCurrencies(List currency); 9 | } 10 | -------------------------------------------------------------------------------- /APIs/GraphQL/java/sprint-boot/wallet-service/src/main/java/com/rolandsall/walletservice/service/IWalletService.java: -------------------------------------------------------------------------------- 1 | package com.rolandsall.walletservice.service; 2 | 3 | import com.rolandsall.walletservice.domain.Wallet; 4 | 5 | import java.util.List; 6 | 7 | public interface IWalletService { 8 | 9 | void createWallet(Wallet wallet); 10 | 11 | List findAll(); 12 | 13 | Wallet findById(int id); 14 | 15 | Wallet addWallet(Wallet wallet); 16 | } 17 | -------------------------------------------------------------------------------- /APIs/GraphQL/java/sprint-boot/wallet-service/src/main/java/com/rolandsall/walletservice/service/IWalletTransactionService.java: -------------------------------------------------------------------------------- 1 | package com.rolandsall.walletservice.service; 2 | 3 | import com.rolandsall.walletservice.domain.WalletTransaction; 4 | 5 | import java.util.List; 6 | 7 | public interface IWalletTransactionService { 8 | 9 | 10 | 11 | void createTransactions(List transaction); 12 | } 13 | -------------------------------------------------------------------------------- /APIs/GraphQL/java/sprint-boot/wallet-service/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.datasource.url=jdbc:h2:mem:wallet-db 2 | spring.datasource.driverClassName=org.h2.Driver 3 | spring.datasource.username=sa 4 | spring.datasource.password=password 5 | spring.jpa.database-platform=org.hibernate.dialect.H2Dialect 6 | spring.h2.console.enabled=true 7 | spring.mvc.pathmatch.matching-strategy = ANT_PATH_MATCHER 8 | 9 | 10 | spring.graphql.graphiql.enabled=true -------------------------------------------------------------------------------- /APIs/GraphQL/java/sprint-boot/wallet-service/src/main/resources/graphql/schema.graphqls: -------------------------------------------------------------------------------- 1 | type Query { 2 | getCurrencies: [Currency], 3 | getCurrenciesByCode(code: String): Currency, 4 | userWallets: [Wallet], 5 | walletById(walletId: Int): Wallet 6 | } 7 | 8 | type Mutation { 9 | addWallet(walletDto: AddWalletRequestDTO): Wallet 10 | } 11 | 12 | input AddWalletRequestDTO { 13 | balance: Float, 14 | currencyCode: String, 15 | } 16 | 17 | type Wallet { 18 | id: Int, 19 | balance:Float, 20 | createAt: Float, 21 | currency: Currency, 22 | walletTransactions: [WalletTransaction] 23 | } 24 | 25 | type Currency { 26 | code: String, 27 | name: String, 28 | salePrice: Float, 29 | purchasePrice: Float, 30 | } 31 | 32 | type WalletTransaction { 33 | id: Int, 34 | timestamp: Float, 35 | wallet: Wallet, 36 | amount: Float, 37 | type: String 38 | } -------------------------------------------------------------------------------- /APIs/GraphQL/java/sprint-boot/wallet-service/src/test/java/com/rolandsall/walletservice/WalletServiceApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.rolandsall.walletservice; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class WalletServiceApplicationTests { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /SOLID/Interface Segregation Principle/java/ISP/src/Checkout.java: -------------------------------------------------------------------------------- 1 | public class Checkout implements Payments { 2 | 3 | 4 | @Override 5 | public void payByCardDetails() { 6 | 7 | } 8 | 9 | @Override 10 | public void payByToken() { 11 | 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /SOLID/Interface Segregation Principle/java/ISP/src/Payments.java: -------------------------------------------------------------------------------- 1 | public interface Payments { 2 | 3 | void payByCardDetails(); 4 | 5 | void payByToken(); 6 | } 7 | -------------------------------------------------------------------------------- /SOLID/Interface Segregation Principle/java/ISP/src/Stripe.java: -------------------------------------------------------------------------------- 1 | public class Stripe implements Payments { 2 | 3 | @Override 4 | public void payByCardDetails() { 5 | 6 | } 7 | 8 | @Override 9 | public void payByToken() { 10 | // not applicable for Stripe 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /SOLID/Interface Segregation Principle/java/ISP/src/fixed/Checkout.java: -------------------------------------------------------------------------------- 1 | package fixed; 2 | 3 | public class Checkout implements TokenManager { 4 | 5 | @Override 6 | public void payByCardDetails() { 7 | 8 | } 9 | 10 | 11 | @Override 12 | public void payByToken() { 13 | 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /SOLID/Interface Segregation Principle/java/ISP/src/fixed/Payments.java: -------------------------------------------------------------------------------- 1 | package fixed; 2 | 3 | public interface Payments { 4 | 5 | void payByCardDetails(); 6 | 7 | } 8 | -------------------------------------------------------------------------------- /SOLID/Interface Segregation Principle/java/ISP/src/fixed/Stripe.java: -------------------------------------------------------------------------------- 1 | package fixed; 2 | 3 | public class Stripe implements Payments { 4 | 5 | 6 | @Override 7 | public void payByCardDetails() { 8 | 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /SOLID/Interface Segregation Principle/java/ISP/src/fixed/TokenManager.java: -------------------------------------------------------------------------------- 1 | package fixed; 2 | 3 | public interface TokenManager extends Payments{ 4 | void payByToken(); 5 | } 6 | -------------------------------------------------------------------------------- /SOLID/Liskov Substitution Principle/java/LSP/.idea/.gitignore: -------------------------------------------------------------------------------- 1 | # Default ignored files 2 | /shelf/ 3 | /workspace.xml 4 | # Editor-based HTTP Client requests 5 | /httpRequests/ 6 | # Datasource local storage ignored files 7 | /dataSources/ 8 | /dataSources.local.xml 9 | -------------------------------------------------------------------------------- /SOLID/Liskov Substitution Principle/java/LSP/.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /SOLID/Liskov Substitution Principle/java/LSP/.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /SOLID/Liskov Substitution Principle/java/LSP/.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /SOLID/Liskov Substitution Principle/java/LSP/LSP.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /SOLID/Liskov Substitution Principle/java/LSP/src/FoodOrderApplication.java: -------------------------------------------------------------------------------- 1 | public abstract class FoodOrderApplication { 2 | 3 | 4 | // supported By Zomato 5 | public abstract void checkDriverLocation(); 6 | 7 | // supported by Zomato and Totters 8 | public abstract void PayDirectly(); 9 | 10 | // supported by Totters 11 | public abstract void askForFoodRecommendation(); 12 | 13 | } 14 | -------------------------------------------------------------------------------- /SOLID/Liskov Substitution Principle/java/LSP/src/Totters.java: -------------------------------------------------------------------------------- 1 | public class Totters extends FoodOrderApplication{ 2 | 3 | // violates LSP since totters does not support the following 4 | @Override 5 | public void checkDriverLocation() { 6 | 7 | } 8 | 9 | @Override 10 | public void PayDirectly() { 11 | 12 | } 13 | 14 | @Override 15 | public void askForFoodRecommendation() { 16 | 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /SOLID/Liskov Substitution Principle/java/LSP/src/Zomato.java: -------------------------------------------------------------------------------- 1 | public class Zomato extends FoodOrderApplication{ 2 | 3 | 4 | @Override 5 | public void checkDriverLocation() { 6 | 7 | } 8 | 9 | @Override 10 | public void PayDirectly() { 11 | 12 | } 13 | 14 | 15 | // violates LSP since zomato does not support the following 16 | @Override 17 | public void askForFoodRecommendation() { 18 | 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /SOLID/Liskov Substitution Principle/java/LSP/src/fixed/ChatManager.java: -------------------------------------------------------------------------------- 1 | package fixed; 2 | 3 | public interface ChatManager { 4 | 5 | void checkDriverLocation(); 6 | } 7 | -------------------------------------------------------------------------------- /SOLID/Liskov Substitution Principle/java/LSP/src/fixed/PayDirectlyManager.java: -------------------------------------------------------------------------------- 1 | package fixed; 2 | 3 | public interface PayDirectlyManager { 4 | 5 | void PayDirectly(); 6 | } 7 | -------------------------------------------------------------------------------- /SOLID/Liskov Substitution Principle/java/LSP/src/fixed/RecommendationSystem.java: -------------------------------------------------------------------------------- 1 | package fixed; 2 | 3 | public interface RecommendationSystem { 4 | 5 | void askForFoodRecommendation(); 6 | } 7 | -------------------------------------------------------------------------------- /SOLID/Liskov Substitution Principle/java/LSP/src/fixed/Totters.java: -------------------------------------------------------------------------------- 1 | package fixed; 2 | 3 | public class Totters implements RecommendationSystem, PayDirectlyManager{ 4 | 5 | // implements the methods that is supported 6 | 7 | @Override 8 | public void PayDirectly() { 9 | 10 | } 11 | 12 | @Override 13 | public void askForFoodRecommendation() { 14 | 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /SOLID/Liskov Substitution Principle/java/LSP/src/fixed/Zomato.java: -------------------------------------------------------------------------------- 1 | package fixed; 2 | 3 | public class Zomato implements PayDirectlyManager,ChatManager{ 4 | 5 | @Override 6 | public void PayDirectly() { 7 | 8 | } 9 | 10 | @Override 11 | public void checkDriverLocation() { 12 | 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /SOLID/Open-Closed Principle/README.md: -------------------------------------------------------------------------------- 1 | # Open-Closed Principle 2 | 3 | > The open-closed principle states that software entities should be open for extension, but closed for modification. 4 | 5 | This implies that such entities – classes, functions, and so on – should be created in a way that their core functionalities can be extended to other entities without altering the initial entity's source code. 6 | 7 | -------------------------------------------------------------------------------- /SOLID/Open-Closed Principle/csharp/OCP/ConsoleApp/ConsoleApp.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net6.0 6 | enable 7 | enable 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /SOLID/Open-Closed Principle/csharp/OCP/ConsoleApp/Program.cs: -------------------------------------------------------------------------------- 1 |  2 | using Domain; 3 | 4 | public class Program 5 | { 6 | static void Main(string[] args) 7 | { 8 | List applicants = new List 9 | { 10 | new Student() { FirstName = "Robin", LastName = "Karaa" , }, 11 | new Staff() { FirstName = "Nick", LastName = "Young" }, 12 | new Student() { FirstName = "James", LastName = "Thomas" } 13 | }; 14 | 15 | List students = new List(); 16 | //Account account = new Account(); 17 | 18 | foreach (var person in applicants) 19 | { 20 | students.Add(person.Account.Create(person)); 21 | } 22 | 23 | foreach (var student in students) 24 | { 25 | Console.WriteLine($"{student.FirstName } { student.LastName } { student.EmailAddress }"); 26 | } 27 | 28 | Console.ReadLine(); 29 | 30 | } 31 | } -------------------------------------------------------------------------------- /SOLID/Open-Closed Principle/csharp/OCP/Domain/Accounts/IAccount.cs: -------------------------------------------------------------------------------- 1 | namespace Domain.Accounts; 2 | 3 | public interface IAccount 4 | { 5 | public Employee Create(Person person); 6 | } -------------------------------------------------------------------------------- /SOLID/Open-Closed Principle/csharp/OCP/Domain/Accounts/StaffAccount.cs: -------------------------------------------------------------------------------- 1 | namespace Domain.Accounts; 2 | 3 | public class StaffAccount: IAccount 4 | { 5 | public Employee Create(Person person) 6 | { 7 | return new Employee() 8 | { 9 | FirstName = person.FirstName, 10 | LastName = person.LastName, 11 | EmailAddress = $"{person.FirstName}.{person.LastName}.staff.@lau.edu" 12 | }; 13 | } 14 | } -------------------------------------------------------------------------------- /SOLID/Open-Closed Principle/csharp/OCP/Domain/Accounts/StudentAccount.cs: -------------------------------------------------------------------------------- 1 | namespace Domain.Accounts; 2 | 3 | public class StudentAccount: IAccount 4 | { 5 | public Employee Create(Person person) 6 | { 7 | return new Employee() 8 | { 9 | FirstName = person.FirstName, 10 | LastName = person.LastName, 11 | EmailAddress = $"{person.FirstName}.{person.LastName}@lau.edu" 12 | }; 13 | } 14 | } -------------------------------------------------------------------------------- /SOLID/Open-Closed Principle/csharp/OCP/Domain/Domain.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net6.0 5 | enable 6 | enable 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /SOLID/Open-Closed Principle/csharp/OCP/Domain/Employee.cs: -------------------------------------------------------------------------------- 1 | namespace Domain; 2 | 3 | public class Employee 4 | { 5 | public string? FirstName { get; set; } 6 | public string? LastName { get; set; } 7 | public string? EmailAddress { get; set; } 8 | } -------------------------------------------------------------------------------- /SOLID/Open-Closed Principle/csharp/OCP/Domain/Person.cs: -------------------------------------------------------------------------------- 1 | using Domain.Accounts; 2 | 3 | namespace Domain; 4 | 5 | public interface Person 6 | { 7 | public string? FirstName { get; set; } 8 | public string? LastName { get; set; } 9 | public IAccount Account { get; set; } 10 | } -------------------------------------------------------------------------------- /SOLID/Open-Closed Principle/csharp/OCP/Domain/Staff.cs: -------------------------------------------------------------------------------- 1 | using Domain.Accounts; 2 | 3 | namespace Domain; 4 | 5 | public class Staff: Person 6 | { 7 | public string? FirstName { get; set; } 8 | public string? LastName { get; set; } 9 | public IAccount Account { get; set; }= new StaffAccount(); 10 | } -------------------------------------------------------------------------------- /SOLID/Open-Closed Principle/csharp/OCP/Domain/Student.cs: -------------------------------------------------------------------------------- 1 | using Domain.Accounts; 2 | 3 | namespace Domain; 4 | 5 | public class Student: Person 6 | { 7 | public string? FirstName { get; set; } 8 | public string? LastName { get; set; } 9 | 10 | public IAccount Account { get; set; }= new StudentAccount(); 11 | } -------------------------------------------------------------------------------- /SOLID/Open-Closed Principle/java/OCP/src/BMI.java: -------------------------------------------------------------------------------- 1 | public class BMI { 2 | 3 | public int calculatedMaleBMI(Human m){ 4 | return m.getHeight()/m.getWeight(); 5 | } 6 | 7 | // assume that for a female you calculate the BMI 8 | // in a different way 9 | public int calculatedFemaleBMI(Human f){ 10 | return f.getHeight()-5/f.getWeight(); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /SOLID/Open-Closed Principle/java/OCP/src/Human.java: -------------------------------------------------------------------------------- 1 | public class Human { 2 | private int weight; 3 | private int height; 4 | 5 | public int getWeight() { 6 | return weight; 7 | } 8 | 9 | public void setWeight(int weight) { 10 | this.weight = weight; 11 | } 12 | 13 | public int getHeight() { 14 | return height; 15 | } 16 | 17 | public void setHeight(int height) { 18 | this.height = height; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /SOLID/Open-Closed Principle/java/OCP/src/fixed/Female.java: -------------------------------------------------------------------------------- 1 | package fixed; 2 | 3 | public class Female implements Human{ 4 | 5 | 6 | private int height; 7 | private int weight; 8 | 9 | 10 | @Override 11 | public int calculateBMI() { 12 | return height-5/weight; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /SOLID/Open-Closed Principle/java/OCP/src/fixed/Human.java: -------------------------------------------------------------------------------- 1 | package fixed; 2 | 3 | public interface Human { 4 | 5 | public int calculateBMI(); 6 | } 7 | -------------------------------------------------------------------------------- /SOLID/Open-Closed Principle/java/OCP/src/fixed/Male.java: -------------------------------------------------------------------------------- 1 | package fixed; 2 | 3 | public class Male implements Human{ 4 | 5 | private int height; 6 | private int weight; 7 | 8 | @Override 9 | public int calculateBMI() { 10 | return height/weight; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /SOLID/README.md: -------------------------------------------------------------------------------- 1 | # SOLID Principles 2 | 3 | SOLID is an acronym for five main principles of Object-Oriented Programming (OOP): 4 | 5 | * Single responsibility principle 6 | * Open-closed principle 7 | * Liskov substitution principle 8 | * Interface segregation principle 9 | * Dependency inversion principle. -------------------------------------------------------------------------------- /SOLID/Single Responsibility/csharp/SRP/SRP.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SRP", "SRP\SRP.csproj", "{51D53A01-33F6-463B-AE23-0AD584F785D2}" 4 | EndProject 5 | Global 6 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 7 | Debug|Any CPU = Debug|Any CPU 8 | Release|Any CPU = Release|Any CPU 9 | EndGlobalSection 10 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 11 | {51D53A01-33F6-463B-AE23-0AD584F785D2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 12 | {51D53A01-33F6-463B-AE23-0AD584F785D2}.Debug|Any CPU.Build.0 = Debug|Any CPU 13 | {51D53A01-33F6-463B-AE23-0AD584F785D2}.Release|Any CPU.ActiveCfg = Release|Any CPU 14 | {51D53A01-33F6-463B-AE23-0AD584F785D2}.Release|Any CPU.Build.0 = Release|Any CPU 15 | EndGlobalSection 16 | EndGlobal 17 | -------------------------------------------------------------------------------- /SOLID/Single Responsibility/csharp/SRP/SRP/Person.cs: -------------------------------------------------------------------------------- 1 | namespace SRP; 2 | 3 | public class Person 4 | { 5 | public string? FirstName { get; set; } 6 | public string? LastName { get; set; } 7 | } -------------------------------------------------------------------------------- /SOLID/Single Responsibility/csharp/SRP/SRP/SRP.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net6.0 6 | enable 7 | enable 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /SOLID/Single Responsibility/csharp/SRP/SRP/alternative/Main.cs: -------------------------------------------------------------------------------- 1 | namespace SRP.alternative; 2 | 3 | public class MainNew 4 | { 5 | static void Main(string[] args) 6 | { 7 | Messages.WelcomeMessage(); 8 | Person user = PersonData.Capture(); 9 | bool isValid = PersonValidator.Validate(user); 10 | 11 | if (!isValid) 12 | { 13 | Messages.EndApplication(); 14 | return; 15 | } 16 | UsernameGenerator.Generate(user); 17 | Messages.EndApplication(); 18 | } 19 | } -------------------------------------------------------------------------------- /SOLID/Single Responsibility/csharp/SRP/SRP/alternative/Messages.cs: -------------------------------------------------------------------------------- 1 | namespace SRP.alternative; 2 | 3 | public class Messages 4 | { 5 | public static void WelcomeMessage() 6 | { 7 | Console.WriteLine("Welcome To This Journey"); 8 | } 9 | 10 | public static void DisplayValidationError(string field) 11 | { 12 | Console.Write($"Not A Valid {field}! Try Again \n"); 13 | } 14 | 15 | public static void EndApplication() 16 | { 17 | Console.ReadLine(); 18 | } 19 | } -------------------------------------------------------------------------------- /SOLID/Single Responsibility/csharp/SRP/SRP/alternative/PersonData.cs: -------------------------------------------------------------------------------- 1 | namespace SRP.alternative; 2 | 3 | public class PersonData 4 | { 5 | public static Person Capture() 6 | { 7 | Person result = new Person(); 8 | 9 | Console.Write("Enter Your First Name \n"); 10 | result.FirstName = Console.ReadLine(); 11 | 12 | Console.Write("Enter Your Last Name \n"); 13 | result.LastName = Console.ReadLine(); 14 | 15 | return result; 16 | } 17 | } -------------------------------------------------------------------------------- /SOLID/Single Responsibility/csharp/SRP/SRP/alternative/PersonValidator.cs: -------------------------------------------------------------------------------- 1 | namespace SRP.alternative; 2 | 3 | public class PersonValidator 4 | { 5 | public static bool Validate(Person person) 6 | { 7 | if (string.IsNullOrWhiteSpace(person.FirstName)) 8 | { 9 | Console.Write("Not A Valid First Name! Try Again \n"); 10 | return false; 11 | } 12 | 13 | if (string.IsNullOrWhiteSpace(person.LastName)) 14 | { 15 | Console.Write("Not A Valid Last Name! Try Again \n"); 16 | return false; 17 | } 18 | 19 | return true; 20 | } 21 | } -------------------------------------------------------------------------------- /SOLID/Single Responsibility/csharp/SRP/SRP/alternative/UsernameGenerator.cs: -------------------------------------------------------------------------------- 1 | namespace SRP.alternative; 2 | 3 | public class UsernameGenerator 4 | { 5 | public static void Generate(Person person) 6 | { 7 | Console.Write($"Your username is {person.FirstName.Substring(0,1)} {person.LastName} "); 8 | } 9 | } -------------------------------------------------------------------------------- /SOLID/Single Responsibility/java/SRP/src/Student.java: -------------------------------------------------------------------------------- 1 | public class Student { 2 | 3 | // This class violates SRP principle since it does multiple functionalities 4 | 5 | 6 | public void registerStudent() { 7 | // some logic 8 | } 9 | 10 | public void calculate_Student_Results() { 11 | // some logic 12 | } 13 | 14 | public void sendEmail() { 15 | // some logic 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /SOLID/Single Responsibility/java/SRP/src/fixed/StudentEmails.java: -------------------------------------------------------------------------------- 1 | package fixed; 2 | 3 | public class StudentEmails { 4 | 5 | public void sendEmail() { 6 | // some logic 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /SOLID/Single Responsibility/java/SRP/src/fixed/StudentRegister.java: -------------------------------------------------------------------------------- 1 | package fixed; 2 | 3 | public class StudentRegister { 4 | public void registerStudent() { 5 | // some logic 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /SOLID/Single Responsibility/java/SRP/src/fixed/StudentResult.java: -------------------------------------------------------------------------------- 1 | package fixed; 2 | 3 | public class StudentResult { 4 | public void calculate_Student_Result() { 5 | // some logic 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /articles/README.md: -------------------------------------------------------------------------------- 1 | # Descriptions: 2 | 3 | The following directory will contains hyperlinks for articles that will be published for different software topics. Example 4 | ``` bash 5 | articles 6 | | 7 | | 8 | |____ microservices 9 | | | 10 | | |__ spring_cloud 11 | | | 12 | | | 13 | | |__ pattern_1 14 | | | 15 | | | 16 | | |_ README.md (contains article link) 17 | | |_ source_code 18 | | 19 | | 20 | . 21 | . 22 | |____ design_patterns 23 | 24 | ``` 25 | 26 | -------------------------------------------------------------------------------- /design-patterns/Behavioral Pattern/Mediator-CQRS/dotnet-core/global.json: -------------------------------------------------------------------------------- 1 | { 2 | "sdk": { 3 | "version": "6.0.0", 4 | "rollForward": "latestMinor", 5 | "allowPrerelease": false 6 | } 7 | } -------------------------------------------------------------------------------- /design-patterns/Behavioral Pattern/Mediator-CQRS/dotnet-core/mediator-cqrs.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "mediator-cqrs", "mediator-cqrs\mediator-cqrs.csproj", "{8E91E7B4-B03E-4978-B274-9A5F2EEAAAA2}" 4 | EndProject 5 | Global 6 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 7 | Debug|Any CPU = Debug|Any CPU 8 | Release|Any CPU = Release|Any CPU 9 | EndGlobalSection 10 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 11 | {8E91E7B4-B03E-4978-B274-9A5F2EEAAAA2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 12 | {8E91E7B4-B03E-4978-B274-9A5F2EEAAAA2}.Debug|Any CPU.Build.0 = Debug|Any CPU 13 | {8E91E7B4-B03E-4978-B274-9A5F2EEAAAA2}.Release|Any CPU.ActiveCfg = Release|Any CPU 14 | {8E91E7B4-B03E-4978-B274-9A5F2EEAAAA2}.Release|Any CPU.Build.0 = Release|Any CPU 15 | EndGlobalSection 16 | EndGlobal 17 | -------------------------------------------------------------------------------- /design-patterns/Behavioral Pattern/Mediator-CQRS/dotnet-core/mediator-cqrs/.gitignore: -------------------------------------------------------------------------------- 1 | .idea 2 | . -------------------------------------------------------------------------------- /design-patterns/Behavioral Pattern/Mediator-CQRS/dotnet-core/mediator-cqrs/Controllers/CreateProductRequest.cs: -------------------------------------------------------------------------------- 1 | using System.Runtime.InteropServices; 2 | 3 | namespace mediator_cqrs.Controllers; 4 | 5 | public class CreateProductRequest 6 | { 7 | 8 | 9 | public string Name { get; set; } 10 | public long SerialNumber { get; set; } 11 | } -------------------------------------------------------------------------------- /design-patterns/Behavioral Pattern/Mediator-CQRS/dotnet-core/mediator-cqrs/Folder.DotSettings.user: -------------------------------------------------------------------------------- 1 |  2 | C:\Program Files\dotnet\sdk\6.0.101\MSBuild.dll 3 | 4294967294 -------------------------------------------------------------------------------- /design-patterns/Behavioral Pattern/Mediator-CQRS/dotnet-core/mediator-cqrs/Handlers/Product/GetAllProductOrdersQueryHandler.cs: -------------------------------------------------------------------------------- 1 | using mediator_cqrs.Queries.Product; 2 | using mediator_cqrs.Repository; 3 | using MediatR; 4 | 5 | namespace mediator_cqrs.Handlers.Product; 6 | 7 | public class GetAllProductOrdersQueryHandler: IRequestHandler> 8 | 9 | { 10 | 11 | private readonly IProductRepo _productRepo; 12 | 13 | public GetAllProductOrdersQueryHandler(IProductRepo productRepo) 14 | { 15 | _productRepo = productRepo; 16 | } 17 | 18 | public async Task> Handle(GetAllOrdersQuery request, CancellationToken cancellationToken) 19 | { 20 | return _productRepo.GetAllProducts(); 21 | } 22 | } -------------------------------------------------------------------------------- /design-patterns/Behavioral Pattern/Mediator-CQRS/dotnet-core/mediator-cqrs/Queries/Product/GetAllOrdersQuery.cs: -------------------------------------------------------------------------------- 1 | using MediatR; 2 | 3 | namespace mediator_cqrs.Queries.Product; 4 | 5 | public class GetAllOrdersQuery: IRequest> 6 | { 7 | 8 | } -------------------------------------------------------------------------------- /design-patterns/Behavioral Pattern/Mediator-CQRS/dotnet-core/mediator-cqrs/Repository/DummyProductRepo.cs: -------------------------------------------------------------------------------- 1 | using mediator_cqrs.entities; 2 | 3 | namespace mediator_cqrs.Repository; 4 | 5 | public class DummyProductRepo: IProductRepo 6 | { 7 | 8 | private List _list = new List(); 9 | 10 | public DummyProductRepo() 11 | { 12 | var product_one = new Product(0, "XBOX", 13123); 13 | var product_two = new Product(1, "PS4", 13123); 14 | _list.Add(product_one); 15 | _list.Add(product_two); 16 | } 17 | 18 | 19 | public List GetAllProducts() 20 | { 21 | 22 | return _list; 23 | } 24 | 25 | public string CreateProduct(Product product) 26 | { 27 | _list.Add(product); 28 | return "Created"; 29 | } 30 | } -------------------------------------------------------------------------------- /design-patterns/Behavioral Pattern/Mediator-CQRS/dotnet-core/mediator-cqrs/Repository/IProductRepo.cs: -------------------------------------------------------------------------------- 1 | using mediator_cqrs.entities; 2 | 3 | namespace mediator_cqrs.Repository; 4 | 5 | public interface IProductRepo 6 | { 7 | public List GetAllProducts(); 8 | 9 | 10 | public String CreateProduct(Product product); 11 | } -------------------------------------------------------------------------------- /design-patterns/Behavioral Pattern/Mediator-CQRS/dotnet-core/mediator-cqrs/Validation/CreateProductCommandValidator.cs: -------------------------------------------------------------------------------- 1 | using FluentValidation; 2 | using mediator_cqrs.Commands.Product; 3 | 4 | namespace mediator_cqrs.Validation 5 | { 6 | 7 | public class CreateProductCommandValidator : AbstractValidator 8 | { 9 | public CreateProductCommandValidator() 10 | { 11 | RuleFor(x => x.SerialNumber).NotNull().NotEqual(0); 12 | RuleFor(x => x.Name).NotNull().NotEqual("foo"); 13 | } 14 | 15 | 16 | } 17 | } -------------------------------------------------------------------------------- /design-patterns/Behavioral Pattern/Mediator-CQRS/dotnet-core/mediator-cqrs/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft.AspNetCore": "Warning" 6 | } 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /design-patterns/Behavioral Pattern/Mediator-CQRS/dotnet-core/mediator-cqrs/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft.AspNetCore": "Warning" 6 | } 7 | }, 8 | "AllowedHosts": "*" 9 | } 10 | -------------------------------------------------------------------------------- /design-patterns/Behavioral Pattern/Mediator-CQRS/dotnet-core/mediator-cqrs/entities/Product.cs: -------------------------------------------------------------------------------- 1 | namespace mediator_cqrs.entities; 2 | 3 | public class Product 4 | { 5 | public int ProductId { get; set; } 6 | public string Name { get; set; } 7 | public long SerialNumber { get; set; } 8 | 9 | public Product(int productId, string name, long serialNumber) 10 | { 11 | ProductId = productId; 12 | Name = name; 13 | SerialNumber = serialNumber; 14 | } 15 | 16 | } -------------------------------------------------------------------------------- /design-patterns/Behavioral Pattern/Mediator-CQRS/dotnet-core/mediator-cqrs/images/MediatR-pipeline.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RolandSall/Software-Concepts/c2623eac706a8bf998c246c1c4e5d4d3cfc9ed18/design-patterns/Behavioral Pattern/Mediator-CQRS/dotnet-core/mediator-cqrs/images/MediatR-pipeline.png -------------------------------------------------------------------------------- /design-patterns/Behavioral Pattern/Mediator-CQRS/dotnet-core/mediator-cqrs/mediator-cqrs.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net6.0 5 | enable 6 | enable 7 | mediator_cqrs 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /design-patterns/Behavioral Pattern/Mediator-CQRS/dotnet-core/mediator-cqrs/mediator-cqrs.csproj.DotSettings: -------------------------------------------------------------------------------- 1 |  2 | CSharp100 -------------------------------------------------------------------------------- /design-patterns/Behavioral Pattern/Strategy/War/README.md: -------------------------------------------------------------------------------- 1 | # Problem 2 | 3 | This problem is taken from the strategy pattern from [this book](https://www.amazon.com/Head-First-Design-Patterns-Brain-Friendly/dp/0596007124) 4 | 5 | This directory will contain its solution (the classes have slight changes but follow the same concepts). -------------------------------------------------------------------------------- /design-patterns/Behavioral Pattern/Strategy/War/src/Behavior/Weapon/AxeBehavior.java: -------------------------------------------------------------------------------- 1 | package Behavior.Weapon; 2 | 3 | public class AxeBehavior implements IWeaponBehavior { 4 | @Override 5 | public void useWeapon() { 6 | System.out.println("Throw axe"); 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /design-patterns/Behavioral Pattern/Strategy/War/src/Behavior/Weapon/CrossbowBehavior.java: -------------------------------------------------------------------------------- 1 | package Behavior.Weapon; 2 | 3 | public class CrossbowBehavior implements IWeaponBehavior { 4 | @Override 5 | public void useWeapon() { 6 | System.out.println("Shoot Arrows"); 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /design-patterns/Behavioral Pattern/Strategy/War/src/Behavior/Weapon/IWeaponBehavior.java: -------------------------------------------------------------------------------- 1 | package Behavior.Weapon; 2 | 3 | public interface IWeaponBehavior { 4 | 5 | void useWeapon(); 6 | } 7 | -------------------------------------------------------------------------------- /design-patterns/Behavioral Pattern/Strategy/War/src/Behavior/Weapon/KnifeBehavior.java: -------------------------------------------------------------------------------- 1 | package Behavior.Weapon; 2 | 3 | public class KnifeBehavior implements IWeaponBehavior { 4 | @Override 5 | public void useWeapon() { 6 | 7 | System.out.println("Throw Knife"); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /design-patterns/Behavioral Pattern/Strategy/War/src/Behavior/Weapon/SwordBehavior.java: -------------------------------------------------------------------------------- 1 | package Behavior.Weapon; 2 | 3 | public class SwordBehavior implements IWeaponBehavior { 4 | @Override 5 | public void useWeapon() { 6 | System.out.println("Attack With Sword"); 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /design-patterns/Behavioral Pattern/Strategy/War/src/Domain/Character.java: -------------------------------------------------------------------------------- 1 | package Domain; 2 | 3 | import Behavior.Weapon.IWeaponBehavior; 4 | 5 | public abstract class Character { 6 | 7 | private IWeaponBehavior weaponBehavior; 8 | 9 | 10 | 11 | public void setWeaponBehavior(IWeaponBehavior weaponBehavior) { 12 | this.weaponBehavior = weaponBehavior; 13 | } 14 | 15 | public void fight(){ 16 | weaponBehavior.useWeapon(); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /design-patterns/Behavioral Pattern/Strategy/War/src/Domain/Knight.java: -------------------------------------------------------------------------------- 1 | package Domain; 2 | 3 | import Behavior.Weapon.SwordBehavior; 4 | 5 | public class Knight extends Character{ 6 | 7 | 8 | public Knight() { 9 | setWeaponBehavior(new SwordBehavior()); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /design-patterns/Behavioral Pattern/Strategy/War/src/Domain/Troll.java: -------------------------------------------------------------------------------- 1 | package Domain; 2 | 3 | import Behavior.Weapon.CrossbowBehavior; 4 | 5 | public class Troll extends Character{ 6 | 7 | public Troll(){ 8 | setWeaponBehavior(new CrossbowBehavior()); 9 | } 10 | 11 | } 12 | -------------------------------------------------------------------------------- /design-patterns/Behavioral Pattern/Strategy/War/src/main.java: -------------------------------------------------------------------------------- 1 | import Behavior.Weapon.AxeBehavior; 2 | import Domain.Character; 3 | import Domain.Knight; 4 | import Domain.Troll; 5 | 6 | public class main { 7 | public static void main(String[] args) { 8 | 9 | Character knight = new Knight(); 10 | knight.fight(); 11 | 12 | knight.setWeaponBehavior(new AxeBehavior()); 13 | knight.fight(); 14 | 15 | 16 | Character troll = new Troll(); 17 | troll.fight(); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /design-patterns/Behavioral Pattern/Strategy/duckExample/src/Behaviours/DuckCallSystem.java: -------------------------------------------------------------------------------- 1 | package Behaviours; 2 | 3 | 4 | import Behaviours.Quack.IQuackBehavior; 5 | 6 | /** 7 | * since the behaviour is already there 8 | * even not related duck subclasses can use it 9 | */ 10 | public class DuckCallSystem { 11 | 12 | private IQuackBehavior quackBehavior; 13 | 14 | public DuckCallSystem(IQuackBehavior quackBehavior) { 15 | this.quackBehavior = quackBehavior; 16 | } 17 | 18 | public void start(){ 19 | System.out.println("Starting System Audio ...."); 20 | quackBehavior.quack(); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /design-patterns/Behavioral Pattern/Strategy/duckExample/src/Behaviours/Fly/IFlyBehavior.java: -------------------------------------------------------------------------------- 1 | package Behaviours.Fly; 2 | 3 | public interface IFlyBehavior { 4 | 5 | public void fly(); 6 | } 7 | -------------------------------------------------------------------------------- /design-patterns/Behavioral Pattern/Strategy/duckExample/src/Behaviours/Fly/NoFly.java: -------------------------------------------------------------------------------- 1 | package Behaviours.Fly; 2 | 3 | public class NoFly implements IFlyBehavior { 4 | 5 | @Override 6 | public void fly() { 7 | System.out.println("I Can't even Fly"); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /design-patterns/Behavioral Pattern/Strategy/duckExample/src/Behaviours/Fly/SlowFly.java: -------------------------------------------------------------------------------- 1 | package Behaviours.Fly; 2 | 3 | public class SlowFly implements IFlyBehavior { 4 | 5 | 6 | @Override 7 | public void fly() { 8 | System.out.println("This is best i can do"); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /design-patterns/Behavioral Pattern/Strategy/duckExample/src/Behaviours/Quack/IQuackBehavior.java: -------------------------------------------------------------------------------- 1 | package Behaviours.Quack; 2 | 3 | public interface IQuackBehavior { 4 | 5 | public void quack(); 6 | } 7 | -------------------------------------------------------------------------------- /design-patterns/Behavioral Pattern/Strategy/duckExample/src/Behaviours/Quack/MuteQuack.java: -------------------------------------------------------------------------------- 1 | package Behaviours.Quack; 2 | 3 | public class MuteQuack implements IQuackBehavior { 4 | 5 | @Override 6 | public void quack() { 7 | System.out.println(""); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /design-patterns/Behavioral Pattern/Strategy/duckExample/src/Behaviours/Quack/NormalQuack.java: -------------------------------------------------------------------------------- 1 | package Behaviours.Quack; 2 | 3 | public class NormalQuack implements IQuackBehavior { 4 | 5 | @Override 6 | public void quack() { 7 | System.out.println("Quack"); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /design-patterns/Behavioral Pattern/Strategy/duckExample/src/CityDuck.java: -------------------------------------------------------------------------------- 1 | import Behaviours.Fly.SlowFly; 2 | import Behaviours.Quack.IQuackBehavior; 3 | import Behaviours.Quack.NormalQuack; 4 | 5 | public class CityDuck extends Duck{ 6 | 7 | 8 | public CityDuck() { 9 | setIQuackBehavior(new NormalQuack()); 10 | setIFlyBehavior(new SlowFly()); 11 | } 12 | 13 | 14 | 15 | @Override 16 | public void display() { 17 | System.out.println("I am a city duck"); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /design-patterns/Behavioral Pattern/Strategy/duckExample/src/Duck.java: -------------------------------------------------------------------------------- 1 | import Behaviours.Fly.IFlyBehavior; 2 | import Behaviours.Quack.IQuackBehavior; 3 | 4 | public abstract class Duck { 5 | 6 | private IQuackBehavior iQuackBehavior; 7 | private IFlyBehavior iFlyBehavior; 8 | 9 | public void performFly(){ 10 | iFlyBehavior.fly(); 11 | } 12 | 13 | public void performQuack(){ 14 | iQuackBehavior.quack(); 15 | } 16 | 17 | public void setIQuackBehavior(IQuackBehavior iQuackBehavior) { 18 | this.iQuackBehavior = iQuackBehavior; 19 | } 20 | 21 | public void setIFlyBehavior(IFlyBehavior iFlyBehavior) { 22 | this.iFlyBehavior = iFlyBehavior; 23 | } 24 | 25 | public abstract void display(); 26 | public void swim(){ 27 | System.out.println("Swim"); 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /design-patterns/Behavioral Pattern/Strategy/duckExample/src/main.java: -------------------------------------------------------------------------------- 1 | import Behaviours.DuckCallSystem; 2 | import Behaviours.Quack.MuteQuack; 3 | import Behaviours.Quack.NormalQuack; 4 | 5 | public class main { 6 | public static void main(String[] args) { 7 | 8 | Duck duck = new CityDuck(); 9 | 10 | duck.performQuack(); 11 | duck.performFly(); 12 | 13 | duck.setIQuackBehavior(new MuteQuack()); 14 | 15 | duck.performQuack(); 16 | 17 | 18 | DuckCallSystem duckCallSystem = new DuckCallSystem(new NormalQuack()); 19 | 20 | // notice also the abstraction 21 | duckCallSystem.start(); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /design-patterns/Behavioral Pattern/Strategy/images/img1.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RolandSall/Software-Concepts/c2623eac706a8bf998c246c1c4e5d4d3cfc9ed18/design-patterns/Behavioral Pattern/Strategy/images/img1.PNG -------------------------------------------------------------------------------- /design-patterns/Behavioral Pattern/Strategy/images/img2.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RolandSall/Software-Concepts/c2623eac706a8bf998c246c1c4e5d4d3cfc9ed18/design-patterns/Behavioral Pattern/Strategy/images/img2.PNG -------------------------------------------------------------------------------- /design-patterns/Behavioral Pattern/Strategy/images/img3.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RolandSall/Software-Concepts/c2623eac706a8bf998c246c1c4e5d4d3cfc9ed18/design-patterns/Behavioral Pattern/Strategy/images/img3.PNG -------------------------------------------------------------------------------- /design-patterns/Creational Pattern/AbstractFactory/java/AbstractFactoryDemo/src/Factory/AbstractFactory.java: -------------------------------------------------------------------------------- 1 | package Factory; 2 | 3 | import Shapes.IShape; 4 | 5 | public abstract class AbstractFactory { 6 | 7 | public abstract IShape getShape(String shapeType); 8 | } 9 | -------------------------------------------------------------------------------- /design-patterns/Creational Pattern/AbstractFactory/java/AbstractFactoryDemo/src/Factory/FactoryProducer.java: -------------------------------------------------------------------------------- 1 | package Factory; 2 | 3 | public class FactoryProducer { 4 | public static AbstractFactory getFactory(boolean rounded){ 5 | if(rounded){ 6 | return new RoundedShapeFactory(); 7 | }else{ 8 | return new ShapeFactory(); 9 | } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /design-patterns/Creational Pattern/AbstractFactory/java/AbstractFactoryDemo/src/Factory/RoundedShapeFactory.java: -------------------------------------------------------------------------------- 1 | package Factory; 2 | 3 | import Shapes.IShape; 4 | import Shapes.RoundedRectangle; 5 | import Shapes.RoundedSquare; 6 | 7 | public class RoundedShapeFactory extends AbstractFactory{ 8 | 9 | @Override 10 | public IShape getShape(String shapeType){ 11 | if(shapeType.equalsIgnoreCase("RECTANGLE")){ 12 | return new RoundedRectangle(); 13 | }else if(shapeType.equalsIgnoreCase("SQUARE")){ 14 | return new RoundedSquare(); 15 | } 16 | return null; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /design-patterns/Creational Pattern/AbstractFactory/java/AbstractFactoryDemo/src/Factory/ShapeFactory.java: -------------------------------------------------------------------------------- 1 | package Factory; 2 | 3 | import Shapes.IShape; 4 | import Shapes.Rectangle; 5 | import Shapes.Square; 6 | 7 | public class ShapeFactory extends AbstractFactory{ 8 | 9 | @Override 10 | public IShape getShape(String shapeType) { 11 | if(shapeType.equalsIgnoreCase("RECTANGLE")){ 12 | return new Rectangle(); 13 | }else if(shapeType.equalsIgnoreCase("SQUARE")){ 14 | return new Square(); 15 | } 16 | return null; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /design-patterns/Creational Pattern/AbstractFactory/java/AbstractFactoryDemo/src/Shapes/IShape.java: -------------------------------------------------------------------------------- 1 | package Shapes; 2 | 3 | public interface IShape { 4 | 5 | void draw(); 6 | } 7 | -------------------------------------------------------------------------------- /design-patterns/Creational Pattern/AbstractFactory/java/AbstractFactoryDemo/src/Shapes/Rectangle.java: -------------------------------------------------------------------------------- 1 | package Shapes; 2 | 3 | import java.awt.*; 4 | 5 | public class Rectangle implements IShape { 6 | @Override 7 | public void draw() { 8 | System.out.println("Inside Rectangle::draw() method."); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /design-patterns/Creational Pattern/AbstractFactory/java/AbstractFactoryDemo/src/Shapes/RoundedRectangle.java: -------------------------------------------------------------------------------- 1 | package Shapes; 2 | 3 | import java.awt.*; 4 | 5 | public class RoundedRectangle implements IShape { 6 | 7 | @Override 8 | public void draw() { 9 | System.out.println("Inside RoundedRectangle::draw() method."); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /design-patterns/Creational Pattern/AbstractFactory/java/AbstractFactoryDemo/src/Shapes/RoundedSquare.java: -------------------------------------------------------------------------------- 1 | package Shapes; 2 | 3 | public class RoundedSquare implements IShape{ 4 | 5 | @Override 6 | public void draw() { 7 | System.out.println("Inside RoundedSquare::draw() method."); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /design-patterns/Creational Pattern/AbstractFactory/java/AbstractFactoryDemo/src/Shapes/Square.java: -------------------------------------------------------------------------------- 1 | package Shapes; 2 | 3 | public class Square implements IShape { 4 | @Override 5 | public void draw() { 6 | System.out.println("Inside Square::draw() method."); 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /design-patterns/Creational Pattern/AbstractFactory/java/PizzaCompany/src/Domain/CheesePizza.java: -------------------------------------------------------------------------------- 1 | package Domain; 2 | 3 | public class CheesePizza extends Pizza { 4 | 5 | 6 | @Override 7 | public void prepare() { 8 | System.out.println("Adding Extra Cheese"); 9 | } 10 | 11 | @Override 12 | public void bake() { 13 | System.out.println("Bake Low Temperature for 30 min"); 14 | 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /design-patterns/Creational Pattern/AbstractFactory/java/PizzaCompany/src/Domain/ChickenPizza.java: -------------------------------------------------------------------------------- 1 | package Domain; 2 | 3 | public class ChickenPizza extends Pizza{ 4 | @Override 5 | public void prepare() { 6 | System.out.println("Adding Extra Chicken"); 7 | } 8 | 9 | @Override 10 | public void bake() { 11 | System.out.println("High Temperature for 1 hour"); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /design-patterns/Creational Pattern/AbstractFactory/java/PizzaCompany/src/Domain/LebanonCheesePizza.java: -------------------------------------------------------------------------------- 1 | package Domain; 2 | 3 | public class LebanonCheesePizza extends CheesePizza{ 4 | 5 | @Override 6 | public void prepare() { 7 | super.prepare(); 8 | System.out.println("Extra Fries Box"); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /design-patterns/Creational Pattern/AbstractFactory/java/PizzaCompany/src/Domain/LebanonChickenPizza.java: -------------------------------------------------------------------------------- 1 | package Domain; 2 | 3 | public class LebanonChickenPizza extends ChickenPizza{ 4 | 5 | @Override 6 | public void prepare() { 7 | super.prepare(); 8 | System.out.println("Extra Sauce"); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /design-patterns/Creational Pattern/AbstractFactory/java/PizzaCompany/src/Domain/Pizza.java: -------------------------------------------------------------------------------- 1 | package Domain; 2 | 3 | import java.util.ArrayList; 4 | 5 | public abstract class Pizza { 6 | private String name; 7 | private String dough; 8 | private String sauce; 9 | 10 | 11 | 12 | public abstract void prepare(); 13 | 14 | public abstract void bake(); 15 | 16 | public void box(){ 17 | System.out.println("Put In A Box! And Ready To Go"); 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /design-patterns/Creational Pattern/AbstractFactory/java/PizzaCompany/src/Domain/USCheesePizza.java: -------------------------------------------------------------------------------- 1 | package Domain; 2 | 3 | public class USCheesePizza extends CheesePizza{ 4 | 5 | @Override 6 | public void prepare() { 7 | super.prepare(); 8 | System.out.println("Extra Crust Added"); 9 | } 10 | 11 | 12 | } 13 | -------------------------------------------------------------------------------- /design-patterns/Creational Pattern/AbstractFactory/java/PizzaCompany/src/Domain/USChickenPizza.java: -------------------------------------------------------------------------------- 1 | package Domain; 2 | 3 | public class USChickenPizza extends ChickenPizza{ 4 | 5 | @Override 6 | public void prepare() { 7 | super.prepare(); 8 | System.out.println("Extra Crust Added"); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /design-patterns/Creational Pattern/AbstractFactory/java/PizzaCompany/src/Factory/SimplePizzaFactory.java: -------------------------------------------------------------------------------- 1 | package Factory; 2 | 3 | import Domain.CheesePizza; 4 | import Domain.ChickenPizza; 5 | import Domain.Pizza; 6 | 7 | public class SimplePizzaFactory { 8 | 9 | public Pizza createPizza(String type){ 10 | Pizza pizza = null; 11 | 12 | if(type.equals("Cheese")) 13 | pizza = new CheesePizza(); 14 | else if (type.equals("Chicken")) 15 | pizza = new ChickenPizza(); 16 | 17 | return pizza; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /design-patterns/Creational Pattern/AbstractFactory/java/PizzaCompany/src/Store/LebanonPizzaStore.java: -------------------------------------------------------------------------------- 1 | package Store; 2 | 3 | import Domain.LebanonCheesePizza; 4 | import Domain.LebanonChickenPizza; 5 | import Domain.Pizza; 6 | 7 | public class LebanonPizzaStore extends PizzaStore{ 8 | @Override 9 | Pizza createPizza(String type) { 10 | 11 | if(type.equals("Cheese")) 12 | return new LebanonCheesePizza(); 13 | else if(type.equals("Chicken")) 14 | return new LebanonChickenPizza(); 15 | return null; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /design-patterns/Creational Pattern/AbstractFactory/java/PizzaCompany/src/Store/PizzaStore.java: -------------------------------------------------------------------------------- 1 | package Store; 2 | 3 | import Domain.Pizza; 4 | import Factory.SimplePizzaFactory; 5 | 6 | public abstract class PizzaStore { 7 | 8 | 9 | public Pizza orderPizza(String type){ 10 | Pizza pizza = null; 11 | 12 | pizza = createPizza(type); 13 | 14 | pizza.prepare(); 15 | pizza.bake(); 16 | pizza.box(); 17 | return pizza; 18 | } 19 | 20 | abstract Pizza createPizza(String type); 21 | } 22 | -------------------------------------------------------------------------------- /design-patterns/Creational Pattern/AbstractFactory/java/PizzaCompany/src/Store/USPizzaStore.java: -------------------------------------------------------------------------------- 1 | package Store; 2 | 3 | import Domain.*; 4 | 5 | public class USPizzaStore extends PizzaStore{ 6 | 7 | @Override 8 | Pizza createPizza(String type) { 9 | 10 | if(type.equals("Cheese")) 11 | return new USCheesePizza(); 12 | else if(type.equals("Chicken")) 13 | return new USChickenPizza(); 14 | return null; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /design-patterns/Creational Pattern/AbstractFactory/java/PizzaCompany/src/main.java: -------------------------------------------------------------------------------- 1 | import Store.LebanonPizzaStore; 2 | import Store.PizzaStore; 3 | import Store.USPizzaStore; 4 | 5 | public class main { 6 | 7 | public static void main(String[] args) { 8 | 9 | System.out.println("Factory Method"); 10 | System.out.println("*****************"); 11 | 12 | PizzaStore pizzaStoreLeb = new LebanonPizzaStore(); 13 | pizzaStoreLeb.orderPizza("Cheese"); 14 | 15 | System.out.println("--------------------"); 16 | 17 | 18 | PizzaStore pizzaStoreUs = new USPizzaStore(); 19 | pizzaStoreUs.orderPizza("Cheese"); 20 | System.out.println("*****************"); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /design-patterns/Creational Pattern/AbstractFactory/java/UFODemo/src/EnemyShipTesting.java: -------------------------------------------------------------------------------- 1 | import Entity.EnemyShip; 2 | 3 | /*** 4 | * Author: Derek Banas 5 | * Link: https://www.newthinktank.com/2012/09/abstract-factory-design-pattern/ 6 | * Note: The code base is exactly the same. 7 | */ 8 | 9 | public class EnemyShipTesting { 10 | 11 | public static void main(String[] args) { 12 | 13 | // EnemyShipBuilding handles orders for new EnemyShips 14 | // You send it a code using the orderTheShip method & 15 | // it sends the order to the right factory for creation 16 | 17 | EnemyShipBuilding MakeUFOs = new UFOEnemyShipBuilding(); 18 | MakeUFOs.makeEnemyShip("UFO"); 19 | 20 | EnemyShip theGrunt = MakeUFOs.orderTheShip("UFO"); 21 | System.out.println(theGrunt + "\n"); 22 | 23 | EnemyShip theBoss = MakeUFOs.orderTheShip("UFO BOSS"); 24 | System.out.println(theBoss + "\n"); 25 | 26 | } 27 | 28 | } -------------------------------------------------------------------------------- /design-patterns/Creational Pattern/AbstractFactory/java/UFODemo/src/Engine/ESEngine.java: -------------------------------------------------------------------------------- 1 | package Engine;// Any part that implements the interface Engine.ESEngine 2 | // can replace that part in any ship 3 | 4 | public interface ESEngine{ 5 | 6 | // User is forced to implement this method 7 | // It outputs the string returned when the 8 | // object is printed 9 | 10 | public String toString(); 11 | 12 | } -------------------------------------------------------------------------------- /design-patterns/Creational Pattern/AbstractFactory/java/UFODemo/src/Engine/ESUFOBossEngine.java: -------------------------------------------------------------------------------- 1 | package Engine;// Here we define a basic component of a space ship 2 | // Any part that implements the interface Engine.ESEngine 3 | // can replace that part in any ship 4 | 5 | public class ESUFOBossEngine implements ESEngine{ 6 | 7 | // Entity.EnemyShip contains a reference to the object 8 | // Weapon.ESWeapon. It is stored in the field weapon 9 | 10 | // The Strategy design pattern is being used here 11 | 12 | // When the field that is of type Weapon.ESUFOGun is printed 13 | // the following shows on the screen 14 | 15 | public String toString(){ 16 | return "2000 mph"; 17 | } 18 | 19 | } -------------------------------------------------------------------------------- /design-patterns/Creational Pattern/AbstractFactory/java/UFODemo/src/Engine/ESUFOEngine.java: -------------------------------------------------------------------------------- 1 | package Engine;// Here we define a basic component of a space ship 2 | // Any part that implements the interface Engine.ESEngine 3 | // can replace that part in any ship 4 | 5 | public class ESUFOEngine implements ESEngine{ 6 | 7 | // Entity.EnemyShip contains a reference to the object 8 | // Weapon.ESWeapon. It is stored in the field weapon 9 | 10 | // The Strategy design pattern is being used here 11 | 12 | // When the field that is of type Weapon.ESUFOGun is printed 13 | // the following shows on the screen 14 | 15 | public String toString(){ 16 | return "1000 mph"; 17 | } 18 | 19 | } -------------------------------------------------------------------------------- /design-patterns/Creational Pattern/AbstractFactory/java/UFODemo/src/Entity/EnemyShipFactory.java: -------------------------------------------------------------------------------- 1 | package Entity;// With an Abstract Factory Pattern you won't 2 | // just build ships, but also all of the components 3 | // for the ships 4 | 5 | // Here is where you define the parts that are required 6 | // if an object wants to be an enemy ship 7 | 8 | import Engine.ESEngine; 9 | import Weapon.ESWeapon; 10 | 11 | public interface EnemyShipFactory{ 12 | 13 | public ESWeapon addESGun(); 14 | public ESEngine addESEngine(); 15 | 16 | } -------------------------------------------------------------------------------- /design-patterns/Creational Pattern/AbstractFactory/java/UFODemo/src/Weapon/ESUFOBossGun.java: -------------------------------------------------------------------------------- 1 | package Weapon;// Here we define a basic component of a space ship 2 | // Any part that implements the interface Weapon.ESWeapon 3 | // can replace that part in any ship 4 | 5 | public class ESUFOBossGun implements ESWeapon{ 6 | 7 | // Entity.EnemyShip contains a reference to the object 8 | // Weapon.ESWeapon. It is stored in the field weapon 9 | 10 | // The Strategy design pattern is being used here 11 | 12 | // When the field that is of type Weapon.ESUFOGun is printed 13 | // the following shows on the screen 14 | 15 | public String toString(){ 16 | return "40 damage"; 17 | } 18 | 19 | } -------------------------------------------------------------------------------- /design-patterns/Creational Pattern/AbstractFactory/java/UFODemo/src/Weapon/ESUFOGun.java: -------------------------------------------------------------------------------- 1 | package Weapon;// Here we define a basic component of a space ship 2 | // Any part that implements the interface Weapon.ESWeapon 3 | // can replace that part in any ship 4 | 5 | public class ESUFOGun implements ESWeapon{ 6 | 7 | // Entity.EnemyShip contains a reference to the object 8 | // Weapon.ESWeapon. It is stored in the field weapon 9 | 10 | // The Strategy design pattern is being used here 11 | 12 | // When the field that is of type Weapon.ESUFOGun is printed 13 | // the following shows on the screen 14 | 15 | public String toString(){ 16 | return "20 damage"; 17 | } 18 | 19 | } -------------------------------------------------------------------------------- /design-patterns/Creational Pattern/AbstractFactory/java/UFODemo/src/Weapon/ESWeapon.java: -------------------------------------------------------------------------------- 1 | package Weapon;// Any part that implements the interface Weapon.ESWeapon 2 | // can replace that part in any ship 3 | 4 | public interface ESWeapon{ 5 | 6 | // User is forced to implement this method 7 | // It outputs the string returned when the 8 | // object is printed 9 | 10 | public String toString(); 11 | 12 | } 13 | -------------------------------------------------------------------------------- /design-patterns/Creational Pattern/Factory/java/main/main.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /design-patterns/Creational Pattern/Factory/java/main/src/BigUFOEnemyShip.java: -------------------------------------------------------------------------------- 1 | public class BigUFOEnemyShip extends UFOEnemyShip{ 2 | 3 | public BigUFOEnemyShip() { 4 | setName("Big UFO Enemy Ship"); 5 | setDamage(50); 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /design-patterns/Creational Pattern/Factory/java/main/src/EnemyShip.java: -------------------------------------------------------------------------------- 1 | public abstract class EnemyShip { 2 | private String name; 3 | private double damage; 4 | 5 | public String getName() { 6 | return name; 7 | } 8 | 9 | public void setName(String name) { 10 | this.name = name; 11 | } 12 | 13 | public double getDamage() { 14 | return damage; 15 | } 16 | 17 | public void setDamage(double damage) { 18 | this.damage = damage; 19 | } 20 | 21 | public void followHeroShip(){ 22 | System.out.println(getName()+ " is following the hero"); 23 | } 24 | 25 | public void displayEnemyShip(){ 26 | System.out.println(getName()+ " is on the screen"); 27 | } 28 | 29 | public void enemyShipShoots(){ 30 | System.out.println(getName()+ " attacks and does " + getDamage() ); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /design-patterns/Creational Pattern/Factory/java/main/src/EnemyShipFactory.java: -------------------------------------------------------------------------------- 1 | public class EnemyShipFactory { 2 | 3 | public EnemyShip makeEnemyShip(String type) { 4 | if (type.equals("U")) 5 | return new UFOEnemyShip(); 6 | else if (type.equals("R")) 7 | return new RocketEnemyShip(); 8 | else if (type.equals("B")) 9 | return new BigUFOEnemyShip(); 10 | else return null; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /design-patterns/Creational Pattern/Factory/java/main/src/RocketEnemyShip.java: -------------------------------------------------------------------------------- 1 | public class RocketEnemyShip extends EnemyShip{ 2 | 3 | public RocketEnemyShip(){ 4 | setName("Rocket Enemy Ship"); 5 | setDamage(10); 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /design-patterns/Creational Pattern/Factory/java/main/src/UFOEnemyShip.java: -------------------------------------------------------------------------------- 1 | public class UFOEnemyShip extends EnemyShip{ 2 | 3 | public UFOEnemyShip() { 4 | setName("UFO Enemy Ship"); 5 | setDamage(20); 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /design-patterns/Creational Pattern/Factory/java/main/src/main.java: -------------------------------------------------------------------------------- 1 | import java.util.Scanner; 2 | 3 | public class main { 4 | public static void main(String[] args) { 5 | 6 | String shipType = "U"; 7 | EnemyShipFactory shipFactory = new EnemyShipFactory(); 8 | EnemyShip enemyShip = shipFactory.makeEnemyShip(shipType); 9 | 10 | if (enemyShip != null) 11 | doStuff(enemyShip); 12 | } 13 | 14 | private static void doStuff(EnemyShip enemyShip) { 15 | enemyShip.displayEnemyShip(); 16 | enemyShip.followHeroShip(); 17 | enemyShip.enemyShipShoots(); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /design-patterns/Creational Pattern/Singleton/README.md: -------------------------------------------------------------------------------- 1 | # Singleton 2 | 3 | > **Singleton** is a creational design pattern that lets you ensure that a class has only one instance, while providing a global access point to this instance. 4 | 5 | 6 | 7 | ## How to implement 8 | 9 | - Make the default constructor private, to prevent other objects from using the `new` operator with the Singleton class. 10 | - Create a static creation method that acts as a constructor. Under the hood, this method calls the private constructor to create an object and saves it in a static field. All following calls to this method return the cached object. 11 | 12 | 13 | 14 | ## Pros and Cons 15 | 16 | :heavy_check_mark: You can be sure that this class has only one instance 17 | 18 | :heavy_check_mark: You gain global access to this instance 19 | 20 | :x: Special treatment in a Multi-Thread environment 21 | 22 | :x: May be difficult to unit test the client. 23 | 24 | -------------------------------------------------------------------------------- /design-patterns/Creational Pattern/Singleton/java/PatternDemo/src/SingletonObject.java: -------------------------------------------------------------------------------- 1 | public class SingletonObject { 2 | 3 | 4 | private static SingletonObject instance = new SingletonObject(); 5 | 6 | // make constructor private 7 | private SingletonObject(){ 8 | 9 | } 10 | 11 | public static SingletonObject getInstance(){ 12 | return instance; 13 | } 14 | 15 | public void showMessage(){ 16 | System.out.println("Message From A Singleton Object"); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /design-patterns/Creational Pattern/Singleton/java/PatternDemo/src/main.java: -------------------------------------------------------------------------------- 1 | public class main { 2 | public static void main(String[] args) { 3 | 4 | SingletonObject singletonObject = SingletonObject.getInstance(); 5 | 6 | singletonObject.showMessage(); 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /design-patterns/Creational Pattern/Singleton/java/PatternDemo2/src/Singleton.java: -------------------------------------------------------------------------------- 1 | public class Singleton { 2 | 3 | private static Singleton singleton = null; 4 | private Singleton(){ 5 | 6 | } 7 | 8 | public static Singleton getInstance(){ 9 | 10 | synchronized(Singleton.class){ 11 | if(singleton == null) { 12 | singleton = new Singleton(); 13 | } 14 | } 15 | 16 | return singleton; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /design-patterns/Creational Pattern/images/img1.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RolandSall/Software-Concepts/c2623eac706a8bf998c246c1c4e5d4d3cfc9ed18/design-patterns/Creational Pattern/images/img1.PNG -------------------------------------------------------------------------------- /design-patterns/Creational Pattern/images/img2.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RolandSall/Software-Concepts/c2623eac706a8bf998c246c1c4e5d4d3cfc9ed18/design-patterns/Creational Pattern/images/img2.PNG -------------------------------------------------------------------------------- /design-patterns/Creational Pattern/images/img3.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RolandSall/Software-Concepts/c2623eac706a8bf998c246c1c4e5d4d3cfc9ed18/design-patterns/Creational Pattern/images/img3.PNG -------------------------------------------------------------------------------- /design-patterns/Structual Pattern/Decorator/README.md: -------------------------------------------------------------------------------- 1 | # Decorator 2 | 3 | > **Decorator** is a structural design pattern that lets you attach new behaviors to objects by placing these objects inside special wrapper objects that contain the behaviors. 4 | 5 | 6 | 7 | A decorator pattern could be a solution of a class explosion. If you feel that at one time you are creating multiple subclasses with slight variation inheriting from the class. a decorator pattern could be a solution. 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /design-patterns/Structual Pattern/Decorator/java/BeveragesExample/BeveragesExample.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /design-patterns/Structual Pattern/Decorator/java/BeveragesExample/src/AddOnDecorator.java: -------------------------------------------------------------------------------- 1 | public abstract class AddOnDecorator extends Beverages{ 2 | 3 | 4 | @Override 5 | public abstract String getDescription(); 6 | } 7 | -------------------------------------------------------------------------------- /design-patterns/Structual Pattern/Decorator/java/BeveragesExample/src/Beverages.java: -------------------------------------------------------------------------------- 1 | public abstract class Beverages { 2 | 3 | String description; 4 | 5 | public String getDescription() { 6 | return description; 7 | } 8 | 9 | public abstract double cost(); 10 | } 11 | -------------------------------------------------------------------------------- /design-patterns/Structual Pattern/Decorator/java/BeveragesExample/src/Espresso.java: -------------------------------------------------------------------------------- 1 | public class Espresso extends Beverages{ 2 | 3 | public Espresso(){ 4 | description = "Espresso"; 5 | } 6 | 7 | @Override 8 | public double cost() { 9 | return 1.99; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /design-patterns/Structual Pattern/Decorator/java/BeveragesExample/src/HouseBlend.java: -------------------------------------------------------------------------------- 1 | public class HouseBlend extends Beverages{ 2 | 3 | public HouseBlend() { 4 | description = "House Blend Coffee"; 5 | } 6 | 7 | @Override 8 | public double cost() { 9 | return 0.89; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /design-patterns/Structual Pattern/Decorator/java/BeveragesExample/src/Mocha.java: -------------------------------------------------------------------------------- 1 | public class Mocha extends AddOnDecorator{ 2 | Beverages beverages; 3 | 4 | public Mocha(Beverages beverages) { 5 | this.beverages = beverages; 6 | } 7 | 8 | @Override 9 | public String getDescription() { 10 | return beverages.getDescription() + ", Mocha"; 11 | } 12 | 13 | @Override 14 | public double cost() { 15 | return beverages.cost() + 0.20; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /design-patterns/Structual Pattern/Decorator/java/BeveragesExample/src/Whip.java: -------------------------------------------------------------------------------- 1 | public class Whip extends AddOnDecorator{ 2 | Beverages beverages; 3 | 4 | public Whip(Beverages beverages) { 5 | this.beverages = beverages; 6 | } 7 | 8 | @Override 9 | public String getDescription() { 10 | return beverages.getDescription() + ", Whip"; 11 | } 12 | 13 | @Override 14 | public double cost() { 15 | return beverages.cost() + 0.10; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /design-patterns/Structual Pattern/Decorator/java/BeveragesExample/src/main.java: -------------------------------------------------------------------------------- 1 | public class main { 2 | public static void main(String[] args) { 3 | 4 | Beverages beverages = new Espresso(); 5 | System.out.println(beverages.description + " " + beverages.cost()); 6 | 7 | 8 | Beverages beverages1 = new Whip(new Mocha(new Espresso())); 9 | String desc = beverages1.getDescription(); 10 | double cost = beverages1.cost(); 11 | System.out.println(desc + " " + cost); 12 | 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /design-patterns/Structual Pattern/Facade/java/BankExample/src/Bank/AccountNumberCheck.java: -------------------------------------------------------------------------------- 1 | package Bank; 2 | 3 | 4 | public class AccountNumberCheck { 5 | 6 | 7 | // certain validation 8 | public boolean isValid(String accountNumber){ 9 | return accountNumber.contains("FDA"); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /design-patterns/Structual Pattern/Facade/java/BankExample/src/Bank/BankAccountNotFound.java: -------------------------------------------------------------------------------- 1 | package Bank; 2 | 3 | public class BankAccountNotFound extends Exception{ 4 | 5 | public BankAccountNotFound(String message) { 6 | super(message); 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /design-patterns/Structual Pattern/Facade/java/BankExample/src/Bank/FundCheck.java: -------------------------------------------------------------------------------- 1 | package Bank; 2 | 3 | public class FundCheck { 4 | 5 | // initial dummy amount 6 | private double cashInAccount = 1000; 7 | 8 | public double getCashInAccount() { 9 | return cashInAccount; 10 | } 11 | 12 | public void cashWithdraw(double cash){ 13 | if (cash > getCashInAccount()){ 14 | System.out.println("Not Enough Money, You Current Balance is: " + getCashInAccount()); 15 | return; 16 | } 17 | cashInAccount -= cash; 18 | System.out.println("Withdraw Complete, Your current Balance: " + getCashInAccount()); 19 | } 20 | 21 | public void depositCash(double cash){ 22 | cashInAccount += cash; 23 | System.out.println("Withdraw Complete, Your current Balance: " + getCashInAccount()); 24 | } 25 | 26 | 27 | } 28 | -------------------------------------------------------------------------------- /design-patterns/Structual Pattern/Facade/java/BankExample/src/Bank/SecurityCodeCheck.java: -------------------------------------------------------------------------------- 1 | package Bank; 2 | 3 | public class SecurityCodeCheck { 4 | 5 | // certain validation 6 | public boolean isValid(int accountNumber){ 7 | return accountNumber == 454; 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /design-patterns/Structual Pattern/Facade/java/BankExample/src/main.java: -------------------------------------------------------------------------------- 1 | import Bank.BankAccountFacade; 2 | import Bank.BankAccountNotFound; 3 | 4 | public class main { 5 | public static void main(String[] args) { 6 | 7 | BankAccountFacade bankAccess = new BankAccountFacade("11242FDA",454); 8 | 9 | try { 10 | bankAccess.withDrawCash(50.00); 11 | bankAccess.withDrawCash(300); 12 | bankAccess.depositCash(55); 13 | bankAccess.withDrawCash(950); 14 | } catch (BankAccountNotFound e) { 15 | throw new RuntimeException(e.getMessage()); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /design-patterns/Structual Pattern/Facade/java/EmployeeExample/src/Employee/Developer.java: -------------------------------------------------------------------------------- 1 | package Employee; 2 | 3 | import Employee.Facade.DeveloperFacade; 4 | import Employee.Facade.Facade; 5 | 6 | public class Developer extends Employee { 7 | 8 | 9 | private DeveloperFacade facade; 10 | public Developer(String firstName, String lastName, int workingHours) { 11 | 12 | super(firstName, lastName, workingHours); 13 | facade = new DeveloperFacade(this); 14 | } 15 | 16 | @Override 17 | public DeveloperFacade getFacade() { 18 | return facade; 19 | } 20 | } -------------------------------------------------------------------------------- /design-patterns/Structual Pattern/Facade/java/EmployeeExample/src/Employee/Facade/EmployeeFacade.java: -------------------------------------------------------------------------------- 1 | package Employee.Facade; 2 | 3 | import Employee.Employee; 4 | import Employee.HourReporter; 5 | import Employee.PayCalculator.EmployeePayCalculator; 6 | import Employee.PayCalculator.IPayCalculator; 7 | 8 | public class EmployeeFacade extends Facade { 9 | 10 | private final IPayCalculator payCalculator; 11 | 12 | private final HourReporter hourReporter; 13 | 14 | private Employee employee; 15 | 16 | public EmployeeFacade(Employee employee) { 17 | this.employee = employee; 18 | payCalculator = new EmployeePayCalculator(); 19 | hourReporter = new HourReporter(); 20 | } 21 | 22 | 23 | public int getSalary(int workingHours) { 24 | return payCalculator.getSalary(employee.getWorkingHours()); 25 | } 26 | public void printReport(int workingHours){ 27 | hourReporter.printReport(employee.getWorkingHours()); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /design-patterns/Structual Pattern/Facade/java/EmployeeExample/src/Employee/Facade/Facade.java: -------------------------------------------------------------------------------- 1 | package Employee.Facade; 2 | 3 | import Employee.HourReporter; 4 | import Employee.PayCalculator.IPayCalculator; 5 | 6 | public abstract class Facade { 7 | 8 | public abstract int getSalary(int workingHours); 9 | public abstract void printReport(int workingHours); 10 | } 11 | -------------------------------------------------------------------------------- /design-patterns/Structual Pattern/Facade/java/EmployeeExample/src/Employee/HourReporter.java: -------------------------------------------------------------------------------- 1 | package Employee; 2 | 3 | public class HourReporter { 4 | public void printReport(int workingHours){ 5 | System.out.println("Worked: " + workingHours); 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /design-patterns/Structual Pattern/Facade/java/EmployeeExample/src/Employee/PayCalculator/EmployeePayCalculator.java: -------------------------------------------------------------------------------- 1 | package Employee.PayCalculator; 2 | 3 | public class EmployeePayCalculator implements IPayCalculator { 4 | @Override 5 | public int getSalary(int workingHours) { 6 | return workingHours * 20; 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /design-patterns/Structual Pattern/Facade/java/EmployeeExample/src/Employee/PayCalculator/IPayCalculator.java: -------------------------------------------------------------------------------- 1 | package Employee.PayCalculator; 2 | 3 | public interface IPayCalculator { 4 | 5 | 6 | public int getSalary(int workingHours); 7 | } 8 | -------------------------------------------------------------------------------- /design-patterns/Structual Pattern/Facade/java/EmployeeExample/src/Employee/PayCalculator/PayDeveloperCalculator.java: -------------------------------------------------------------------------------- 1 | package Employee.PayCalculator; 2 | 3 | public class PayDeveloperCalculator implements IPayCalculator { 4 | 5 | @Override 6 | public int getSalary(int workingHours) { 7 | return workingHours * 40; 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /design-patterns/Structual Pattern/Facade/java/EmployeeExample/src/Employee/PayCalculator/PayTesterCalculator.java: -------------------------------------------------------------------------------- 1 | package Employee.PayCalculator; 2 | 3 | public class PayTesterCalculator implements IPayCalculator{ 4 | 5 | @Override 6 | public int getSalary(int workingHours) { 7 | return workingHours * 35; 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /design-patterns/Structual Pattern/Facade/java/EmployeeExample/src/Employee/Tester.java: -------------------------------------------------------------------------------- 1 | package Employee; 2 | 3 | import Employee.Facade.DeveloperFacade; 4 | import Employee.Facade.Facade; 5 | import Employee.Facade.TesterFacade; 6 | 7 | public class Tester extends Employee{ 8 | 9 | private TesterFacade facade; 10 | public Tester(String firstName, String lastName, int workingHours) { 11 | super(firstName, lastName, workingHours); 12 | facade = new TesterFacade(this); 13 | } 14 | 15 | @Override 16 | public TesterFacade getFacade() { 17 | return facade; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /design-patterns/Structual Pattern/Facade/java/EmployeeExample/src/main.java: -------------------------------------------------------------------------------- 1 | import Employee.Developer; 2 | import Employee.Employee; 3 | import Employee.Tester; 4 | 5 | import java.util.List; 6 | 7 | public class main { 8 | public static void main(String[] args) { 9 | 10 | Employee developer = new Developer("Robin", "Karaa", 35); 11 | Employee tester = new Tester("James", "Tomy", 23); 12 | Employee employee = new Tester("Harry", "Poter", 40); 13 | 14 | List employeeList = List.of(developer,tester,employee); 15 | 16 | for (Employee emp: employeeList) { 17 | System.out.println("Salary: " + emp.getFacade().getSalary(employee.getWorkingHours())); 18 | emp.getFacade().printReport(employee.getWorkingHours()); 19 | } 20 | 21 | 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /event-driven-microservices/java/images/CQRS-with-event-sourcing.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RolandSall/Software-Concepts/c2623eac706a8bf998c246c1c4e5d4d3cfc9ed18/event-driven-microservices/java/images/CQRS-with-event-sourcing.png -------------------------------------------------------------------------------- /event-driven-microservices/java/images/asynchronous-communication.drawio.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RolandSall/Software-Concepts/c2623eac706a8bf998c246c1c4e5d4d3cfc9ed18/event-driven-microservices/java/images/asynchronous-communication.drawio.png -------------------------------------------------------------------------------- /event-driven-microservices/java/images/event-sourcing(1).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RolandSall/Software-Concepts/c2623eac706a8bf998c246c1c4e5d4d3cfc9ed18/event-driven-microservices/java/images/event-sourcing(1).png -------------------------------------------------------------------------------- /event-driven-microservices/java/images/microservie-architecture.drawio.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RolandSall/Software-Concepts/c2623eac706a8bf998c246c1c4e5d4d3cfc9ed18/event-driven-microservices/java/images/microservie-architecture.drawio.png -------------------------------------------------------------------------------- /event-driven-microservices/java/images/synchronous-communication.drawio.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RolandSall/Software-Concepts/c2623eac706a8bf998c246c1c4e5d4d3cfc9ed18/event-driven-microservices/java/images/synchronous-communication.drawio.png -------------------------------------------------------------------------------- /event-driven-microservices/java/templates/cqrs-eventsourcing-axon/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/**/target/ 5 | !**/src/test/**/target/ 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | *.iws 19 | *.iml 20 | *.ipr 21 | 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /nbbuild/ 25 | /dist/ 26 | /nbdist/ 27 | /.nb-gradle/ 28 | build/ 29 | !**/src/main/**/build/ 30 | !**/src/test/**/build/ 31 | 32 | ### VS Code ### 33 | .vscode/ 34 | -------------------------------------------------------------------------------- /event-driven-microservices/java/templates/cqrs-eventsourcing-axon/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RolandSall/Software-Concepts/c2623eac706a8bf998c246c1c4e5d4d3cfc9ed18/event-driven-microservices/java/templates/cqrs-eventsourcing-axon/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /event-driven-microservices/java/templates/cqrs-eventsourcing-axon/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.5/apache-maven-3.8.5-bin.zip 2 | wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar 3 | -------------------------------------------------------------------------------- /event-driven-microservices/java/templates/cqrs-eventsourcing-axon/README.md: -------------------------------------------------------------------------------- 1 | # Implementing CQRS & Event Sourcing With AXON 2 | 3 | 4 | 5 | > [Axon Framework](http://www.axonframework.org/) is a Java framework that provides implementations of the most important building blocks, e.g. aggregates, command and event buses, as well as repositories to help developers apply the CQRS architectural pattern when building applications. 6 | 7 | Extra Resources: [CQRS-ES-AXON-SPRING-BOOT](https://raghuramg.medium.com/implementing-event-sourcing-cqrs-using-axon-and-spring-boot-6eaa9ddde89f) 8 | 9 | ![axon](./images/axon.PNG) -------------------------------------------------------------------------------- /event-driven-microservices/java/templates/cqrs-eventsourcing-axon/docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: '3.6' 2 | services: 3 | db: 4 | container_name: postgress-container 5 | image: postgres 6 | restart: always 7 | environment: 8 | POSTGRES_USER: user 9 | POSTGRES_PASSWORD: pass123 10 | POSTGRES_DB: demp 11 | volumes: 12 | - pgdata:/var/lib/postgresql/data 13 | ports: 14 | - "5432:5432" 15 | 16 | volumes: 17 | pgdata: -------------------------------------------------------------------------------- /event-driven-microservices/java/templates/cqrs-eventsourcing-axon/images/axon.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RolandSall/Software-Concepts/c2623eac706a8bf998c246c1c4e5d4d3cfc9ed18/event-driven-microservices/java/templates/cqrs-eventsourcing-axon/images/axon.PNG -------------------------------------------------------------------------------- /event-driven-microservices/java/templates/cqrs-eventsourcing-axon/src/main/java/com/rolandsall24/cqrseventsourcingaxon/CqrsEventsourcingAxonApplication.java: -------------------------------------------------------------------------------- 1 | package com.rolandsall24.cqrseventsourcingaxon; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class CqrsEventsourcingAxonApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(CqrsEventsourcingAxonApplication.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /event-driven-microservices/java/templates/cqrs-eventsourcing-axon/src/main/java/com/rolandsall24/cqrseventsourcingaxon/SwaggerConfig.java: -------------------------------------------------------------------------------- 1 | package com.rolandsall24.cqrseventsourcingaxon; 2 | 3 | import org.springframework.context.annotation.Bean; 4 | import org.springframework.context.annotation.Configuration; 5 | import springfox.documentation.builders.PathSelectors; 6 | import springfox.documentation.builders.RequestHandlerSelectors; 7 | import springfox.documentation.spi.DocumentationType; 8 | import springfox.documentation.spring.web.plugins.Docket; 9 | import springfox.documentation.swagger2.annotations.EnableSwagger2; 10 | 11 | @Configuration 12 | @EnableSwagger2 13 | public class SwaggerConfig { 14 | 15 | @Bean 16 | public Docket api() { 17 | return new Docket(DocumentationType.SWAGGER_2) 18 | .select() 19 | .apis(RequestHandlerSelectors.any()) 20 | .paths(PathSelectors.any()) 21 | .build(); 22 | } 23 | } -------------------------------------------------------------------------------- /event-driven-microservices/java/templates/cqrs-eventsourcing-axon/src/main/java/com/rolandsall24/cqrseventsourcingaxon/commands/product/commands/CreateProductCommand.java: -------------------------------------------------------------------------------- 1 | package com.rolandsall24.cqrseventsourcingaxon.commands.product.commands; 2 | import lombok.Getter; 3 | import org.axonframework.modelling.command.TargetAggregateIdentifier; 4 | 5 | import java.util.UUID; 6 | 7 | 8 | @Getter 9 | public class CreateProductCommand extends ProductBaseCommand { 10 | 11 | private String name; 12 | private long serialNumber; 13 | 14 | public CreateProductCommand(UUID id, String name, long serialNumber) { 15 | super(id); 16 | this.name = name; 17 | this.serialNumber = serialNumber; 18 | } 19 | } 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /event-driven-microservices/java/templates/cqrs-eventsourcing-axon/src/main/java/com/rolandsall24/cqrseventsourcingaxon/commands/product/commands/ProductBaseCommand.java: -------------------------------------------------------------------------------- 1 | package com.rolandsall24.cqrseventsourcingaxon.commands.product.commands; 2 | 3 | import lombok.Getter; 4 | import org.axonframework.modelling.command.TargetAggregateIdentifier; 5 | 6 | public abstract class ProductBaseCommand { 7 | 8 | @Getter 9 | @TargetAggregateIdentifier 10 | private final T id; 11 | 12 | public ProductBaseCommand(T id) { 13 | this.id = id; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /event-driven-microservices/java/templates/cqrs-eventsourcing-axon/src/main/java/com/rolandsall24/cqrseventsourcingaxon/commands/product/commands/UpdateProductStatusCommand.java: -------------------------------------------------------------------------------- 1 | package com.rolandsall24.cqrseventsourcingaxon.commands.product.commands; 2 | 3 | import com.rolandsall24.cqrseventsourcingaxon.commands.product.enums.ProductStatus; 4 | import lombok.Getter; 5 | 6 | import java.util.UUID; 7 | 8 | @Getter 9 | public class UpdateProductStatusCommand extends ProductBaseCommand{ 10 | 11 | private ProductStatus status; 12 | 13 | public UpdateProductStatusCommand(UUID id, ProductStatus status) { 14 | super(id); 15 | this.status = status; 16 | } 17 | } 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /event-driven-microservices/java/templates/cqrs-eventsourcing-axon/src/main/java/com/rolandsall24/cqrseventsourcingaxon/commands/product/enums/ProductStatus.java: -------------------------------------------------------------------------------- 1 | package com.rolandsall24.cqrseventsourcingaxon.commands.product.enums; 2 | 3 | public enum ProductStatus{ 4 | CREATED, REMOVED, OUT_OF_STOCK 5 | } -------------------------------------------------------------------------------- /event-driven-microservices/java/templates/cqrs-eventsourcing-axon/src/main/java/com/rolandsall24/cqrseventsourcingaxon/commands/product/events/ProductBaseEvent.java: -------------------------------------------------------------------------------- 1 | package com.rolandsall24.cqrseventsourcingaxon.commands.product.events; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Getter; 5 | 6 | @AllArgsConstructor 7 | public abstract class ProductBaseEvent { 8 | 9 | @Getter 10 | private final T id; 11 | } 12 | -------------------------------------------------------------------------------- /event-driven-microservices/java/templates/cqrs-eventsourcing-axon/src/main/java/com/rolandsall24/cqrseventsourcingaxon/commands/product/events/ProductCreatedEvent.java: -------------------------------------------------------------------------------- 1 | package com.rolandsall24.cqrseventsourcingaxon.commands.product.events; 2 | 3 | 4 | import com.rolandsall24.cqrseventsourcingaxon.commands.product.enums.ProductStatus; 5 | import lombok.AllArgsConstructor; 6 | import lombok.Getter; 7 | 8 | import java.util.UUID; 9 | 10 | @Getter 11 | public class ProductCreatedEvent extends ProductBaseEvent { 12 | private String name; 13 | private long serialNumber; 14 | private ProductStatus productStatus; 15 | 16 | public ProductCreatedEvent(UUID id, String name, long serialNumber, ProductStatus productStatus) { 17 | super(id); 18 | this.name = name; 19 | this.serialNumber = serialNumber; 20 | this.productStatus = productStatus; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /event-driven-microservices/java/templates/cqrs-eventsourcing-axon/src/main/java/com/rolandsall24/cqrseventsourcingaxon/commands/product/events/UpdateProductStatusEvent.java: -------------------------------------------------------------------------------- 1 | package com.rolandsall24.cqrseventsourcingaxon.commands.product.events; 2 | 3 | import com.rolandsall24.cqrseventsourcingaxon.commands.product.enums.ProductStatus; 4 | import lombok.AllArgsConstructor; 5 | import lombok.Getter; 6 | 7 | import java.util.UUID; 8 | 9 | @Getter 10 | public class UpdateProductStatusEvent extends ProductBaseEvent{ 11 | 12 | private ProductStatus status; 13 | 14 | public UpdateProductStatusEvent(UUID id, ProductStatus status) { 15 | super(id); 16 | this.status = status; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /event-driven-microservices/java/templates/cqrs-eventsourcing-axon/src/main/java/com/rolandsall24/cqrseventsourcingaxon/dtos/CreateProductRequestDto.java: -------------------------------------------------------------------------------- 1 | package com.rolandsall24.cqrseventsourcingaxon.dtos; 2 | 3 | import lombok.Builder; 4 | import lombok.Data; 5 | 6 | @Data 7 | @Builder 8 | public class CreateProductRequestDto { 9 | 10 | private String name; 11 | private long serialNumber; 12 | 13 | } 14 | -------------------------------------------------------------------------------- /event-driven-microservices/java/templates/cqrs-eventsourcing-axon/src/main/java/com/rolandsall24/cqrseventsourcingaxon/dtos/UpdateProductDto.java: -------------------------------------------------------------------------------- 1 | package com.rolandsall24.cqrseventsourcingaxon.dtos; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Builder; 5 | import lombok.Getter; 6 | import lombok.NoArgsConstructor; 7 | 8 | @Builder 9 | @Getter 10 | @AllArgsConstructor 11 | @NoArgsConstructor 12 | public class UpdateProductDto { 13 | 14 | private String productStatus; 15 | } 16 | -------------------------------------------------------------------------------- /event-driven-microservices/java/templates/cqrs-eventsourcing-axon/src/main/java/com/rolandsall24/cqrseventsourcingaxon/model/Product.java: -------------------------------------------------------------------------------- 1 | package com.rolandsall24.cqrseventsourcingaxon.model; 2 | 3 | import lombok.Data; 4 | 5 | import javax.persistence.Entity; 6 | import javax.persistence.GeneratedValue; 7 | import javax.persistence.Id; 8 | import java.util.UUID; 9 | 10 | @Data 11 | @Entity 12 | public class Product { 13 | 14 | 15 | @Id 16 | private UUID productId; 17 | private String name; 18 | private long serialNumber; 19 | } 20 | -------------------------------------------------------------------------------- /event-driven-microservices/java/templates/cqrs-eventsourcing-axon/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | # Local Dev -> for container change the values to match the docker file (postgress conenction 2 | server.port=8080 3 | spring.datasource.url=jdbc:mysql://${MSQL_HOST:localhost}:${MSQL_PORT:3306}/cqrs-es?createDatabaseIfNotExist=true 4 | spring.datasource.username=${MYSQL_USER:root} 5 | spring.datasource.password=${MYSQL_PASS:root} 6 | spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MariaDBDialect 7 | spring.jpa.hibernate.ddl-auto=update 8 | spring.jpa.hibernate.show-sql=true 9 | 10 | 11 | spring.mvc.pathmatch.matching-strategy=ant_path_matcher 12 | -------------------------------------------------------------------------------- /event-driven-microservices/java/templates/cqrs-eventsourcing-axon/src/test/java/com/rolandsall24/cqrseventsourcingaxon/CqrsEventsourcingAxonApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.rolandsall24.cqrseventsourcingaxon; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class CqrsEventsourcingAxonApplicationTests { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /microservices/microservice-full-example-two/README.md: -------------------------------------------------------------------------------- 1 | # Project Learning 2 | 3 | In this project, we will develop a microservice solution using spring boot and spring cloud similar to the first example of microservices. However this time we will focus more on desgin patterns and software concepts such as: 4 | 1. Clean Architecture & Hexagonal Architecture 5 | 2. Domain Driven Design 6 | 3. CQRS Pattern 7 | 4. SAGA and Outbox Patterns 8 | 9 | 10 | We will also use Docker and K8S and apply clean code principles (discussed in the other directories of this repo) to build an application that meets a real-world use case. 11 | 12 | Quick Summary: https://docs.google.com/presentation/d/18NCGcusCAugltyvtL6nHkghIsPx0489pSNXtEBYJ5Yk/edit?usp=sharing 13 | 14 | 15 | -------------------------------------------------------------------------------- /microservices/microservice-full-example-two/food-ordering-system/.gitignore: -------------------------------------------------------------------------------- 1 | .idea 2 | 3 | ./order-service/idea -------------------------------------------------------------------------------- /microservices/microservice-full-example-two/food-ordering-system/common/common-domain/src/main/java/com/rolandsall/food/ordering/system/domain/entity/AggregateRoot.java: -------------------------------------------------------------------------------- 1 | package com.rolandsall.food.ordering.system.domain.entity; 2 | 3 | // marker 4 | public abstract class AggregateRoot extends BaseEntity { 5 | } 6 | -------------------------------------------------------------------------------- /microservices/microservice-full-example-two/food-ordering-system/common/common-domain/src/main/java/com/rolandsall/food/ordering/system/domain/entity/BaseEntity.java: -------------------------------------------------------------------------------- 1 | package com.rolandsall.food.ordering.system.domain.entity; 2 | 3 | import java.util.Objects; 4 | 5 | public abstract class BaseEntity { 6 | private ID id; 7 | 8 | public ID getId() { 9 | return id; 10 | } 11 | 12 | public void setId(ID id) { 13 | this.id = id; 14 | } 15 | 16 | @Override 17 | public boolean equals(Object o) { 18 | if (this == o) return true; 19 | if (o == null || getClass() != o.getClass()) return false; 20 | BaseEntity that = (BaseEntity) o; 21 | return Objects.equals(id, that.id); 22 | } 23 | 24 | @Override 25 | public int hashCode() { 26 | return Objects.hash(id); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /microservices/microservice-full-example-two/food-ordering-system/common/common-domain/src/main/java/com/rolandsall/food/ordering/system/domain/event/DomainEvent.java: -------------------------------------------------------------------------------- 1 | package com.rolandsall.food.ordering.system.domain.event; 2 | 3 | public interface DomainEvent { 4 | } 5 | -------------------------------------------------------------------------------- /microservices/microservice-full-example-two/food-ordering-system/common/common-domain/src/main/java/com/rolandsall/food/ordering/system/domain/event/publisher/DomainEventPublisher.java: -------------------------------------------------------------------------------- 1 | package com.rolandsall.food.ordering.system.domain.event.publisher; 2 | 3 | import com.rolandsall.food.ordering.system.domain.event.DomainEvent; 4 | 5 | public interface DomainEventPublisher { 6 | 7 | void publish(T domainEvent); 8 | } 9 | -------------------------------------------------------------------------------- /microservices/microservice-full-example-two/food-ordering-system/common/common-domain/src/main/java/com/rolandsall/food/ordering/system/domain/exception/DomainException.java: -------------------------------------------------------------------------------- 1 | package com.rolandsall.food.ordering.system.domain.exception; 2 | 3 | public class DomainException extends RuntimeException{ 4 | 5 | public DomainException(String message) { 6 | super(message); 7 | } 8 | 9 | public DomainException(String message, Throwable cause) { 10 | super(message, cause); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /microservices/microservice-full-example-two/food-ordering-system/common/common-domain/src/main/java/com/rolandsall/food/ordering/system/domain/valueobject/BaseId.java: -------------------------------------------------------------------------------- 1 | package com.rolandsall.food.ordering.system.domain.valueobject; 2 | 3 | import java.util.Objects; 4 | 5 | public abstract class BaseId { 6 | private final T value; 7 | 8 | protected BaseId(T value) { 9 | this.value = value; 10 | } 11 | 12 | public T getValue() { 13 | return value; 14 | } 15 | 16 | @Override 17 | public boolean equals(Object o) { 18 | if (this == o) return true; 19 | if (o == null || getClass() != o.getClass()) return false; 20 | BaseId baseId = (BaseId) o; 21 | return Objects.equals(value, baseId.value); 22 | } 23 | 24 | @Override 25 | public int hashCode() { 26 | return Objects.hash(value); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /microservices/microservice-full-example-two/food-ordering-system/common/common-domain/src/main/java/com/rolandsall/food/ordering/system/domain/valueobject/CustomerId.java: -------------------------------------------------------------------------------- 1 | package com.rolandsall.food.ordering.system.domain.valueobject; 2 | 3 | import java.util.UUID; 4 | 5 | public class CustomerId extends BaseId{ 6 | 7 | public CustomerId(UUID value) { 8 | super(value); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /microservices/microservice-full-example-two/food-ordering-system/common/common-domain/src/main/java/com/rolandsall/food/ordering/system/domain/valueobject/OrderApprovalStatus.java: -------------------------------------------------------------------------------- 1 | package com.rolandsall.food.ordering.system.domain.valueobject; 2 | 3 | public enum OrderApprovalStatus { 4 | APPROVED, REJECTED 5 | } 6 | -------------------------------------------------------------------------------- /microservices/microservice-full-example-two/food-ordering-system/common/common-domain/src/main/java/com/rolandsall/food/ordering/system/domain/valueobject/OrderId.java: -------------------------------------------------------------------------------- 1 | package com.rolandsall.food.ordering.system.domain.valueobject; 2 | 3 | import java.util.UUID; 4 | 5 | public class OrderId extends BaseId{ 6 | 7 | public OrderId(UUID value) { 8 | super(value); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /microservices/microservice-full-example-two/food-ordering-system/common/common-domain/src/main/java/com/rolandsall/food/ordering/system/domain/valueobject/OrderStatus.java: -------------------------------------------------------------------------------- 1 | package com.rolandsall.food.ordering.system.domain.valueobject; 2 | 3 | public enum OrderStatus { 4 | PENDING, PAID, APPROVED, CANCELLING, CANCELLED 5 | } 6 | -------------------------------------------------------------------------------- /microservices/microservice-full-example-two/food-ordering-system/common/common-domain/src/main/java/com/rolandsall/food/ordering/system/domain/valueobject/PaymentStatus.java: -------------------------------------------------------------------------------- 1 | package com.rolandsall.food.ordering.system.domain.valueobject; 2 | 3 | public enum PaymentStatus { 4 | COMPLETED, CANCELLED, FAILED 5 | } 6 | -------------------------------------------------------------------------------- /microservices/microservice-full-example-two/food-ordering-system/common/common-domain/src/main/java/com/rolandsall/food/ordering/system/domain/valueobject/ProductId.java: -------------------------------------------------------------------------------- 1 | package com.rolandsall.food.ordering.system.domain.valueobject; 2 | 3 | import java.util.UUID; 4 | 5 | public class ProductId extends BaseId{ 6 | 7 | public ProductId(UUID value) { 8 | super(value); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /microservices/microservice-full-example-two/food-ordering-system/common/common-domain/src/main/java/com/rolandsall/food/ordering/system/domain/valueobject/RestaurantId.java: -------------------------------------------------------------------------------- 1 | package com.rolandsall.food.ordering.system.domain.valueobject; 2 | 3 | import java.util.UUID; 4 | 5 | public class RestaurantId extends BaseId{ 6 | 7 | public RestaurantId(UUID value) { 8 | super(value); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /microservices/microservice-full-example-two/food-ordering-system/common/common-domain/src/test/java/com/rolandsall/AppTest.java: -------------------------------------------------------------------------------- 1 | package com.rolandsall; 2 | 3 | import junit.framework.Test; 4 | import junit.framework.TestCase; 5 | import junit.framework.TestSuite; 6 | 7 | /** 8 | * Unit test for simple App. 9 | */ 10 | public class AppTest 11 | extends TestCase 12 | { 13 | /** 14 | * Create the test case 15 | * 16 | * @param testName name of the test case 17 | */ 18 | public AppTest( String testName ) 19 | { 20 | super( testName ); 21 | } 22 | 23 | /** 24 | * @return the suite of tests being tested 25 | */ 26 | public static Test suite() 27 | { 28 | return new TestSuite( AppTest.class ); 29 | } 30 | 31 | /** 32 | * Rigourous Test :-) 33 | */ 34 | public void testApp() 35 | { 36 | assertTrue( true ); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /microservices/microservice-full-example-two/food-ordering-system/common/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | food-ordering-system 5 | com.rolandsall 6 | 1.0-SNAPSHOT 7 | 8 | 4.0.0 9 | 10 | common 11 | pom 12 | 13 | 14 | common-domain 15 | 16 | 17 | common 18 | 19 | 20 | 21 | UTF-8 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /microservices/microservice-full-example-two/food-ordering-system/infrastructure/docker-compose/.env: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RolandSall/Software-Concepts/c2623eac706a8bf998c246c1c4e5d4d3cfc9ed18/microservices/microservice-full-example-two/food-ordering-system/infrastructure/docker-compose/.env -------------------------------------------------------------------------------- /microservices/microservice-full-example-two/food-ordering-system/infrastructure/docker-compose/common.yml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RolandSall/Software-Concepts/c2623eac706a8bf998c246c1c4e5d4d3cfc9ed18/microservices/microservice-full-example-two/food-ordering-system/infrastructure/docker-compose/common.yml -------------------------------------------------------------------------------- /microservices/microservice-full-example-two/food-ordering-system/infrastructure/docker-compose/kafka_cluster.yml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RolandSall/Software-Concepts/c2623eac706a8bf998c246c1c4e5d4d3cfc9ed18/microservices/microservice-full-example-two/food-ordering-system/infrastructure/docker-compose/kafka_cluster.yml -------------------------------------------------------------------------------- /microservices/microservice-full-example-two/food-ordering-system/infrastructure/docker-compose/zookeeper.yml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RolandSall/Software-Concepts/c2623eac706a8bf998c246c1c4e5d4d3cfc9ed18/microservices/microservice-full-example-two/food-ordering-system/infrastructure/docker-compose/zookeeper.yml -------------------------------------------------------------------------------- /microservices/microservice-full-example-two/food-ordering-system/order-service/order-application/src/main/java/com/rolandsall/App.java: -------------------------------------------------------------------------------- 1 | package com.rolandsall; 2 | 3 | /** 4 | * Hello world! 5 | * 6 | */ 7 | public class App 8 | { 9 | public static void main( String[] args ) 10 | { 11 | System.out.println( "Hello World!" ); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /microservices/microservice-full-example-two/food-ordering-system/order-service/order-application/src/test/java/com/rolandsall/AppTest.java: -------------------------------------------------------------------------------- 1 | package com.rolandsall; 2 | 3 | import junit.framework.Test; 4 | import junit.framework.TestCase; 5 | import junit.framework.TestSuite; 6 | 7 | /** 8 | * Unit test for simple App. 9 | */ 10 | public class AppTest 11 | extends TestCase 12 | { 13 | /** 14 | * Create the test case 15 | * 16 | * @param testName name of the test case 17 | */ 18 | public AppTest( String testName ) 19 | { 20 | super( testName ); 21 | } 22 | 23 | /** 24 | * @return the suite of tests being tested 25 | */ 26 | public static Test suite() 27 | { 28 | return new TestSuite( AppTest.class ); 29 | } 30 | 31 | /** 32 | * Rigourous Test :-) 33 | */ 34 | public void testApp() 35 | { 36 | assertTrue( true ); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /microservices/microservice-full-example-two/food-ordering-system/order-service/order-container/src/main/java/com/rolandsall/App.java: -------------------------------------------------------------------------------- 1 | package com.rolandsall; 2 | 3 | /** 4 | * Hello world! 5 | * 6 | */ 7 | public class App 8 | { 9 | public static void main( String[] args ) 10 | { 11 | System.out.println( "Hello World!" ); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /microservices/microservice-full-example-two/food-ordering-system/order-service/order-container/src/test/java/com/rolandsall/AppTest.java: -------------------------------------------------------------------------------- 1 | package com.rolandsall; 2 | 3 | import junit.framework.Test; 4 | import junit.framework.TestCase; 5 | import junit.framework.TestSuite; 6 | 7 | /** 8 | * Unit test for simple App. 9 | */ 10 | public class AppTest 11 | extends TestCase 12 | { 13 | /** 14 | * Create the test case 15 | * 16 | * @param testName name of the test case 17 | */ 18 | public AppTest( String testName ) 19 | { 20 | super( testName ); 21 | } 22 | 23 | /** 24 | * @return the suite of tests being tested 25 | */ 26 | public static Test suite() 27 | { 28 | return new TestSuite( AppTest.class ); 29 | } 30 | 31 | /** 32 | * Rigourous Test :-) 33 | */ 34 | public void testApp() 35 | { 36 | assertTrue( true ); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /microservices/microservice-full-example-two/food-ordering-system/order-service/order-dataaccess/src/main/java/com/rolandsall/App.java: -------------------------------------------------------------------------------- 1 | package com.rolandsall; 2 | 3 | /** 4 | * Hello world! 5 | * 6 | */ 7 | public class App 8 | { 9 | public static void main( String[] args ) 10 | { 11 | System.out.println( "Hello World!" ); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /microservices/microservice-full-example-two/food-ordering-system/order-service/order-dataaccess/src/test/java/com/rolandsall/AppTest.java: -------------------------------------------------------------------------------- 1 | package com.rolandsall; 2 | 3 | import junit.framework.Test; 4 | import junit.framework.TestCase; 5 | import junit.framework.TestSuite; 6 | 7 | /** 8 | * Unit test for simple App. 9 | */ 10 | public class AppTest 11 | extends TestCase 12 | { 13 | /** 14 | * Create the test case 15 | * 16 | * @param testName name of the test case 17 | */ 18 | public AppTest( String testName ) 19 | { 20 | super( testName ); 21 | } 22 | 23 | /** 24 | * @return the suite of tests being tested 25 | */ 26 | public static Test suite() 27 | { 28 | return new TestSuite( AppTest.class ); 29 | } 30 | 31 | /** 32 | * Rigourous Test :-) 33 | */ 34 | public void testApp() 35 | { 36 | assertTrue( true ); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /microservices/microservice-full-example-two/food-ordering-system/order-service/order-domain/order-application-service/src/main/java/com/rolandsall/order/service/domain/dto/create/CreateOrderCommand.java: -------------------------------------------------------------------------------- 1 | package com.rolandsall.order.service.domain.dto.create; 2 | 3 | 4 | import lombok.AllArgsConstructor; 5 | import lombok.Builder; 6 | import lombok.Getter; 7 | 8 | import javax.validation.constraints.NotNull; 9 | import java.math.BigDecimal; 10 | import java.util.List; 11 | import java.util.UUID; 12 | 13 | @Builder 14 | @AllArgsConstructor 15 | @Getter 16 | public class CreateOrderCommand { 17 | @NotNull 18 | private final UUID customerId; 19 | @NotNull 20 | private final UUID restaurantId; 21 | @NotNull 22 | private final BigDecimal price; 23 | @NotNull 24 | private final List items; 25 | @NotNull 26 | private final OrderAddress orderAddress; 27 | } 28 | -------------------------------------------------------------------------------- /microservices/microservice-full-example-two/food-ordering-system/order-service/order-domain/order-application-service/src/main/java/com/rolandsall/order/service/domain/dto/create/CreateOrderResponse.java: -------------------------------------------------------------------------------- 1 | package com.rolandsall.order.service.domain.dto.create; 2 | 3 | import com.rolandsall.food.ordering.system.domain.valueobject.OrderStatus; 4 | import lombok.AllArgsConstructor; 5 | import lombok.Builder; 6 | import lombok.Getter; 7 | 8 | import javax.validation.constraints.NotNull; 9 | import java.util.UUID; 10 | 11 | @Getter 12 | @Builder 13 | @AllArgsConstructor 14 | public class CreateOrderResponse { 15 | @NotNull 16 | private final UUID orderTrackingId; 17 | @NotNull 18 | private final OrderStatus orderStatus; 19 | @NotNull 20 | private String message; 21 | 22 | } 23 | -------------------------------------------------------------------------------- /microservices/microservice-full-example-two/food-ordering-system/order-service/order-domain/order-application-service/src/main/java/com/rolandsall/order/service/domain/dto/create/OrderAddress.java: -------------------------------------------------------------------------------- 1 | package com.rolandsall.order.service.domain.dto.create; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Builder; 5 | import lombok.Getter; 6 | 7 | import javax.validation.constraints.Max; 8 | import javax.validation.constraints.NotNull; 9 | 10 | @Getter 11 | @Builder 12 | @AllArgsConstructor 13 | public class OrderAddress { 14 | @NotNull 15 | @Max(value = 50) 16 | private final String street; 17 | @NotNull 18 | @Max(value = 10) 19 | private final String postalCode; 20 | @NotNull 21 | private final String city; 22 | } 23 | -------------------------------------------------------------------------------- /microservices/microservice-full-example-two/food-ordering-system/order-service/order-domain/order-application-service/src/main/java/com/rolandsall/order/service/domain/dto/create/OrderItem.java: -------------------------------------------------------------------------------- 1 | package com.rolandsall.order.service.domain.dto.create; 2 | 3 | 4 | import lombok.AllArgsConstructor; 5 | import lombok.Builder; 6 | import lombok.Getter; 7 | 8 | import javax.validation.constraints.NotNull; 9 | import java.math.BigDecimal; 10 | import java.util.UUID; 11 | 12 | @Getter 13 | @Builder 14 | @AllArgsConstructor 15 | public class OrderItem { 16 | @NotNull 17 | private final UUID productId; 18 | @NotNull 19 | private final Integer quantity; 20 | @NotNull 21 | private final BigDecimal price; 22 | @NotNull 23 | private final BigDecimal subTotal; 24 | } 25 | -------------------------------------------------------------------------------- /microservices/microservice-full-example-two/food-ordering-system/order-service/order-domain/order-application-service/src/main/java/com/rolandsall/order/service/domain/dto/message/PaymentResponse.java: -------------------------------------------------------------------------------- 1 | package com.rolandsall.order.service.domain.dto.message; 2 | 3 | 4 | import com.rolandsall.food.ordering.system.domain.valueobject.PaymentStatus; 5 | import lombok.AllArgsConstructor; 6 | import lombok.Builder; 7 | import lombok.Getter; 8 | 9 | import java.math.BigDecimal; 10 | import java.time.Instant; 11 | import java.util.List; 12 | 13 | @Getter 14 | @Builder 15 | @AllArgsConstructor 16 | public class PaymentResponse { 17 | private String id; 18 | private String sagaId; 19 | private String orderId; 20 | private String paymentId; 21 | private String customerId; 22 | private BigDecimal price; 23 | private Instant createdAt; 24 | private PaymentStatus paymentStatus; 25 | private List failureMessages; 26 | } 27 | -------------------------------------------------------------------------------- /microservices/microservice-full-example-two/food-ordering-system/order-service/order-domain/order-application-service/src/main/java/com/rolandsall/order/service/domain/dto/message/RestaurantApprovalResponse.java: -------------------------------------------------------------------------------- 1 | package com.rolandsall.order.service.domain.dto.message; 2 | 3 | import com.rolandsall.food.ordering.system.domain.valueobject.OrderApprovalStatus; 4 | import lombok.AllArgsConstructor; 5 | import lombok.Builder; 6 | import lombok.Getter; 7 | 8 | import java.time.Instant; 9 | import java.util.List; 10 | 11 | @Getter 12 | @Builder 13 | @AllArgsConstructor 14 | public class RestaurantApprovalResponse { 15 | private String id; 16 | private String sagaId; 17 | private String orderId; 18 | private String restaurantId; 19 | private Instant createdAt; 20 | private OrderApprovalStatus orderApprovalStatus; 21 | private List failureMessages; 22 | } 23 | -------------------------------------------------------------------------------- /microservices/microservice-full-example-two/food-ordering-system/order-service/order-domain/order-application-service/src/main/java/com/rolandsall/order/service/domain/dto/track/TrackOrderQuery.java: -------------------------------------------------------------------------------- 1 | package com.rolandsall.order.service.domain.dto.track; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Builder; 5 | import lombok.Getter; 6 | 7 | import javax.validation.constraints.NotNull; 8 | import java.util.UUID; 9 | 10 | @Getter 11 | @Builder 12 | @AllArgsConstructor 13 | public class TrackOrderQuery { 14 | @NotNull 15 | private final UUID orderTrackingId; 16 | 17 | } 18 | -------------------------------------------------------------------------------- /microservices/microservice-full-example-two/food-ordering-system/order-service/order-domain/order-application-service/src/main/java/com/rolandsall/order/service/domain/dto/track/TrackOrderResponse.java: -------------------------------------------------------------------------------- 1 | package com.rolandsall.order.service.domain.dto.track; 2 | 3 | import com.rolandsall.food.ordering.system.domain.valueobject.OrderStatus; 4 | import lombok.AllArgsConstructor; 5 | import lombok.Builder; 6 | import lombok.Getter; 7 | 8 | import javax.validation.constraints.NotNull; 9 | import java.util.List; 10 | import java.util.UUID; 11 | 12 | @Getter 13 | @Builder 14 | @AllArgsConstructor 15 | public class TrackOrderResponse { 16 | @NotNull 17 | private final UUID orderTrackingId; 18 | @NotNull 19 | private final OrderStatus orderStatus; 20 | private final List failureMessages; 21 | } 22 | -------------------------------------------------------------------------------- /microservices/microservice-full-example-two/food-ordering-system/order-service/order-domain/order-application-service/src/main/java/com/rolandsall/order/service/domain/payment/PaymentResponseMessageListener.java: -------------------------------------------------------------------------------- 1 | package com.rolandsall.order.service.domain.payment; 2 | 3 | import com.rolandsall.order.service.domain.dto.message.PaymentResponse; 4 | import com.rolandsall.order.service.domain.ports.input.message.listener.payment.IPaymentResponseMessageListener; 5 | import lombok.extern.slf4j.Slf4j; 6 | import org.springframework.stereotype.Service; 7 | import org.springframework.validation.annotation.Validated; 8 | 9 | @Slf4j 10 | @Validated 11 | @Service 12 | public class PaymentResponseMessageListener implements IPaymentResponseMessageListener { 13 | @Override 14 | public void paymentCompleted(PaymentResponse paymentResponse) { 15 | 16 | } 17 | 18 | @Override 19 | public void paymentCancelled(PaymentResponse paymentResponse) { 20 | 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /microservices/microservice-full-example-two/food-ordering-system/order-service/order-domain/order-application-service/src/main/java/com/rolandsall/order/service/domain/ports/input/message/listener/payment/IPaymentResponseMessageListener.java: -------------------------------------------------------------------------------- 1 | package com.rolandsall.order.service.domain.ports.input.message.listener.payment; 2 | 3 | import com.rolandsall.order.service.domain.dto.message.PaymentResponse; 4 | 5 | public interface IPaymentResponseMessageListener { 6 | 7 | void paymentCompleted(PaymentResponse paymentResponse); 8 | 9 | void paymentCancelled(PaymentResponse paymentResponse); 10 | } 11 | -------------------------------------------------------------------------------- /microservices/microservice-full-example-two/food-ordering-system/order-service/order-domain/order-application-service/src/main/java/com/rolandsall/order/service/domain/ports/input/message/listener/restaurantapproval/IRestaurantApprovalResponseMessageListener.java: -------------------------------------------------------------------------------- 1 | package com.rolandsall.order.service.domain.ports.input.message.listener.restaurantapproval; 2 | 3 | import com.rolandsall.order.service.domain.dto.message.RestaurantApprovalResponse; 4 | 5 | public interface IRestaurantApprovalResponseMessageListener { 6 | 7 | void orderApproved(RestaurantApprovalResponse restaurantApprovalResponse); 8 | 9 | void orderRejected(RestaurantApprovalResponse restaurantApprovalResponse); 10 | 11 | } 12 | -------------------------------------------------------------------------------- /microservices/microservice-full-example-two/food-ordering-system/order-service/order-domain/order-application-service/src/main/java/com/rolandsall/order/service/domain/ports/input/service/OrderApplicationService.java: -------------------------------------------------------------------------------- 1 | package com.rolandsall.order.service.domain.ports.input.service; 2 | 3 | import com.rolandsall.order.service.domain.dto.create.CreateOrderCommand; 4 | import com.rolandsall.order.service.domain.dto.create.CreateOrderResponse; 5 | import com.rolandsall.order.service.domain.dto.track.TrackOrderQuery; 6 | import com.rolandsall.order.service.domain.dto.track.TrackOrderResponse; 7 | 8 | import javax.validation.Valid; 9 | 10 | public interface OrderApplicationService { 11 | 12 | CreateOrderResponse createOrder(@Valid CreateOrderCommand createOrderCommand); 13 | 14 | TrackOrderResponse trackOrder (@Valid TrackOrderQuery trackOrderQuery); 15 | } 16 | -------------------------------------------------------------------------------- /microservices/microservice-full-example-two/food-ordering-system/order-service/order-domain/order-application-service/src/main/java/com/rolandsall/order/service/domain/ports/output/message/publisher/payment/OrderCancelledPaymentRequestMessagePublisher.java: -------------------------------------------------------------------------------- 1 | package com.rolandsall.order.service.domain.ports.output.message.publisher.payment; 2 | 3 | import com.rolandsall.food.ordering.system.domain.event.publisher.DomainEventPublisher; 4 | import com.rolandsall.order.service.domain.event.OrderCancelledEvent; 5 | 6 | public interface OrderCancelledPaymentRequestMessagePublisher extends DomainEventPublisher { 7 | } 8 | -------------------------------------------------------------------------------- /microservices/microservice-full-example-two/food-ordering-system/order-service/order-domain/order-application-service/src/main/java/com/rolandsall/order/service/domain/ports/output/message/publisher/payment/OrderCreatedPaymentRequestMessagePublisher.java: -------------------------------------------------------------------------------- 1 | package com.rolandsall.order.service.domain.ports.output.message.publisher.payment; 2 | 3 | import com.rolandsall.food.ordering.system.domain.event.publisher.DomainEventPublisher; 4 | import com.rolandsall.order.service.domain.event.OrderCreatedEvent; 5 | 6 | public interface OrderCreatedPaymentRequestMessagePublisher extends DomainEventPublisher { 7 | } 8 | -------------------------------------------------------------------------------- /microservices/microservice-full-example-two/food-ordering-system/order-service/order-domain/order-application-service/src/main/java/com/rolandsall/order/service/domain/ports/output/message/publisher/restaurantapproval/OrderPaidRestaurantRequestMessagePublisher.java: -------------------------------------------------------------------------------- 1 | package com.rolandsall.order.service.domain.ports.output.message.publisher.restaurantapproval; 2 | 3 | import com.rolandsall.food.ordering.system.domain.event.publisher.DomainEventPublisher; 4 | import com.rolandsall.order.service.domain.event.OrderCancelledEvent; 5 | import com.rolandsall.order.service.domain.event.OrderPaidEvent; 6 | 7 | public interface OrderPaidRestaurantRequestMessagePublisher extends DomainEventPublisher { 8 | } 9 | -------------------------------------------------------------------------------- /microservices/microservice-full-example-two/food-ordering-system/order-service/order-domain/order-application-service/src/main/java/com/rolandsall/order/service/domain/ports/output/repository/CustomerRepository.java: -------------------------------------------------------------------------------- 1 | package com.rolandsall.order.service.domain.ports.output.repository; 2 | 3 | import com.rolandsall.order.service.domain.entity.Customer; 4 | 5 | import java.util.Optional; 6 | import java.util.UUID; 7 | 8 | public interface CustomerRepository { 9 | 10 | Optional findCustomer(UUID customerId); 11 | } 12 | -------------------------------------------------------------------------------- /microservices/microservice-full-example-two/food-ordering-system/order-service/order-domain/order-application-service/src/main/java/com/rolandsall/order/service/domain/ports/output/repository/OrderRepository.java: -------------------------------------------------------------------------------- 1 | package com.rolandsall.order.service.domain.ports.output.repository; 2 | 3 | import com.rolandsall.order.service.domain.entity.Order; 4 | import com.rolandsall.order.service.domain.valueobject.TrackingId; 5 | 6 | import java.util.Optional; 7 | 8 | public interface OrderRepository { 9 | 10 | Order save(Order order); 11 | 12 | Optional findByTrackingId(TrackingId trackingId); 13 | } 14 | -------------------------------------------------------------------------------- /microservices/microservice-full-example-two/food-ordering-system/order-service/order-domain/order-application-service/src/main/java/com/rolandsall/order/service/domain/ports/output/repository/RestaurantRepository.java: -------------------------------------------------------------------------------- 1 | package com.rolandsall.order.service.domain.ports.output.repository; 2 | 3 | import com.rolandsall.order.service.domain.entity.Restaurant; 4 | 5 | import java.util.Optional; 6 | 7 | public interface RestaurantRepository { 8 | 9 | Optional findRestaurantInformation(Restaurant restaurant); 10 | } 11 | -------------------------------------------------------------------------------- /microservices/microservice-full-example-two/food-ordering-system/order-service/order-domain/order-domain-core/src/main/java/com/rolandsall/order/service/domain/entity/Customer.java: -------------------------------------------------------------------------------- 1 | package com.rolandsall.order.service.domain.entity; 2 | 3 | import com.rolandsall.food.ordering.system.domain.entity.AggregateRoot; 4 | import com.rolandsall.food.ordering.system.domain.valueobject.CustomerId; 5 | 6 | public class Customer extends AggregateRoot { 7 | 8 | } 9 | -------------------------------------------------------------------------------- /microservices/microservice-full-example-two/food-ordering-system/order-service/order-domain/order-domain-core/src/main/java/com/rolandsall/order/service/domain/event/OrderCancelledEvent.java: -------------------------------------------------------------------------------- 1 | package com.rolandsall.order.service.domain.event; 2 | 3 | import com.rolandsall.order.service.domain.entity.Order; 4 | 5 | import java.time.ZonedDateTime; 6 | 7 | public class OrderCancelledEvent extends OrderEvent { 8 | 9 | public OrderCancelledEvent(Order order, ZonedDateTime createdAt) { 10 | super(order, createdAt); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /microservices/microservice-full-example-two/food-ordering-system/order-service/order-domain/order-domain-core/src/main/java/com/rolandsall/order/service/domain/event/OrderCreatedEvent.java: -------------------------------------------------------------------------------- 1 | package com.rolandsall.order.service.domain.event; 2 | 3 | import com.rolandsall.order.service.domain.entity.Order; 4 | 5 | import java.time.ZonedDateTime; 6 | 7 | public class OrderCreatedEvent extends OrderEvent { 8 | 9 | public OrderCreatedEvent(Order order, ZonedDateTime createdAt) { 10 | super(order, createdAt); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /microservices/microservice-full-example-two/food-ordering-system/order-service/order-domain/order-domain-core/src/main/java/com/rolandsall/order/service/domain/event/OrderEvent.java: -------------------------------------------------------------------------------- 1 | package com.rolandsall.order.service.domain.event; 2 | 3 | import com.rolandsall.food.ordering.system.domain.event.DomainEvent; 4 | import com.rolandsall.order.service.domain.entity.Order; 5 | 6 | import java.time.ZonedDateTime; 7 | 8 | public abstract class OrderEvent implements DomainEvent { 9 | private final Order order; 10 | private final ZonedDateTime createdAt; 11 | 12 | public OrderEvent(Order order, ZonedDateTime createdAt) { 13 | this.order = order; 14 | this.createdAt = createdAt; 15 | } 16 | 17 | 18 | public Order getOrder() { 19 | return order; 20 | } 21 | 22 | public ZonedDateTime getCreatedAt() { 23 | return createdAt; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /microservices/microservice-full-example-two/food-ordering-system/order-service/order-domain/order-domain-core/src/main/java/com/rolandsall/order/service/domain/event/OrderPaidEvent.java: -------------------------------------------------------------------------------- 1 | package com.rolandsall.order.service.domain.event; 2 | 3 | import com.rolandsall.order.service.domain.entity.Order; 4 | 5 | import java.time.ZonedDateTime; 6 | 7 | public class OrderPaidEvent extends OrderEvent { 8 | public OrderPaidEvent(Order order, ZonedDateTime createdAt) { 9 | super(order, createdAt); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /microservices/microservice-full-example-two/food-ordering-system/order-service/order-domain/order-domain-core/src/main/java/com/rolandsall/order/service/domain/exception/OrderDomainException.java: -------------------------------------------------------------------------------- 1 | package com.rolandsall.order.service.domain.exception; 2 | 3 | import com.rolandsall.food.ordering.system.domain.exception.DomainException; 4 | 5 | public class OrderDomainException extends DomainException { 6 | 7 | public OrderDomainException(String message) { 8 | super(message); 9 | } 10 | 11 | public OrderDomainException(String message, Throwable cause) { 12 | super(message, cause); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /microservices/microservice-full-example-two/food-ordering-system/order-service/order-domain/order-domain-core/src/main/java/com/rolandsall/order/service/domain/exception/OrderNotFoundException.java: -------------------------------------------------------------------------------- 1 | package com.rolandsall.order.service.domain.exception; 2 | 3 | import com.rolandsall.food.ordering.system.domain.exception.DomainException; 4 | 5 | public class OrderNotFoundException extends DomainException { 6 | public OrderNotFoundException(String message) { 7 | super(message); 8 | } 9 | 10 | public OrderNotFoundException(String message, Throwable cause) { 11 | super(message, cause); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /microservices/microservice-full-example-two/food-ordering-system/order-service/order-domain/order-domain-core/src/main/java/com/rolandsall/order/service/domain/valueobject/OrderItemId.java: -------------------------------------------------------------------------------- 1 | package com.rolandsall.order.service.domain.valueobject; 2 | 3 | import com.rolandsall.food.ordering.system.domain.valueobject.BaseId; 4 | 5 | public class OrderItemId extends BaseId { 6 | public OrderItemId(Long value) { 7 | super(value); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /microservices/microservice-full-example-two/food-ordering-system/order-service/order-domain/order-domain-core/src/main/java/com/rolandsall/order/service/domain/valueobject/TrackingId.java: -------------------------------------------------------------------------------- 1 | package com.rolandsall.order.service.domain.valueobject; 2 | 3 | import com.rolandsall.food.ordering.system.domain.valueobject.BaseId; 4 | 5 | import java.util.UUID; 6 | 7 | public class TrackingId extends BaseId { 8 | 9 | public TrackingId(UUID value) { 10 | super(value); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /microservices/microservice-full-example-two/food-ordering-system/order-service/order-domain/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | order-service 5 | com.rolandsall 6 | 1.0-SNAPSHOT 7 | 8 | 4.0.0 9 | 10 | order-domain 11 | pom 12 | 13 | order-domain 14 | http://maven.apache.org 15 | 16 | order-domain-core 17 | order-application-service 18 | 19 | 20 | 21 | UTF-8 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /microservices/microservice-full-example-two/food-ordering-system/order-service/order-messaging/src/main/java/com/rolandsall/App.java: -------------------------------------------------------------------------------- 1 | package com.rolandsall; 2 | 3 | /** 4 | * Hello world! 5 | * 6 | */ 7 | public class App 8 | { 9 | public static void main( String[] args ) 10 | { 11 | System.out.println( "Hello World!" ); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /microservices/microservice-full-example-two/food-ordering-system/order-service/order-messaging/src/test/java/com/rolandsall/AppTest.java: -------------------------------------------------------------------------------- 1 | package com.rolandsall; 2 | 3 | import junit.framework.Test; 4 | import junit.framework.TestCase; 5 | import junit.framework.TestSuite; 6 | 7 | /** 8 | * Unit test for simple App. 9 | */ 10 | public class AppTest 11 | extends TestCase 12 | { 13 | /** 14 | * Create the test case 15 | * 16 | * @param testName name of the test case 17 | */ 18 | public AppTest( String testName ) 19 | { 20 | super( testName ); 21 | } 22 | 23 | /** 24 | * @return the suite of tests being tested 25 | */ 26 | public static Test suite() 27 | { 28 | return new TestSuite( AppTest.class ); 29 | } 30 | 31 | /** 32 | * Rigourous Test :-) 33 | */ 34 | public void testApp() 35 | { 36 | assertTrue( true ); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /microservices/microservice-full-example/README.md: -------------------------------------------------------------------------------- 1 | # Project Learning 2 | 3 | In this project, we will develop a microservice solution using spring boot and spring cloud while applying famous spring cloud technologies that are used as microservices patterns such as: 4 | 5 | 1. Service Discovery 6 | 2. Distributed Tracing 7 | 3. API Gateway 8 | 4. Messages Queues: 9 | * RabbitMQ 10 | * Kafka 11 | 12 | We will also use Docker and K8S and apply clean code principles (discussed in the other directories of this repo) to build an application that meets a real-world use case. 13 | 14 | 15 | -------------------------------------------------------------------------------- /microservices/microservice-full-example/microservices/.gitignore: -------------------------------------------------------------------------------- 1 | .idea 2 | microservices.iml 3 | 4 | ./customer/target -------------------------------------------------------------------------------- /microservices/microservice-full-example/microservices/amqp/src/main/java/com/rolandsall/amqp/RabbitMQMessageProducer.java: -------------------------------------------------------------------------------- 1 | package com.rolandsall.amqp; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.extern.slf4j.Slf4j; 5 | import org.springframework.amqp.core.AmqpTemplate; 6 | import org.springframework.stereotype.Component; 7 | 8 | @Component 9 | @Slf4j 10 | @AllArgsConstructor 11 | public class RabbitMQMessageProducer { 12 | 13 | private final AmqpTemplate amqpTemplate; 14 | 15 | public void publish(Object payload, String exchange, String routingKey){ 16 | log.info("Publishing to {} using routing key {}, Payload: {}", exchange, routingKey, payload); 17 | amqpTemplate.convertAndSend(exchange, routingKey, payload); 18 | log.info("Published to {} using routing key {}, Payload: {}", exchange, routingKey, payload); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /microservices/microservice-full-example/microservices/build.sh: -------------------------------------------------------------------------------- 1 | VERSION=latest 2 | 3 | mvn clean install 4 | 5 | cd ./fraud 6 | docker build -t rolandsall24/fraud:$VERSION . 7 | 8 | cd ../notification 9 | docker build -t rolandsall24/notification:$VERSION . 10 | 11 | cd ../gateway 12 | docker build -t rolandsall24/gateway:$VERSION . 13 | 14 | cd ../customer 15 | docker build -t rolandsall24/customer:$VERSION . 16 | 17 | cd ../discovery 18 | docker build -t rolandsall24/discovery:$VERSION . -------------------------------------------------------------------------------- /microservices/microservice-full-example/microservices/client/src/main/java/com/rolandsall/client/fraud/FraudClient.java: -------------------------------------------------------------------------------- 1 | package com.rolandsall.client.fraud; 2 | import org.springframework.cloud.openfeign.FeignClient; 3 | import org.springframework.http.ResponseEntity; 4 | import org.springframework.web.bind.annotation.GetMapping; 5 | import org.springframework.web.bind.annotation.PathVariable; 6 | 7 | import java.util.UUID; 8 | 9 | @FeignClient( 10 | value = "fraud", 11 | path = "api/v1/fraud-check" 12 | ) 13 | public interface FraudClient { 14 | 15 | @GetMapping("{customerId}") 16 | ResponseEntity CheckIfFraud(@PathVariable("customerId") UUID customerId); 17 | } 18 | -------------------------------------------------------------------------------- /microservices/microservice-full-example/microservices/client/src/main/java/com/rolandsall/client/fraud/FraudResponse.java: -------------------------------------------------------------------------------- 1 | package com.rolandsall.client.fraud; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Data; 5 | import lombok.NoArgsConstructor; 6 | 7 | @Data 8 | @NoArgsConstructor 9 | @AllArgsConstructor 10 | public class FraudResponse { 11 | private boolean isFraud; 12 | } 13 | -------------------------------------------------------------------------------- /microservices/microservice-full-example/microservices/client/src/main/java/com/rolandsall/client/notification/NotificationClient.java: -------------------------------------------------------------------------------- 1 | package com.rolandsall.client.notification; 2 | 3 | import org.springframework.cloud.openfeign.FeignClient; 4 | import org.springframework.http.ResponseEntity; 5 | import org.springframework.web.bind.annotation.PostMapping; 6 | import org.springframework.web.bind.annotation.RequestBody; 7 | 8 | @FeignClient(value = "notification", path = "api/v1/notification") 9 | public interface NotificationClient { 10 | 11 | @PostMapping 12 | ResponseEntity sendNotification(@RequestBody NotificationRequest request); 13 | } 14 | -------------------------------------------------------------------------------- /microservices/microservice-full-example/microservices/customer/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM eclipse-temurin:11 2 | ADD target/customer-1.0-SNAPSHOT.jar customer-1.0-SNAPSHOT.jar 3 | EXPOSE 8080 4 | ENTRYPOINT ["java","-jar","customer-1.0-SNAPSHOT.jar"] -------------------------------------------------------------------------------- /microservices/microservice-full-example/microservices/customer/src/main/java/com/rolandsall/customer/CustomerMainApplication.java: -------------------------------------------------------------------------------- 1 | package com.rolandsall.customer; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.cloud.netflix.eureka.EnableEurekaClient; 6 | import org.springframework.cloud.openfeign.EnableFeignClients; 7 | import org.springframework.context.annotation.ComponentScan; 8 | 9 | @SpringBootApplication( 10 | scanBasePackages = { 11 | "com.rolandsall.customer", 12 | "com.rolandsall.amqp", 13 | } 14 | ) 15 | @EnableEurekaClient 16 | @EnableFeignClients( 17 | basePackages = "com.rolandsall.client" 18 | ) 19 | public class CustomerMainApplication { 20 | public static void main(String[] args) { 21 | SpringApplication.run(CustomerMainApplication.class, args); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /microservices/microservice-full-example/microservices/customer/src/main/java/com/rolandsall/customer/SwaggerConfig.java: -------------------------------------------------------------------------------- 1 | package com.rolandsall.customer; 2 | 3 | import org.springframework.context.annotation.Bean; 4 | import org.springframework.context.annotation.Configuration; 5 | import springfox.documentation.builders.PathSelectors; 6 | import springfox.documentation.builders.RequestHandlerSelectors; 7 | import springfox.documentation.spi.DocumentationType; 8 | import springfox.documentation.spring.web.plugins.Docket; 9 | import springfox.documentation.swagger2.annotations.EnableSwagger2; 10 | 11 | @Configuration 12 | @EnableSwagger2 13 | public class SwaggerConfig { 14 | 15 | @Bean 16 | public Docket api() { 17 | return new Docket(DocumentationType.SWAGGER_2) 18 | .select() 19 | .apis(RequestHandlerSelectors.any()) 20 | .paths(PathSelectors.any()) 21 | .build(); 22 | } 23 | } -------------------------------------------------------------------------------- /microservices/microservice-full-example/microservices/customer/src/main/java/com/rolandsall/customer/api/customer/CustomerRegistrationRequest.java: -------------------------------------------------------------------------------- 1 | package com.rolandsall.customer.api.customer; 2 | 3 | import lombok.*; 4 | 5 | @Builder 6 | @Data 7 | @ToString 8 | @NoArgsConstructor 9 | @AllArgsConstructor 10 | public class CustomerRegistrationRequest { 11 | private String firstName; 12 | private String lastName; 13 | private String email; 14 | } 15 | -------------------------------------------------------------------------------- /microservices/microservice-full-example/microservices/customer/src/main/java/com/rolandsall/customer/configurations/CustomerConfiguration.java: -------------------------------------------------------------------------------- 1 | package com.rolandsall.customer.configurations; 2 | 3 | import org.springframework.cloud.client.loadbalancer.LoadBalanced; 4 | import org.springframework.context.annotation.Bean; 5 | import org.springframework.context.annotation.Configuration; 6 | import org.springframework.web.client.RestTemplate; 7 | 8 | @Configuration 9 | public class CustomerConfiguration { 10 | 11 | @Bean 12 | @LoadBalanced 13 | public RestTemplate restTemplate(){ 14 | return new RestTemplate(); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /microservices/microservice-full-example/microservices/customer/src/main/java/com/rolandsall/customer/models/Customer.java: -------------------------------------------------------------------------------- 1 | package com.rolandsall.customer.models; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Builder; 5 | import lombok.Data; 6 | import lombok.NoArgsConstructor; 7 | 8 | import javax.persistence.Entity; 9 | import javax.persistence.Id; 10 | import java.util.UUID; 11 | 12 | @Data 13 | @Builder 14 | @AllArgsConstructor 15 | @NoArgsConstructor 16 | @Entity 17 | public class Customer { 18 | 19 | @Id 20 | private UUID id; 21 | private String firstName; 22 | private String lastName; 23 | private String email; 24 | } 25 | -------------------------------------------------------------------------------- /microservices/microservice-full-example/microservices/customer/src/main/java/com/rolandsall/customer/respositories/customer/ICustomerRepository.java: -------------------------------------------------------------------------------- 1 | package com.rolandsall.customer.respositories.customer; 2 | 3 | import com.rolandsall.customer.models.Customer; 4 | import org.springframework.data.jpa.repository.JpaRepository; 5 | 6 | import java.util.UUID; 7 | 8 | public interface ICustomerRepository extends JpaRepository { 9 | } 10 | -------------------------------------------------------------------------------- /microservices/microservice-full-example/microservices/customer/src/main/java/com/rolandsall/customer/services/ICustomerService.java: -------------------------------------------------------------------------------- 1 | package com.rolandsall.customer.services; 2 | 3 | import com.rolandsall.customer.models.Customer; 4 | 5 | import java.util.List; 6 | 7 | public interface ICustomerService { 8 | void Register(Customer customer); 9 | 10 | List GetUsers(); 11 | 12 | } 13 | -------------------------------------------------------------------------------- /microservices/microservice-full-example/microservices/customer/src/main/java/com/rolandsall/customer/services/IFraudHandler.java: -------------------------------------------------------------------------------- 1 | package com.rolandsall.customer.services; 2 | 3 | import com.rolandsall.customer.models.Customer; 4 | 5 | public interface IFraudHandler { 6 | boolean checkIfFraud(Customer customer); 7 | } 8 | -------------------------------------------------------------------------------- /microservices/microservice-full-example/microservices/customer/src/main/java/com/rolandsall/customer/services/INotificationHandler.java: -------------------------------------------------------------------------------- 1 | package com.rolandsall.customer.services; 2 | 3 | import com.rolandsall.customer.models.Customer; 4 | 5 | public interface INotificationHandler { 6 | void publish(Customer customer); 7 | } 8 | -------------------------------------------------------------------------------- /microservices/microservice-full-example/microservices/customer/src/main/resources/application-docker.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 8080 3 | 4 | spring: 5 | application: 6 | name: customer 7 | datasource: 8 | password: 'password' 9 | url: jdbc:postgresql://postgres:5432/customer 10 | username: 'rolandsall' 11 | jpa: 12 | hibernate: 13 | ddl-auto: create-drop 14 | properties: 15 | hibernate: 16 | dialect: org.hibernate.dialect.PostgreSQLDialect 17 | format_sql: true 18 | show-sql: true 19 | mvc: 20 | pathmatch: 21 | matching-strategy: ant_path_matcher 22 | zipkin: 23 | base-url: http://zipkin:9411 24 | rabbitmq: 25 | addresses: rabbitmq:5672 26 | 27 | eureka: 28 | client: 29 | service-url: 30 | defaultZone: 'http://eureka-service:8761/eureka' -------------------------------------------------------------------------------- /microservices/microservice-full-example/microservices/customer/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 8080 3 | 4 | spring: 5 | application: 6 | name: customer 7 | datasource: 8 | password: 'password' 9 | url: jdbc:postgresql://localhost:5432/customer 10 | username: 'rolandsall' 11 | jpa: 12 | hibernate: 13 | ddl-auto: create-drop 14 | properties: 15 | hibernate: 16 | dialect: org.hibernate.dialect.PostgreSQLDialect 17 | format_sql: true 18 | show-sql: true 19 | mvc: 20 | pathmatch: 21 | matching-strategy: ant_path_matcher 22 | zipkin: 23 | base-url: http://localhost:9411 24 | rabbitmq: 25 | addresses: localhost:5672 26 | 27 | eureka: 28 | client: 29 | service-url: 30 | defaultZone: 'http://localhost:8761/eureka' -------------------------------------------------------------------------------- /microservices/microservice-full-example/microservices/customer/src/main/resources/banner.txt: -------------------------------------------------------------------------------- 1 | ___ _ ___ _ 2 | / __| _ _ ___ | |_ ___ _ __ ___ _ _ / __| ___ _ _ __ __ (_) __ ___ 3 | | (__ | || | (_-< | _| / _ \ | ' \ / -_) | '_| \__ \ / -_) | '_| \ V / | | / _| / -_) 4 | \___| \_,_| /__/ \__| \___/ |_|_|_| \___| |_| |___/ \___| |_| \_/ |_| \__| \___| 5 | 6 | -------------------------------------------------------------------------------- /microservices/microservice-full-example/microservices/customer/src/test/resources/application.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 8081 3 | 4 | 5 | spring: 6 | application: 7 | name: customer 8 | datasource: 9 | password: 'sa' 10 | url: jdbc:h2:mem:testdb 11 | username: 'password' 12 | driver-class-name: org.h2.Driver 13 | jpa: 14 | hibernate: 15 | ddl-auto: create-drop 16 | properties: 17 | hibernate: 18 | dialect: org.hibernate.dialect.H2Dialect 19 | format_sql: true 20 | show-sql: true 21 | mvc: 22 | pathmatch: 23 | matching-strategy: ant_path_matcher 24 | 25 | h2: 26 | console: 27 | enabled: true -------------------------------------------------------------------------------- /microservices/microservice-full-example/microservices/delete_unused_images.sh: -------------------------------------------------------------------------------- 1 | docker rmi $(docker images | grep "none" | awk '{print $3}') 2 | -------------------------------------------------------------------------------- /microservices/microservice-full-example/microservices/discovery/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM eclipse-temurin:11 2 | ADD target/discovery-1.0-SNAPSHOT.jar discovery-1.0-SNAPSHOT.jar 3 | EXPOSE 8080 4 | ENTRYPOINT ["java","-jar","discovery-1.0-SNAPSHOT.jar"] -------------------------------------------------------------------------------- /microservices/microservice-full-example/microservices/discovery/src/main/java/com/rolandsall/discovery/DiscoveryMainApplication.java: -------------------------------------------------------------------------------- 1 | package com.rolandsall.discovery; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer; 6 | 7 | @SpringBootApplication 8 | @EnableEurekaServer 9 | public class DiscoveryMainApplication 10 | { 11 | public static void main( String[] args ) 12 | { 13 | SpringApplication.run(DiscoveryMainApplication.class, args); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /microservices/microservice-full-example/microservices/discovery/src/main/resources/application-docker.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 8761 3 | 4 | eureka: 5 | client: 6 | register-with-eureka: false 7 | fetch-registry: false 8 | spring: 9 | application: 10 | name: discovery-service 11 | zipkin: 12 | base-url: http://zipkin:9411 13 | 14 | -------------------------------------------------------------------------------- /microservices/microservice-full-example/microservices/discovery/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 8761 3 | 4 | eureka: 5 | client: 6 | register-with-eureka: false 7 | fetch-registry: false 8 | spring: 9 | application: 10 | name: discovery-service 11 | zipkin: 12 | base-url: http://localhost:9411 13 | 14 | -------------------------------------------------------------------------------- /microservices/microservice-full-example/microservices/discovery/src/main/resources/banner.txt: -------------------------------------------------------------------------------- 1 | ,------. ,--. ,---. ,--. 2 | | .-. \ `--' ,---. ,---. ,---. ,--. ,--. ,---. ,--.--. ,--. ,--. ' .-' ,---. ,--.--. ,--. ,--. `--' ,---. ,---. 3 | | | \ : ,--. ( .-' | .-. | | .--' \ `' / | .-. : | .--' \ ' / `. `-. | .-. : | .--' \ `' / ,--. | .--' | .-. : 4 | | '--' / | | .-' `) ' '-' ' \ `--. \ / \ --. | | \ ' .-' | \ --. | | \ / | | \ `--. \ --. 5 | `-------' `--' `----' `---' `---' `--' `----' `--' .-' / `-----' `----' `--' `--' `--' `---' `----' -------------------------------------------------------------------------------- /microservices/microservice-full-example/microservices/fraud/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM eclipse-temurin:11 2 | ADD target/fraud-1.0-SNAPSHOT.jar fraud-1.0-SNAPSHOT.jar 3 | EXPOSE 8080 4 | ENTRYPOINT ["java","-jar","fraud-1.0-SNAPSHOT.jar"] -------------------------------------------------------------------------------- /microservices/microservice-full-example/microservices/fraud/src/main/java/com/rolandsall/fraud/FraudMainApplication.java: -------------------------------------------------------------------------------- 1 | package com.rolandsall.fraud; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.cloud.netflix.eureka.EnableEurekaClient; 6 | 7 | @SpringBootApplication 8 | @EnableEurekaClient 9 | public class FraudMainApplication { 10 | public static void main(String[] args) { 11 | SpringApplication.run(FraudMainApplication.class, args); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /microservices/microservice-full-example/microservices/fraud/src/main/java/com/rolandsall/fraud/SwaggerConfig.java: -------------------------------------------------------------------------------- 1 | package com.rolandsall.fraud; 2 | 3 | import org.springframework.context.annotation.Bean; 4 | import org.springframework.context.annotation.Configuration; 5 | import springfox.documentation.builders.PathSelectors; 6 | import springfox.documentation.builders.RequestHandlerSelectors; 7 | import springfox.documentation.spi.DocumentationType; 8 | import springfox.documentation.spring.web.plugins.Docket; 9 | import springfox.documentation.swagger2.annotations.EnableSwagger2; 10 | 11 | @Configuration 12 | @EnableSwagger2 13 | public class SwaggerConfig { 14 | 15 | @Bean 16 | public Docket api() { 17 | return new Docket(DocumentationType.SWAGGER_2) 18 | .select() 19 | .apis(RequestHandlerSelectors.any()) 20 | .paths(PathSelectors.any()) 21 | .build(); 22 | } 23 | } -------------------------------------------------------------------------------- /microservices/microservice-full-example/microservices/fraud/src/main/java/com/rolandsall/fraud/models/FraudCheckHistory.java: -------------------------------------------------------------------------------- 1 | package com.rolandsall.fraud.models; 2 | 3 | 4 | import lombok.AllArgsConstructor; 5 | import lombok.Builder; 6 | import lombok.Data; 7 | import lombok.NoArgsConstructor; 8 | 9 | import javax.persistence.Entity; 10 | import javax.persistence.Id; 11 | import java.time.LocalDateTime; 12 | import java.util.UUID; 13 | 14 | @NoArgsConstructor 15 | @AllArgsConstructor 16 | @Entity 17 | @Data 18 | @Builder 19 | public class FraudCheckHistory { 20 | 21 | @Id 22 | public UUID id; 23 | private UUID customerId; 24 | private boolean isFraud; 25 | private LocalDateTime createdAt; 26 | } 27 | -------------------------------------------------------------------------------- /microservices/microservice-full-example/microservices/fraud/src/main/java/com/rolandsall/fraud/repositories/FraudCheckHistoryRepository.java: -------------------------------------------------------------------------------- 1 | package com.rolandsall.fraud.repositories; 2 | 3 | import com.rolandsall.fraud.models.FraudCheckHistory; 4 | import org.springframework.data.jpa.repository.JpaRepository; 5 | 6 | import java.util.UUID; 7 | 8 | public interface FraudCheckHistoryRepository extends JpaRepository { 9 | } 10 | -------------------------------------------------------------------------------- /microservices/microservice-full-example/microservices/fraud/src/main/java/com/rolandsall/fraud/services/IFraudCheckService.java: -------------------------------------------------------------------------------- 1 | package com.rolandsall.fraud.services; 2 | 3 | import java.util.UUID; 4 | 5 | public interface IFraudCheckService { 6 | 7 | public boolean isFraudCustomer(UUID customerId); 8 | 9 | } 10 | -------------------------------------------------------------------------------- /microservices/microservice-full-example/microservices/fraud/src/main/resources/application-docker.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 8081 3 | 4 | 5 | spring: 6 | application: 7 | name: fraud 8 | datasource: 9 | password: 'password' 10 | url: jdbc:postgresql://postgres-fraud:5432/fraud 11 | username: 'rolandsall' 12 | jpa: 13 | hibernate: 14 | ddl-auto: create-drop 15 | properties: 16 | hibernate: 17 | dialect: org.hibernate.dialect.PostgreSQLDialect 18 | format_sql: true 19 | show-sql: true 20 | generate-ddl: true 21 | mvc: 22 | pathmatch: 23 | matching-strategy: ant_path_matcher 24 | zipkin: 25 | base-url: http://zipkin:9411 26 | 27 | eureka: 28 | client: 29 | service-url: 30 | defaultZone: 'http://eureka-service:8761/eureka' 31 | -------------------------------------------------------------------------------- /microservices/microservice-full-example/microservices/fraud/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 8081 3 | 4 | 5 | spring: 6 | application: 7 | name: fraud 8 | datasource: 9 | password: 'password' 10 | url: jdbc:postgresql://localhost:5433/fraud 11 | username: 'rolandsall' 12 | jpa: 13 | hibernate: 14 | ddl-auto: create-drop 15 | properties: 16 | hibernate: 17 | dialect: org.hibernate.dialect.PostgreSQLDialect 18 | format_sql: true 19 | show-sql: true 20 | generate-ddl: true 21 | mvc: 22 | pathmatch: 23 | matching-strategy: ant_path_matcher 24 | zipkin: 25 | base-url: http://localhost:9411 26 | 27 | eureka: 28 | client: 29 | service-url: 30 | defaultZone: 'http://localhost:8761/eureka' 31 | -------------------------------------------------------------------------------- /microservices/microservice-full-example/microservices/fraud/src/main/resources/banner.txt: -------------------------------------------------------------------------------- 1 | ,------. ,--. ,---. ,--. 2 | | .---' ,--.--. ,--,--. ,--.,--. ,-| | ' .-' ,---. ,--.--. ,--. ,--. `--' ,---. ,---. 3 | | `--, | .--' ' ,-. | | || | ' .-. | `. `-. | .-. : | .--' \ `' / ,--. | .--' | .-. : 4 | | |` | | \ '-' | ' '' ' \ `-' | .-' | \ --. | | \ / | | \ `--. \ --. 5 | `--' `--' `--`--' `----' `---' `-----' `----' `--' `--' `--' `---' `----' 6 | -------------------------------------------------------------------------------- /microservices/microservice-full-example/microservices/gateway/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM eclipse-temurin:11 2 | ADD target/gateway-1.0-SNAPSHOT.jar gateway-1.0-SNAPSHOT.jar 3 | EXPOSE 8080 4 | ENTRYPOINT ["java","-jar","gateway-1.0-SNAPSHOT.jar"] -------------------------------------------------------------------------------- /microservices/microservice-full-example/microservices/gateway/src/main/java/com/rolandsall/gateway/GatewayMainApplication.java: -------------------------------------------------------------------------------- 1 | package com.rolandsall.gateway; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.cloud.netflix.eureka.EnableEurekaClient; 6 | 7 | @SpringBootApplication 8 | @EnableEurekaClient 9 | public class GatewayMainApplication 10 | { 11 | public static void main( String[] args ) 12 | { 13 | SpringApplication.run(GatewayMainApplication.class, args); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /microservices/microservice-full-example/microservices/gateway/src/main/resources/application-docker.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 8083 3 | 4 | spring: 5 | application: 6 | name: gateway 7 | zipkin: 8 | base-url: 'http://zipkin:9411' 9 | cloud: 10 | gateway: 11 | routes: 12 | - id: customer 13 | uri: lb://CUSTOMER 14 | predicates: 15 | - Path=/api/v1/customers/** 16 | 17 | 18 | eureka: 19 | client: 20 | service-url: 21 | defaultZone: 'http://eureka-service:8761/eureka' 22 | -------------------------------------------------------------------------------- /microservices/microservice-full-example/microservices/gateway/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 8083 3 | 4 | spring: 5 | application: 6 | name: gateway 7 | zipkin: 8 | base-url: 'http://localhost:9411' 9 | cloud: 10 | gateway: 11 | routes: 12 | - id: customer 13 | uri: lb://CUSTOMER 14 | predicates: 15 | - Path=/api/v1/customers/** 16 | 17 | 18 | eureka: 19 | client: 20 | service-url: 21 | defaultZone: 'http://localhost:8761/eureka' 22 | -------------------------------------------------------------------------------- /microservices/microservice-full-example/microservices/gateway/src/main/resources/banner.txt: -------------------------------------------------------------------------------- 1 | ,----. ,---. ,--------. ,------. ,--. ,--. ,---. ,--. ,--. ,---. ,------. ,------. ,--. ,--. ,--. ,-----. ,------. 2 | ' .-./ / O \ '--. .--' | .---' | | | | / O \ \ `.' / ' .-' | .---' | .--. ' \ `.' / | | ' .--./ | .---' 3 | | | .---. | .-. | | | | `--, | |.'.| | | .-. | '. / `. `-. | `--, | '--'.' \ / | | | | | `--, 4 | ' '--' | | | | | | | | `---. | ,'. | | | | | | | .-' | | `---. | |\ \ \ / | | ' '--'\ | `---. 5 | `------' `--' `--' `--' `------' '--' '--' `--' `--' `--' `-----' `------' `--' '--' `-' `--' `-----' `------' -------------------------------------------------------------------------------- /microservices/microservice-full-example/microservices/notification/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM eclipse-temurin:11 2 | ADD target/notification-1.0-SNAPSHOT.jar notification-1.0-SNAPSHOT.jar 3 | EXPOSE 8080 4 | ENTRYPOINT ["java","-jar","notification-1.0-SNAPSHOT.jar"] -------------------------------------------------------------------------------- /microservices/microservice-full-example/microservices/notification/src/main/java/com/rolandsall/notification/SwaggerConfig.java: -------------------------------------------------------------------------------- 1 | package com.rolandsall.notification; 2 | 3 | import org.springframework.context.annotation.Bean; 4 | import org.springframework.context.annotation.Configuration; 5 | import springfox.documentation.builders.PathSelectors; 6 | import springfox.documentation.builders.RequestHandlerSelectors; 7 | import springfox.documentation.spi.DocumentationType; 8 | import springfox.documentation.spring.web.plugins.Docket; 9 | import springfox.documentation.swagger2.annotations.EnableSwagger2; 10 | 11 | @Configuration 12 | @EnableSwagger2 13 | public class SwaggerConfig { 14 | 15 | @Bean 16 | public Docket api() { 17 | return new Docket(DocumentationType.SWAGGER_2) 18 | .select() 19 | .apis(RequestHandlerSelectors.any()) 20 | .paths(PathSelectors.any()) 21 | .build(); 22 | } 23 | } -------------------------------------------------------------------------------- /microservices/microservice-full-example/microservices/notification/src/main/java/com/rolandsall/notification/models/Notification.java: -------------------------------------------------------------------------------- 1 | package com.rolandsall.notification.models; 2 | 3 | import lombok.*; 4 | 5 | import javax.persistence.Entity; 6 | import javax.persistence.Id; 7 | import java.time.LocalDateTime; 8 | import java.util.UUID; 9 | 10 | @Entity 11 | @Builder 12 | @AllArgsConstructor 13 | @NoArgsConstructor 14 | @Getter 15 | @Setter 16 | @ToString 17 | public class Notification { 18 | 19 | @Id 20 | private UUID notificationId; 21 | private UUID toCustomerId; 22 | private String toCustomerEmail; 23 | private String sender; 24 | private String message; 25 | private LocalDateTime sentAt; 26 | } 27 | -------------------------------------------------------------------------------- /microservices/microservice-full-example/microservices/notification/src/main/java/com/rolandsall/notification/repositories/INotificationRepository.java: -------------------------------------------------------------------------------- 1 | package com.rolandsall.notification.repositories; 2 | 3 | import com.rolandsall.notification.models.Notification; 4 | import org.springframework.data.jpa.repository.JpaRepository; 5 | 6 | import java.util.UUID; 7 | 8 | public interface INotificationRepository extends JpaRepository { 9 | } 10 | -------------------------------------------------------------------------------- /microservices/microservice-full-example/microservices/notification/src/main/java/com/rolandsall/notification/services/INotificationService.java: -------------------------------------------------------------------------------- 1 | package com.rolandsall.notification.services; 2 | 3 | import com.rolandsall.notification.models.Notification; 4 | 5 | public interface INotificationService { 6 | void send(Notification notification); 7 | } 8 | -------------------------------------------------------------------------------- /microservices/microservice-full-example/microservices/notification/src/main/resources/banner.txt: -------------------------------------------------------------------------------- 1 | ,--. ,--. ,--. ,--. ,---. ,--. ,--. ,--. ,---. ,--. 2 | | ,'.| | ,---. ,-' '-. `--' / .-' `--' ,---. ,--,--. ,-' '-. `--' ,---. ,--,--, ' .-' ,---. ,--.--. ,--. ,--. `--' ,---. ,---. 3 | | |' ' | | .-. | '-. .-' ,--. | `-, ,--. | .--' ' ,-. | '-. .-' ,--. | .-. | | \ `. `-. | .-. : | .--' \ `' / ,--. | .--' | .-. : 4 | | | ` | ' '-' ' | | | | | .-' | | \ `--. \ '-' | | | | | ' '-' ' | || | .-' | \ --. | | \ / | | \ `--. \ --. 5 | `--' `--' `---' `--' `--' `--' `--' `---' `--`--' `--' `--' `---' `--''--' `-----' `----' `--' `--' `--' `---' `----' 6 | -------------------------------------------------------------------------------- /microservices/microservice-full-example/microservices/test.sh: -------------------------------------------------------------------------------- 1 | curl -X POST "http://localhost:8083/api/v1/customers" -H "accept: */*" -H "Content-Type: application/json" -d "{ \"email\": \"string\", \"firstName\": \"string\", \"lastName\": \"string\"}" -------------------------------------------------------------------------------- /object-oriented-design/java/call-center/README.md: -------------------------------------------------------------------------------- 1 | # Problem 2 | 3 | Call Center: Imagine you have a call center with three levels of employees: respondent, manager, 4 | and director. An incoming telephone call must be first allocated to a respondent who is free. If the 5 | respondent can't handle the call, he or she must escalate the call to a manager. If the manager is not 6 | free or not able to handle it, then the call should be escalated to a director. Design the classes and 7 | data structures for this problem. Implement a method dispatchCall () which assigns a call to 8 | the first available employee. -------------------------------------------------------------------------------- /object-oriented-design/java/call-center/src/Call.java: -------------------------------------------------------------------------------- 1 | package PACKAGE_NAME;public class Call { 2 | } 3 | -------------------------------------------------------------------------------- /object-oriented-design/java/call-center/src/CallHandler.java: -------------------------------------------------------------------------------- 1 | package PACKAGE_NAME;public class CallHandler { 2 | } 3 | -------------------------------------------------------------------------------- /object-oriented-design/java/call-center/src/Domain/BaseEmployee.java: -------------------------------------------------------------------------------- 1 | package Domain;public class BaseEmployee { 2 | } 3 | -------------------------------------------------------------------------------- /object-oriented-design/java/deck-of-cards/README.md: -------------------------------------------------------------------------------- 1 | # Problem 2 | 3 | Deck of Cards: Design the data structures for a generic deck of cards. Explain how you would 4 | subclass the data structures to implement blackjack. -------------------------------------------------------------------------------- /object-oriented-design/java/deck-of-cards/src/BlackJackCard.java: -------------------------------------------------------------------------------- 1 | public class BlackJackCard extends Card{ 2 | 3 | public BlackJackCard(int faceValue, Suit suit) { 4 | super(faceValue, suit); 5 | } 6 | 7 | @Override 8 | public int value() { 9 | // logic how to calculate 10 | return 0; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /object-oriented-design/java/deck-of-cards/src/Card.java: -------------------------------------------------------------------------------- 1 | public abstract class Card { 2 | 3 | private boolean available = true; 4 | 5 | protected int faceValue; 6 | protected Suit suit; 7 | 8 | public Card(int faceValue, Suit suit) { 9 | this.faceValue = faceValue; 10 | this.suit = suit; 11 | } 12 | 13 | public abstract int value(); 14 | 15 | 16 | public Suit getSuit() { 17 | return suit; 18 | } 19 | 20 | public boolean isAvailable() { 21 | return available; 22 | } 23 | 24 | public void makeAvailable(){ 25 | available = true; 26 | } 27 | 28 | public void makeUnavailable(){ 29 | available = false; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /object-oriented-design/java/deck-of-cards/src/Deck.java: -------------------------------------------------------------------------------- 1 | import java.util.ArrayList; 2 | import java.util.Collections; 3 | 4 | public class Deck { 5 | 6 | ArrayList cards; 7 | private int dealIndex = 0; 8 | 9 | 10 | public void shuffle(){ 11 | Collections.shuffle(cards); 12 | } 13 | 14 | 15 | } 16 | -------------------------------------------------------------------------------- /object-oriented-design/java/deck-of-cards/src/Hand.java: -------------------------------------------------------------------------------- 1 | import java.util.ArrayList; 2 | 3 | public class Hand { 4 | 5 | private ArrayList handCards = new ArrayList(); 6 | 7 | 8 | public int score(){ 9 | int score =0; 10 | 11 | for(T card: handCards){ 12 | score += card.value(); 13 | } 14 | 15 | return score; 16 | } 17 | 18 | 19 | public void addCard(T card){ 20 | handCards.add(card); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /object-oriented-design/java/deck-of-cards/src/Suit.java: -------------------------------------------------------------------------------- 1 | public enum Suit { 2 | 3 | Club, 4 | Diamond, 5 | Heart, 6 | Spade 7 | 8 | 9 | } 10 | -------------------------------------------------------------------------------- /object-oriented-design/java/deck-of-cards/src/main.java: -------------------------------------------------------------------------------- 1 | public class main { 2 | public static void main(String[] args) { 3 | 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /object-oriented-design/java/library-management-system/main/README.md: -------------------------------------------------------------------------------- 1 | # Problem 2 | 3 | Manage a library system where users can borrow or buy items from the library. 4 | the library system is always updated by new books by the staff. 5 | you can rent a book for a certain period n and you cannot have more than m books rented at the same time 6 | if a user does not return a book a n duration he or she should pay a fine. 7 | 8 | if the user have a subscription the fine will be 9 | different then a user has does not have subscription. the fine also depend on the user fine renting history. 10 | If a user get fined more than x amount time he is not allowed to borrow books, he is only allow to buy books. 11 | 12 | books also have copies, that are normally kept tracked for. the books are stored on rack to directly identify 13 | their location. 14 | 15 | you can search for a book by its name, category or author name -------------------------------------------------------------------------------- /object-oriented-design/java/library-management-system/main/src/Entities/Location.java: -------------------------------------------------------------------------------- 1 | package Entities; 2 | 3 | public class Location { 4 | int latitude; 5 | int longitude; 6 | 7 | 8 | public Location(int latitude, int longitude) { 9 | this.latitude = latitude; 10 | this.longitude = longitude; 11 | } 12 | 13 | 14 | } -------------------------------------------------------------------------------- /object-oriented-design/java/library-management-system/main/src/Entities/Rack.java: -------------------------------------------------------------------------------- 1 | package Entities; 2 | 3 | public class Rack { 4 | private int floorNumber; 5 | private int rackNumber; 6 | 7 | public Rack(int floorNumber, int rackNumber) { 8 | this.floorNumber = floorNumber; 9 | this.rackNumber = rackNumber; 10 | } 11 | 12 | public int getFloorNumber() { 13 | return floorNumber; 14 | } 15 | 16 | public void setFloorNumber(int floorNumber) { 17 | this.floorNumber = floorNumber; 18 | } 19 | 20 | public int getRackNumber() { 21 | return rackNumber; 22 | } 23 | 24 | public void setRackNumber(int rackNumber) { 25 | this.rackNumber = rackNumber; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /object-oriented-design/java/library-management-system/main/src/Entities/RentedBooks.java: -------------------------------------------------------------------------------- 1 | package Entities; 2 | 3 | import java.util.Date; 4 | 5 | public class RentedBooks { 6 | private BookItem book; 7 | private Client client; 8 | private Date rentedDate; 9 | private Date returnedDate; 10 | 11 | } 12 | -------------------------------------------------------------------------------- /object-oriented-design/java/library-management-system/main/src/Entities/Staff.java: -------------------------------------------------------------------------------- 1 | package Entities; 2 | 3 | public abstract class Staff { 4 | 5 | int id; 6 | String firstName; 7 | String lastName; 8 | String email; 9 | 10 | public Staff(int id, String firstName, String lastName, String email) { 11 | this.id = id; 12 | this.firstName = firstName; 13 | this.lastName = lastName; 14 | this.email = email; 15 | } 16 | 17 | public abstract void Greet(); 18 | 19 | public void addBook(Library library, Book book) { 20 | library.getBookList().add(book); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /object-oriented-design/java/library-management-system/main/src/Enums/BookCategory.java: -------------------------------------------------------------------------------- 1 | package Enums; 2 | 3 | public enum BookCategory { 4 | Drama, 5 | Documentary, 6 | Fictional 7 | } 8 | 9 | -------------------------------------------------------------------------------- /object-oriented-design/java/library-management-system/main/src/Services/ILibraryService.java: -------------------------------------------------------------------------------- 1 | package Services; 2 | 3 | import Entities.Book; 4 | import Entities.Library; 5 | import Entities.Staff; 6 | 7 | public interface ILibraryService { 8 | void addBook(Library library, Staff staff, Book book); 9 | } 10 | -------------------------------------------------------------------------------- /object-oriented-design/java/library-management-system/main/src/Services/LibraryService.java: -------------------------------------------------------------------------------- 1 | package Services; 2 | 3 | import Entities.Book; 4 | import Entities.Library; 5 | import Entities.Staff; 6 | 7 | public class LibraryService implements ILibraryService{ 8 | 9 | 10 | @Override 11 | public void addBook(Library library, Staff staff, Book book) { 12 | staff.addBook(library, book); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /object-oriented-design/java/music-player-v2-simplified/README.md: -------------------------------------------------------------------------------- 1 | # Problem 2 | 3 | We have to design a music player with the following functionalities: 4 | 5 | Add a song to the music player. 6 | Play a random song from music player such those same songs are not repeated consecutively. 7 | Play a particular song. -------------------------------------------------------------------------------- /object-oriented-design/java/music-player/README.md: -------------------------------------------------------------------------------- 1 | Write the code for a music player application : 2 | the user should be able to browse song 3 | -> list of all available songs on the platform 4 | --> name of artist of the song 5 | 6 | artist can publish songs to the platform. 7 | 8 | 9 | create his own playlist from songs 10 | --> maximum number of a playlist is 100 11 | 12 | 13 | a user should be able to play a list in an shuffle mode or normal order and should be able to shuffle at anytime while playing music 14 | 15 | pause play songs -------------------------------------------------------------------------------- /object-oriented-design/java/music-player/src/DTOs/CreateSingerDto.java: -------------------------------------------------------------------------------- 1 | package DTOs; 2 | 3 | public class CreateSingerDto { 4 | private String firstName; 5 | private String lastName; 6 | 7 | public CreateSingerDto(String firstName, String lastName) { 8 | this.firstName = firstName; 9 | this.lastName = lastName; 10 | } 11 | 12 | public String getFirstName() { 13 | return firstName; 14 | } 15 | 16 | 17 | public String getLastName() { 18 | return lastName; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /object-oriented-design/java/music-player/src/DTOs/CreateSongDto.java: -------------------------------------------------------------------------------- 1 | package DTOs; 2 | 3 | import entities.Singer; 4 | 5 | import java.util.List; 6 | 7 | public class CreateSongDto { 8 | private String name; 9 | private List singers; 10 | 11 | public CreateSongDto(String name, List singers) { 12 | this.name = name; 13 | this.singers = singers; 14 | } 15 | 16 | public String getName() { 17 | return name; 18 | } 19 | 20 | public List getSingers() { 21 | return singers; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /object-oriented-design/java/music-player/src/DTOs/CreateUserDto.java: -------------------------------------------------------------------------------- 1 | package DTOs; 2 | 3 | public class CreateUserDto { 4 | private String firstName; 5 | private String lastName; 6 | 7 | public CreateUserDto(String firstName, String lastName) { 8 | this.firstName = firstName; 9 | this.lastName = lastName; 10 | } 11 | 12 | public String getFirstName() { 13 | return firstName; 14 | } 15 | 16 | public String getLastName() { 17 | return lastName; 18 | } 19 | 20 | 21 | } 22 | -------------------------------------------------------------------------------- /object-oriented-design/java/music-player/src/Strategy/IShuffleBehaviour.java: -------------------------------------------------------------------------------- 1 | package Strategy; 2 | 3 | import entities.PlayList; 4 | 5 | public interface IShuffleBehaviour { 6 | 7 | public void shuffle(PlayList playList); 8 | } 9 | -------------------------------------------------------------------------------- /object-oriented-design/java/music-player/src/Strategy/NormalShuffleBehavior.java: -------------------------------------------------------------------------------- 1 | package Strategy; 2 | 3 | import entities.PlayList; 4 | 5 | public class NormalShuffleBehavior implements IShuffleBehaviour{ 6 | 7 | @Override 8 | public void shuffle(PlayList playList) { 9 | 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /object-oriented-design/java/music-player/src/Strategy/RandomShuffleBehavior.java: -------------------------------------------------------------------------------- 1 | package Strategy; 2 | 3 | import entities.PlayList; 4 | 5 | import java.util.Collections; 6 | import java.util.List; 7 | 8 | public class RandomShuffleBehavior implements IShuffleBehaviour 9 | { 10 | @Override 11 | public void shuffle(PlayList playList) { 12 | Collections.shuffle((List) playList); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /object-oriented-design/java/music-player/src/entities/EmailNotification.java: -------------------------------------------------------------------------------- 1 | package entities; 2 | 3 | import java.util.UUID; 4 | 5 | public class EmailNotification extends Notification{ 6 | private String content; 7 | 8 | public EmailNotification(String content) { 9 | super(UUID.randomUUID(),false); 10 | this.content = content; 11 | } 12 | 13 | @Override 14 | public String toString() { 15 | 16 | return super.toString() + " EmailNotification{" + 17 | "content='" + content + '\'' + 18 | '}'; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /object-oriented-design/java/music-player/src/entities/Notification.java: -------------------------------------------------------------------------------- 1 | package entities; 2 | 3 | import java.util.UUID; 4 | 5 | public abstract class Notification { 6 | 7 | private UUID id; 8 | private boolean read; 9 | 10 | public Notification(UUID id, boolean read) { 11 | this.id = id; 12 | this.read = read; 13 | } 14 | 15 | public UUID getId() { 16 | return id; 17 | } 18 | 19 | public boolean isRead() { 20 | return read; 21 | } 22 | 23 | public void read(){ 24 | this.read = true; 25 | } 26 | 27 | @Override 28 | public String toString() { 29 | return "Notification{" + 30 | "id=" + id + 31 | ", read=" + read + 32 | '}'; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /object-oriented-design/java/music-player/src/entities/Pool.java: -------------------------------------------------------------------------------- 1 | package entities; 2 | 3 | import java.util.HashMap; 4 | import java.util.List; 5 | 6 | public class Pool { 7 | 8 | private List songs; 9 | private List singers; 10 | 11 | private HashMap> singerHashMap; 12 | 13 | public void addSong(Song song){ 14 | // you add songs to the pool 15 | 16 | 17 | Singer singer = song.getSingers().get(0); 18 | List singersSongs = singerHashMap.get(singer); 19 | singersSongs.add(song); 20 | } 21 | 22 | 23 | } 24 | -------------------------------------------------------------------------------- /object-oriented-design/java/music-player/src/entities/Song.java: -------------------------------------------------------------------------------- 1 | package entities; 2 | 3 | import java.util.List; 4 | import java.util.UUID; 5 | 6 | public class Song { 7 | 8 | private UUID id; 9 | private String name; 10 | private List singers; 11 | 12 | public Song(UUID id ,String name, List singers) { 13 | this.id = id; 14 | this.name = name; 15 | this.singers = singers; 16 | } 17 | 18 | public UUID getId() { 19 | return id; 20 | } 21 | 22 | public String getName() { 23 | return name; 24 | } 25 | 26 | public List getSingers() { 27 | return singers; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /object-oriented-design/java/music-player/src/entities/User.java: -------------------------------------------------------------------------------- 1 | package entities; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | import java.util.UUID; 6 | 7 | public class User extends BaseUser { 8 | 9 | public User(UUID id, String firstName, String lastName) { 10 | super(id, firstName, lastName); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /object-oriented-design/java/music-player/src/repos/IMusicSystemDbContext.java: -------------------------------------------------------------------------------- 1 | package repos; 2 | 3 | import DTOs.CreateSingerDto; 4 | import DTOs.CreateSongDto; 5 | import DTOs.CreateUserDto; 6 | import entities.Singer; 7 | import entities.Song; 8 | import entities.User; 9 | 10 | 11 | public interface IMusicSystemDbContext { 12 | 13 | User registerAsUser(CreateUserDto createUserDto); 14 | 15 | Singer registerAsSinger(CreateSingerDto createSingerDto); 16 | 17 | Song saveSong(CreateSongDto song); 18 | 19 | 20 | Song browseBySingerName(String name); 21 | 22 | Song browseBySongName(String name); 23 | } 24 | -------------------------------------------------------------------------------- /object-oriented-design/java/music-player/src/services/browse/BrowseService.java: -------------------------------------------------------------------------------- 1 | package services.browse; 2 | 3 | import entities.Song; 4 | import repos.IMusicSystemDbContext; 5 | 6 | public class BrowseService implements IBrowseService{ 7 | 8 | 9 | private IMusicSystemDbContext iMusicSystemDbContext; 10 | 11 | public BrowseService(IMusicSystemDbContext iMusicSystemDbContext) { 12 | this.iMusicSystemDbContext = iMusicSystemDbContext; 13 | } 14 | 15 | @Override 16 | public Song browseBySingerName(String name) { 17 | return iMusicSystemDbContext.browseBySingerName(name); 18 | } 19 | 20 | @Override 21 | public Song browseByName(String name) { 22 | return iMusicSystemDbContext.browseBySongName(name); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /object-oriented-design/java/music-player/src/services/browse/IBrowseService.java: -------------------------------------------------------------------------------- 1 | package services.browse; 2 | 3 | import entities.Song; 4 | 5 | public interface IBrowseService { 6 | 7 | Song browseBySingerName(String name); 8 | 9 | Song browseByName(String name); 10 | 11 | } 12 | -------------------------------------------------------------------------------- /object-oriented-design/java/music-player/src/services/notfication/INotificationManager.java: -------------------------------------------------------------------------------- 1 | package services.notfication; 2 | 3 | import entities.Singer; 4 | import entities.Song; 5 | 6 | import java.util.List; 7 | 8 | public interface INotificationManager { 9 | 10 | 11 | public void removedSongNotify(List singers, Song song); 12 | 13 | void addSongNotify(List singers, Song song); 14 | } 15 | -------------------------------------------------------------------------------- /object-oriented-design/java/music-player/src/services/playList/IPlayListService.java: -------------------------------------------------------------------------------- 1 | package services.playList; 2 | 3 | import entities.PlayList; 4 | import entities.Song; 5 | 6 | public interface IPlayListService { 7 | 8 | void addSong(PlayList user, Song song); 9 | 10 | 11 | void removeSong(PlayList playList, Song song); 12 | } 13 | -------------------------------------------------------------------------------- /object-oriented-design/java/music-player/src/services/playList/PlayListService.java: -------------------------------------------------------------------------------- 1 | package services.playList; 2 | 3 | import entities.PlayList; 4 | import entities.Song; 5 | import repos.IMusicSystemDbContext; 6 | import services.notfication.INotificationManager; 7 | import services.notfication.NotificationManager; 8 | 9 | public class PlayListService implements IPlayListService{ 10 | 11 | private INotificationManager notificationManager; 12 | 13 | public PlayListService() { 14 | this.notificationManager = new NotificationManager(); 15 | } 16 | 17 | @Override 18 | public void addSong(PlayList playList, Song song) { 19 | playList.addSong(song); 20 | notificationManager.addSongNotify(song.getSingers(), song); 21 | 22 | } 23 | 24 | @Override 25 | public void removeSong(PlayList playList, Song song) { 26 | playList.removeSong(song); 27 | notificationManager.removedSongNotify(song.getSingers(), song); 28 | 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /object-oriented-design/java/music-player/src/services/registration/IRegistrationService.java: -------------------------------------------------------------------------------- 1 | package services.registration; 2 | 3 | import DTOs.CreateSingerDto; 4 | import DTOs.CreateUserDto; 5 | import entities.BaseUser; 6 | import entities.Singer; 7 | import entities.User; 8 | 9 | public interface IRegistrationService { 10 | 11 | public User registerAsUser(CreateUserDto createUserDto); 12 | public Singer registerAsSinger(CreateSingerDto createSingerDto); 13 | } 14 | -------------------------------------------------------------------------------- /object-oriented-design/java/music-player/src/services/registration/RegistrationService.java: -------------------------------------------------------------------------------- 1 | package services.registration; 2 | 3 | import DTOs.CreateSingerDto; 4 | import DTOs.CreateUserDto; 5 | import entities.Singer; 6 | import entities.User; 7 | import repos.IMusicSystemDbContext; 8 | 9 | public class RegistrationService implements IRegistrationService{ 10 | 11 | private IMusicSystemDbContext iMusicSystemDbContext; 12 | 13 | public RegistrationService(IMusicSystemDbContext iMusicSystemDbContext) { 14 | this.iMusicSystemDbContext = iMusicSystemDbContext; 15 | } 16 | 17 | @Override 18 | public User registerAsUser(CreateUserDto createUserDto) { 19 | return iMusicSystemDbContext.registerAsUser(createUserDto); 20 | } 21 | 22 | @Override 23 | public Singer registerAsSinger(CreateSingerDto createSingerDto) { 24 | return iMusicSystemDbContext.registerAsSinger(createSingerDto); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /object-oriented-design/java/music-player/src/services/singer/ISingerService.java: -------------------------------------------------------------------------------- 1 | package services.singer; 2 | 3 | import DTOs.CreateSongDto; 4 | import entities.Singer; 5 | import entities.Song; 6 | 7 | public interface ISingerService { 8 | 9 | public void addSong(CreateSongDto song); 10 | } 11 | -------------------------------------------------------------------------------- /object-oriented-design/java/music-player/src/services/singer/SingerService.java: -------------------------------------------------------------------------------- 1 | package services.singer; 2 | 3 | import DTOs.CreateSongDto; 4 | import entities.Singer; 5 | import entities.Song; 6 | import repos.IMusicSystemDbContext; 7 | 8 | public class SingerService implements ISingerService{ 9 | 10 | 11 | IMusicSystemDbContext iMusicSystemDbContext; 12 | 13 | public SingerService(IMusicSystemDbContext iMusicSystemDbContext) { 14 | this.iMusicSystemDbContext = iMusicSystemDbContext; 15 | } 16 | 17 | @Override 18 | public void addSong(CreateSongDto song) { 19 | Song newSong = iMusicSystemDbContext.saveSong(song); 20 | for(Singer singer: song.getSingers()) 21 | singer.addSong(newSong); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /object-oriented-design/java/vending-machibe/src/Beverage.java: -------------------------------------------------------------------------------- 1 | import java.util.Objects; 2 | 3 | public abstract class Beverage { 4 | private int beverageId; 5 | private int price; 6 | 7 | public Beverage(int beverageId, int price) { 8 | this.beverageId = beverageId; 9 | this.price = price; 10 | } 11 | 12 | public int getPrice(){ 13 | return price; 14 | } 15 | 16 | @Override 17 | public boolean equals(Object o) { 18 | if (this == o) return true; 19 | if (!(o instanceof Beverage)) return false; 20 | Beverage beverage = (Beverage) o; 21 | return beverageId == beverage.beverageId; 22 | } 23 | 24 | @Override 25 | public int hashCode() { 26 | return Objects.hash(beverageId); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /object-oriented-design/java/vending-machibe/src/CoinType.java: -------------------------------------------------------------------------------- 1 | public enum CoinType { 2 | penny(1), 3 | nickel(5), 4 | dime(10), 5 | quarter(25); 6 | 7 | 8 | private int value; 9 | CoinType(int value) { 10 | this.value = value; 11 | } 12 | 13 | public int getValue() { 14 | return value; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /object-oriented-design/java/vending-machibe/src/Coke.java: -------------------------------------------------------------------------------- 1 | public class Coke extends Beverage { 2 | 3 | public Coke(int beverageId) { 4 | super(beverageId, 25); 5 | } 6 | 7 | 8 | } 9 | -------------------------------------------------------------------------------- /object-oriented-design/java/vending-machibe/src/Pepsi.java: -------------------------------------------------------------------------------- 1 | public class Pepsi extends Beverage { 2 | 3 | public Pepsi(int beverageId) { 4 | super(beverageId, 35); 5 | } 6 | 7 | } 8 | -------------------------------------------------------------------------------- /object-oriented-design/java/vending-machibe/src/Soda.java: -------------------------------------------------------------------------------- 1 | public class Soda extends Beverage { 2 | 3 | public Soda(int beverageId) { 4 | super(beverageId, 45); 5 | } 6 | 7 | } 8 | -------------------------------------------------------------------------------- /object-oriented-design/java/vending-machibe/src/Transaction.java: -------------------------------------------------------------------------------- 1 | public class Transaction { 2 | 3 | private int transactionId; 4 | private boolean isFinished; 5 | 6 | 7 | 8 | 9 | public int getTransactionId() { 10 | return transactionId; 11 | } 12 | 13 | public void setTransactionId(int transactionId) { 14 | this.transactionId = transactionId; 15 | } 16 | 17 | public boolean isFinished() { 18 | return isFinished; 19 | } 20 | 21 | public void setFinished(boolean finished) { 22 | isFinished = finished; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /testing/unit-testing/java/junit/testing-demo-v1/README.md: -------------------------------------------------------------------------------- 1 | # Unit Testing 2 | 3 | In this repository you will see a glimpse of what is unit testing. 4 | 5 | ## Junit5 6 | 7 | JUnit is a unit testing framework for the Java programming language. 8 | JUnit has been important in the development of test-driven development 9 | 10 | ## Examples 11 | 12 | In this example, we will discuss the basics of testing functions behaviour and abnormal behaviour. 13 | This is a good start point to understand what are unit tests and why the latter are important for software development. 14 | 15 | For the next examples, we will start scaling the complexity of the functions! 16 | Check the code! 17 | 18 | -------------------------------------------------------------------------------- /testing/unit-testing/java/junit/testing-demo-v1/main/java/calculator/Calculator.java: -------------------------------------------------------------------------------- 1 | package calculator; 2 | 3 | public interface Calculator { 4 | 5 | int add(int num1, int num2); 6 | } 7 | -------------------------------------------------------------------------------- /testing/unit-testing/java/junit/testing-demo-v1/main/java/calculator/SimpleCalculator.java: -------------------------------------------------------------------------------- 1 | package calculator; 2 | 3 | public class SimpleCalculator implements Calculator { 4 | 5 | @Override 6 | public int add(int num1, int num2) { 7 | return num1 + num2; 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /testing/unit-testing/java/junit/testing-demo-v1/main/java/gpaCalculator/IGPACalculator.java: -------------------------------------------------------------------------------- 1 | package gpaCalculator; 2 | 3 | public interface IGPACalculator { 4 | 5 | Character calculate (int grade); 6 | } 7 | -------------------------------------------------------------------------------- /testing/unit-testing/java/junit/testing-demo-v1/main/java/gpaCalculator/LAUGPACalculator.java: -------------------------------------------------------------------------------- 1 | package gpaCalculator; 2 | 3 | public class LAUGPACalculator implements IGPACalculator { 4 | 5 | 6 | @Override 7 | public Character calculate(int grade) { 8 | if(grade < 0) 9 | throw new IllegalArgumentException("negative value received"); 10 | else if( grade < 60) 11 | return 'F'; 12 | else if (grade < 70) 13 | return 'D'; 14 | else if (grade < 80) 15 | return 'C'; 16 | else if (grade < 90) 17 | return 'B'; 18 | else if (grade < 100) 19 | return 'A'; 20 | else 21 | throw new IllegalArgumentException("Value is invalid"); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /testing/unit-testing/java/junit/testing-demo-v1/main/java/main.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022. 3 | * Author: Roland Salloum 4 | * Github: RolandSall 5 | * Contact: roland.salloum00@outlook.com 6 | */ 7 | 8 | import calculator.Calculator; 9 | import calculator.SimpleCalculator; 10 | 11 | 12 | 13 | public class main { 14 | public static void main(String[] args) { 15 | Calculator calculator = new SimpleCalculator(); 16 | 17 | System.out.println(calculator.add(5,5)); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /testing/unit-testing/java/junit/testing-demo-v1/main/test/java/calculator/SimpleCalculatorTest.java: -------------------------------------------------------------------------------- 1 | package calculator; 2 | 3 | import calculator.SimpleCalculator; 4 | import org.junit.jupiter.api.Test; 5 | 6 | import static org.junit.jupiter.api.Assertions.assertEquals; 7 | 8 | class SimpleCalculatorTest { 9 | 10 | 11 | @Test 12 | void add_function_add_two_numbers_correctly(){ 13 | 14 | // Arrange 15 | var calculator = new SimpleCalculator(); 16 | 17 | // Action 18 | var result_test_1 =calculator.add(2, 2); 19 | var result_test_2 =calculator.add(3, 2); 20 | 21 | // Assert 22 | assertEquals(4,result_test_1); 23 | assertEquals(5,result_test_2); 24 | 25 | } 26 | 27 | } -------------------------------------------------------------------------------- /testing/unit-testing/java/junit/testing-demo-v2/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/**/target/ 5 | !**/src/test/**/target/ 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | *.iws 19 | *.iml 20 | *.ipr 21 | 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /nbbuild/ 25 | /dist/ 26 | /nbdist/ 27 | /.nb-gradle/ 28 | build/ 29 | !**/src/main/**/build/ 30 | !**/src/test/**/build/ 31 | 32 | ### VS Code ### 33 | .vscode/ 34 | -------------------------------------------------------------------------------- /testing/unit-testing/java/junit/testing-demo-v2/src/main/java/com/rolandsall/testingdemov2/SwaggerConfig.java: -------------------------------------------------------------------------------- 1 | package com.rolandsall.testingdemov2; 2 | 3 | import org.springframework.context.annotation.Bean; 4 | import org.springframework.context.annotation.Configuration; 5 | import springfox.documentation.builders.PathSelectors; 6 | import springfox.documentation.builders.RequestHandlerSelectors; 7 | import springfox.documentation.spi.DocumentationType; 8 | import springfox.documentation.spring.web.plugins.Docket; 9 | import springfox.documentation.swagger2.annotations.EnableSwagger2; 10 | 11 | @Configuration 12 | @EnableSwagger2 13 | public class SwaggerConfig { 14 | 15 | @Bean 16 | public Docket api() { 17 | return new Docket(DocumentationType.SWAGGER_2) 18 | .select() 19 | .apis(RequestHandlerSelectors.any()) 20 | .paths(PathSelectors.any()) 21 | .build(); 22 | } 23 | } -------------------------------------------------------------------------------- /testing/unit-testing/java/junit/testing-demo-v2/src/main/java/com/rolandsall/testingdemov2/TestingDemoV2Application.java: -------------------------------------------------------------------------------- 1 | package com.rolandsall.testingdemov2; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class TestingDemoV2Application { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(TestingDemoV2Application.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /testing/unit-testing/java/junit/testing-demo-v2/src/main/java/com/rolandsall/testingdemov2/enums/Gender.java: -------------------------------------------------------------------------------- 1 | package com.rolandsall.testingdemov2.enums; 2 | 3 | public enum Gender { 4 | MALE, 5 | FEMALE, 6 | OTHER 7 | } -------------------------------------------------------------------------------- /testing/unit-testing/java/junit/testing-demo-v2/src/main/java/com/rolandsall/testingdemov2/exceptions/BadRequestException.java: -------------------------------------------------------------------------------- 1 | package com.rolandsall.testingdemov2.exceptions; 2 | 3 | import org.springframework.http.HttpStatus; 4 | import org.springframework.web.bind.annotation.ResponseStatus; 5 | 6 | @ResponseStatus(HttpStatus.BAD_REQUEST) 7 | public class BadRequestException extends RuntimeException { 8 | 9 | public BadRequestException(String msg) { 10 | super(msg); 11 | } 12 | } -------------------------------------------------------------------------------- /testing/unit-testing/java/junit/testing-demo-v2/src/main/java/com/rolandsall/testingdemov2/exceptions/StudentNotFoundException.java: -------------------------------------------------------------------------------- 1 | package com.rolandsall.testingdemov2.exceptions; 2 | 3 | import org.springframework.http.HttpStatus; 4 | import org.springframework.web.bind.annotation.ResponseStatus; 5 | 6 | @ResponseStatus(HttpStatus.NOT_FOUND) 7 | public class StudentNotFoundException extends RuntimeException { 8 | 9 | public StudentNotFoundException(String msg) { 10 | super(msg); 11 | } 12 | } -------------------------------------------------------------------------------- /testing/unit-testing/java/junit/testing-demo-v2/src/main/java/com/rolandsall/testingdemov2/repos/IStudentRepository.java: -------------------------------------------------------------------------------- 1 | package com.rolandsall.testingdemov2.repos; 2 | 3 | import com.rolandsall.testingdemov2.models.Student; 4 | import org.springframework.data.jpa.repository.JpaRepository; 5 | import org.springframework.data.jpa.repository.Query; 6 | import org.springframework.stereotype.Repository; 7 | 8 | @Repository 9 | public interface IStudentRepository extends JpaRepository{ 10 | 11 | 12 | @Query("" + 13 | "SELECT CASE WHEN COUNT(s) > 0 THEN " + 14 | "TRUE ELSE FALSE END " + 15 | "FROM Student s " + 16 | "WHERE s.email = ?1" 17 | ) 18 | Boolean selectExistsEmail(String email); 19 | } 20 | -------------------------------------------------------------------------------- /testing/unit-testing/java/junit/testing-demo-v2/src/main/java/com/rolandsall/testingdemov2/services/IStudentService.java: -------------------------------------------------------------------------------- 1 | package com.rolandsall.testingdemov2.services; 2 | 3 | import com.rolandsall.testingdemov2.models.Student; 4 | import org.springframework.stereotype.Service; 5 | 6 | import java.util.List; 7 | 8 | @Service 9 | public interface IStudentService { 10 | List getAllStudents(); 11 | 12 | void addStudent(Student student); 13 | 14 | void deleteStudent(Long studentId); 15 | } 16 | -------------------------------------------------------------------------------- /testing/unit-testing/java/junit/testing-demo-v2/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.datasource.url=jdbc:h2:mem:testdb 2 | spring.datasource.driverClassName=org.h2.Driver 3 | spring.datasource.username=sa 4 | spring.datasource.password=password 5 | spring.jpa.database-platform=org.hibernate.dialect.H2Dialect 6 | spring.h2.console.enabled=true 7 | spring.mvc.pathmatch.matching-strategy = ANT_PATH_MATCHER -------------------------------------------------------------------------------- /testing/unit-testing/java/junit/testing-demo-v2/src/test/java/com/rolandsall/testingdemov2/TestingDemoV2ApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.rolandsall.testingdemov2; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | class TestingDemoV2ApplicationTests { 7 | 8 | @Test 9 | void contextLoads() { 10 | } 11 | 12 | } 13 | -------------------------------------------------------------------------------- /testing/unit-testing/java/junit/testing-demo-v2/src/test/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.datasource.url=jdbc:h2:mem:testdb 2 | spring.datasource.driverClassName=org.h2.Driver 3 | spring.datasource.username=sa 4 | spring.datasource.password=password 5 | spring.jpa.database-platform=org.hibernate.dialect.H2Dialect 6 | spring.h2.console.enabled=true 7 | spring.jpa.show-sql=true 8 | spring.mvc.pathmatch.matching-strategy = ANT_PATH_MATCHER --------------------------------------------------------------------------------