From b423fd30d4b0d1fd6db2681c35f7c49ce447b1e5 Mon Sep 17 00:00:00 2001 From: Samil Ayoub Date: Wed, 2 Sep 2020 18:12:42 +0100 Subject: [PATCH] Fix bugs, clean the code and add unit tests. --- simple-factory/etc/simple-factory.urm.puml | 35 +++++++++++++++ simple-factory/pom.xml | 13 +++++- .../java/com/iluwatar/simplefactory/App.java | 44 +++++++++++++++---- .../java/com/iluwatar/simplefactory/Car.java | 8 ++-- .../simplefactory/CarSimpleFactory.java | 42 ++++++++---------- .../com/iluwatar/simplefactory/Ferrari.java | 16 +++---- .../java/com/iluwatar/simplefactory/Ford.java | 12 ++--- .../com/iluwatar/simplefactory/AppTest.java | 14 ++++++ .../simplefactory/CarSimpleFactoryTest.java | 15 +++++++ 9 files changed, 148 insertions(+), 51 deletions(-) create mode 100644 simple-factory/etc/simple-factory.urm.puml create mode 100644 simple-factory/src/test/java/com/iluwatar/simplefactory/AppTest.java create mode 100644 simple-factory/src/test/java/com/iluwatar/simplefactory/CarSimpleFactoryTest.java diff --git a/simple-factory/etc/simple-factory.urm.puml b/simple-factory/etc/simple-factory.urm.puml new file mode 100644 index 000000000..77fee4b5b --- /dev/null +++ b/simple-factory/etc/simple-factory.urm.puml @@ -0,0 +1,35 @@ +@startuml +package com.iluwatar.simplefactory { + class App { + - LOGGER : Logger {static} + + App() + + main(args : String[]) {static} + } + interface Car { + + getDescription() : String {abstract} + } + class CarSimpleFactory { + + CarSimpleFactory() + + getCar(type : CarType) : Car {static} + } + ~enum CarType { + + FERRARI {static} + + FORD {static} + + valueOf(name : String) : CarType {static} + + values() : CarType[] {static} + } + class Ferrari { + ~ DESCRIPTION : String {static} + + Ferrari() + + getDescription() : String + } + class Ford { + ~ DESCRIPTION : String {static} + + Ford() + + getDescription() : String + } +} +CarType ..+ CarSimpleFactory +Ferrari ..|> Car +Ford ..|> Car +@enduml \ No newline at end of file diff --git a/simple-factory/pom.xml b/simple-factory/pom.xml index e7d28511f..ca7c0547d 100644 --- a/simple-factory/pom.xml +++ b/simple-factory/pom.xml @@ -6,6 +6,17 @@ 1.24.0-SNAPSHOT simple-factory + + + org.junit.jupiter + junit-jupiter-engine + test + + + junit + junit + +