diff --git a/.idea/modules.xml b/.idea/modules.xml
new file mode 100644
index 0000000..1d4d744
--- /dev/null
+++ b/.idea/modules.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/tn-05.iml b/.idea/tn-05.iml
new file mode 100644
index 0000000..d6ebd48
--- /dev/null
+++ b/.idea/tn-05.iml
@@ -0,0 +1,9 @@
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
new file mode 100644
index 0000000..35eb1dd
--- /dev/null
+++ b/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
new file mode 100644
index 0000000..f2c0100
--- /dev/null
+++ b/.idea/workspace.xml
@@ -0,0 +1,264 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1561645894129
+
+
+ 1561645894129
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1.8
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/de.hhn.ai.prog2.blatt7.junit/.idea/misc.xml b/de.hhn.ai.prog2.blatt7.junit/.idea/misc.xml
index 787fc23..0548357 100644
--- a/de.hhn.ai.prog2.blatt7.junit/.idea/misc.xml
+++ b/de.hhn.ai.prog2.blatt7.junit/.idea/misc.xml
@@ -1,6 +1,6 @@
-
+
\ No newline at end of file
diff --git a/de.hhn.ai.prog2.blatt7.junit/.idea/workspace.xml b/de.hhn.ai.prog2.blatt7.junit/.idea/workspace.xml
index 807f762..d97f2d5 100644
--- a/de.hhn.ai.prog2.blatt7.junit/.idea/workspace.xml
+++ b/de.hhn.ai.prog2.blatt7.junit/.idea/workspace.xml
@@ -1,7 +1,45 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -10,74 +48,124 @@
-
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
@@ -89,24 +177,24 @@
-
-
-
-
-
-
+
+
+
+
+
+
@@ -116,36 +204,10 @@
true
DEFINITION_ORDER
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Kotlin
-
-
- Style issuesKotlin
-
-
-
-
+
+
+
@@ -153,7 +215,6 @@
-
@@ -179,6 +240,13 @@
+
+
+
+
+
+
+
@@ -190,11 +258,17 @@
+
+
+
+
+
+
-
+
@@ -203,6 +277,7 @@
+
@@ -212,7 +287,7 @@
-
+
@@ -226,6 +301,7 @@
+
@@ -241,13 +317,7 @@
-
-
-
-
-
-
-
+
@@ -267,22 +337,24 @@
-
-
-
+
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
@@ -303,6 +375,39 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -319,16 +424,29 @@
+
+
+
+
+
+
+
+
+
-
+
+
+
+
+
+
-
@@ -356,18 +474,45 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
-
+
@@ -376,7 +521,7 @@
-
+
@@ -384,7 +529,7 @@
-
+
@@ -439,34 +584,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -502,13 +619,6 @@
-
-
-
-
-
-
-
@@ -516,37 +626,111 @@
-
+
-
-
-
-
-
+
+
-
+
-
-
-
-
-
+
+
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/de.hhn.ai.prog2.blatt7.junit/PizzaProject.iml b/de.hhn.ai.prog2.blatt7.junit/PizzaProject.iml
index e2f89a7..ccc8ed3 100644
--- a/de.hhn.ai.prog2.blatt7.junit/PizzaProject.iml
+++ b/de.hhn.ai.prog2.blatt7.junit/PizzaProject.iml
@@ -32,5 +32,17 @@
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/de.hhn.ai.prog2.blatt7.junit/out/production/PizzaProject/META-INF/PizzaProject.kotlin_module b/de.hhn.ai.prog2.blatt7.junit/out/production/PizzaProject/META-INF/PizzaProject.kotlin_module
new file mode 100644
index 0000000..8fb6019
Binary files /dev/null and b/de.hhn.ai.prog2.blatt7.junit/out/production/PizzaProject/META-INF/PizzaProject.kotlin_module differ
diff --git a/de.hhn.ai.prog2.blatt7.junit/out/production/PizzaProject/model/Order$OrderState.class b/de.hhn.ai.prog2.blatt7.junit/out/production/PizzaProject/model/Order$OrderState.class
index 8cf1ddb..11b9487 100644
Binary files a/de.hhn.ai.prog2.blatt7.junit/out/production/PizzaProject/model/Order$OrderState.class and b/de.hhn.ai.prog2.blatt7.junit/out/production/PizzaProject/model/Order$OrderState.class differ
diff --git a/de.hhn.ai.prog2.blatt7.junit/out/production/PizzaProject/model/Order.class b/de.hhn.ai.prog2.blatt7.junit/out/production/PizzaProject/model/Order.class
index c90ee54..e028391 100644
Binary files a/de.hhn.ai.prog2.blatt7.junit/out/production/PizzaProject/model/Order.class and b/de.hhn.ai.prog2.blatt7.junit/out/production/PizzaProject/model/Order.class differ
diff --git a/de.hhn.ai.prog2.blatt7.junit/out/production/PizzaProject/model/Pizza$Size.class b/de.hhn.ai.prog2.blatt7.junit/out/production/PizzaProject/model/Pizza$Size.class
index 528adb7..d2ea68e 100644
Binary files a/de.hhn.ai.prog2.blatt7.junit/out/production/PizzaProject/model/Pizza$Size.class and b/de.hhn.ai.prog2.blatt7.junit/out/production/PizzaProject/model/Pizza$Size.class differ
diff --git a/de.hhn.ai.prog2.blatt7.junit/out/production/PizzaProject/model/Pizza$Toppings.class b/de.hhn.ai.prog2.blatt7.junit/out/production/PizzaProject/model/Pizza$Toppings.class
index 77beb91..33a84ac 100644
Binary files a/de.hhn.ai.prog2.blatt7.junit/out/production/PizzaProject/model/Pizza$Toppings.class and b/de.hhn.ai.prog2.blatt7.junit/out/production/PizzaProject/model/Pizza$Toppings.class differ
diff --git a/de.hhn.ai.prog2.blatt7.junit/out/production/PizzaProject/model/Pizza.class b/de.hhn.ai.prog2.blatt7.junit/out/production/PizzaProject/model/Pizza.class
index 512d03f..cd39b10 100644
Binary files a/de.hhn.ai.prog2.blatt7.junit/out/production/PizzaProject/model/Pizza.class and b/de.hhn.ai.prog2.blatt7.junit/out/production/PizzaProject/model/Pizza.class differ
diff --git a/de.hhn.ai.prog2.blatt7.junit/out/production/PizzaProject/services/dummy/PizzaServiceDummy.class b/de.hhn.ai.prog2.blatt7.junit/out/production/PizzaProject/services/dummy/PizzaServiceDummy.class
index e300bf0..2ee9878 100644
Binary files a/de.hhn.ai.prog2.blatt7.junit/out/production/PizzaProject/services/dummy/PizzaServiceDummy.class and b/de.hhn.ai.prog2.blatt7.junit/out/production/PizzaProject/services/dummy/PizzaServiceDummy.class differ
diff --git a/de.hhn.ai.prog2.blatt7.junit/out/production/PizzaProject/services/impl/OrderService.class b/de.hhn.ai.prog2.blatt7.junit/out/production/PizzaProject/services/impl/OrderService.class
index 9bed23b..1922378 100644
Binary files a/de.hhn.ai.prog2.blatt7.junit/out/production/PizzaProject/services/impl/OrderService.class and b/de.hhn.ai.prog2.blatt7.junit/out/production/PizzaProject/services/impl/OrderService.class differ
diff --git a/de.hhn.ai.prog2.blatt7.junit/out/production/TestGPI2/model/Order$OrderState.class b/de.hhn.ai.prog2.blatt7.junit/out/production/TestGPI2/model/Order$OrderState.class
deleted file mode 100644
index b28225e..0000000
Binary files a/de.hhn.ai.prog2.blatt7.junit/out/production/TestGPI2/model/Order$OrderState.class and /dev/null differ
diff --git a/de.hhn.ai.prog2.blatt7.junit/out/production/TestGPI2/model/Order.class b/de.hhn.ai.prog2.blatt7.junit/out/production/TestGPI2/model/Order.class
deleted file mode 100644
index b39ddb1..0000000
Binary files a/de.hhn.ai.prog2.blatt7.junit/out/production/TestGPI2/model/Order.class and /dev/null differ
diff --git a/de.hhn.ai.prog2.blatt7.junit/out/production/TestGPI2/model/Pizza$Size.class b/de.hhn.ai.prog2.blatt7.junit/out/production/TestGPI2/model/Pizza$Size.class
deleted file mode 100644
index fbc7c08..0000000
Binary files a/de.hhn.ai.prog2.blatt7.junit/out/production/TestGPI2/model/Pizza$Size.class and /dev/null differ
diff --git a/de.hhn.ai.prog2.blatt7.junit/out/production/TestGPI2/model/Pizza$Toppings.class b/de.hhn.ai.prog2.blatt7.junit/out/production/TestGPI2/model/Pizza$Toppings.class
deleted file mode 100644
index e4c71ff..0000000
Binary files a/de.hhn.ai.prog2.blatt7.junit/out/production/TestGPI2/model/Pizza$Toppings.class and /dev/null differ
diff --git a/de.hhn.ai.prog2.blatt7.junit/out/production/TestGPI2/model/Pizza.class b/de.hhn.ai.prog2.blatt7.junit/out/production/TestGPI2/model/Pizza.class
deleted file mode 100644
index 35838f2..0000000
Binary files a/de.hhn.ai.prog2.blatt7.junit/out/production/TestGPI2/model/Pizza.class and /dev/null differ
diff --git a/de.hhn.ai.prog2.blatt7.junit/out/production/TestGPI2/model/exceptions/OrderException.class b/de.hhn.ai.prog2.blatt7.junit/out/production/TestGPI2/model/exceptions/OrderException.class
deleted file mode 100644
index 9b3bd44..0000000
Binary files a/de.hhn.ai.prog2.blatt7.junit/out/production/TestGPI2/model/exceptions/OrderException.class and /dev/null differ
diff --git a/de.hhn.ai.prog2.blatt7.junit/out/production/TestGPI2/services/dummy/PizzaServiceDummy.class b/de.hhn.ai.prog2.blatt7.junit/out/production/TestGPI2/services/dummy/PizzaServiceDummy.class
deleted file mode 100644
index 91b7041..0000000
Binary files a/de.hhn.ai.prog2.blatt7.junit/out/production/TestGPI2/services/dummy/PizzaServiceDummy.class and /dev/null differ
diff --git a/de.hhn.ai.prog2.blatt7.junit/out/production/TestGPI2/services/impl/OrderService.class b/de.hhn.ai.prog2.blatt7.junit/out/production/TestGPI2/services/impl/OrderService.class
deleted file mode 100644
index f1497c2..0000000
Binary files a/de.hhn.ai.prog2.blatt7.junit/out/production/TestGPI2/services/impl/OrderService.class and /dev/null differ
diff --git a/de.hhn.ai.prog2.blatt7.junit/out/production/TestGPI2/services/impl/PizzaService.class b/de.hhn.ai.prog2.blatt7.junit/out/production/TestGPI2/services/impl/PizzaService.class
deleted file mode 100644
index ca4f772..0000000
Binary files a/de.hhn.ai.prog2.blatt7.junit/out/production/TestGPI2/services/impl/PizzaService.class and /dev/null differ
diff --git a/de.hhn.ai.prog2.blatt7.junit/out/production/TestGPI2/services/interfaces/IPizzaService.class b/de.hhn.ai.prog2.blatt7.junit/out/production/TestGPI2/services/interfaces/IPizzaService.class
deleted file mode 100644
index ab6c942..0000000
Binary files a/de.hhn.ai.prog2.blatt7.junit/out/production/TestGPI2/services/interfaces/IPizzaService.class and /dev/null differ
diff --git a/de.hhn.ai.prog2.blatt7.junit/out/production/TestGPI2/services/io/PizzaIOHandler.class b/de.hhn.ai.prog2.blatt7.junit/out/production/TestGPI2/services/io/PizzaIOHandler.class
deleted file mode 100644
index deea7b1..0000000
Binary files a/de.hhn.ai.prog2.blatt7.junit/out/production/TestGPI2/services/io/PizzaIOHandler.class and /dev/null differ
diff --git a/de.hhn.ai.prog2.blatt7.junit/out/production/TestGPI2/view/MainFrame.class b/de.hhn.ai.prog2.blatt7.junit/out/production/TestGPI2/view/MainFrame.class
deleted file mode 100644
index 77623f0..0000000
Binary files a/de.hhn.ai.prog2.blatt7.junit/out/production/TestGPI2/view/MainFrame.class and /dev/null differ
diff --git a/de.hhn.ai.prog2.blatt7.junit/out/production/TestGPI2/view/PizzaConfiguratorPanel.class b/de.hhn.ai.prog2.blatt7.junit/out/production/TestGPI2/view/PizzaConfiguratorPanel.class
deleted file mode 100644
index d6679a0..0000000
Binary files a/de.hhn.ai.prog2.blatt7.junit/out/production/TestGPI2/view/PizzaConfiguratorPanel.class and /dev/null differ
diff --git a/de.hhn.ai.prog2.blatt7.junit/out/production/TestGPI2/view/PizzaListPanel.class b/de.hhn.ai.prog2.blatt7.junit/out/production/TestGPI2/view/PizzaListPanel.class
deleted file mode 100644
index 8a6e6c1..0000000
Binary files a/de.hhn.ai.prog2.blatt7.junit/out/production/TestGPI2/view/PizzaListPanel.class and /dev/null differ
diff --git a/de.hhn.ai.prog2.blatt7.junit/out/test/PizzaProject/model/OrderTest.class b/de.hhn.ai.prog2.blatt7.junit/out/test/PizzaProject/model/OrderTest.class
index eabf10b..6fbae4d 100644
Binary files a/de.hhn.ai.prog2.blatt7.junit/out/test/PizzaProject/model/OrderTest.class and b/de.hhn.ai.prog2.blatt7.junit/out/test/PizzaProject/model/OrderTest.class differ
diff --git a/de.hhn.ai.prog2.blatt7.junit/out/test/PizzaProject/model/PizzaTest.class b/de.hhn.ai.prog2.blatt7.junit/out/test/PizzaProject/model/PizzaTest.class
index f53ad21..55b5da9 100644
Binary files a/de.hhn.ai.prog2.blatt7.junit/out/test/PizzaProject/model/PizzaTest.class and b/de.hhn.ai.prog2.blatt7.junit/out/test/PizzaProject/model/PizzaTest.class differ
diff --git a/de.hhn.ai.prog2.blatt7.junit/out/test/PizzaProject/services/OrderServiceTest.class b/de.hhn.ai.prog2.blatt7.junit/out/test/PizzaProject/services/OrderServiceTest.class
index c674935..b8af862 100644
Binary files a/de.hhn.ai.prog2.blatt7.junit/out/test/PizzaProject/services/OrderServiceTest.class and b/de.hhn.ai.prog2.blatt7.junit/out/test/PizzaProject/services/OrderServiceTest.class differ
diff --git a/de.hhn.ai.prog2.blatt7.junit/out/test/TestGPI2/model/OrderTest.class b/de.hhn.ai.prog2.blatt7.junit/out/test/TestGPI2/model/OrderTest.class
deleted file mode 100644
index 672f292..0000000
Binary files a/de.hhn.ai.prog2.blatt7.junit/out/test/TestGPI2/model/OrderTest.class and /dev/null differ
diff --git a/de.hhn.ai.prog2.blatt7.junit/out/test/TestGPI2/model/PizzaTest.class b/de.hhn.ai.prog2.blatt7.junit/out/test/TestGPI2/model/PizzaTest.class
deleted file mode 100644
index f53ad21..0000000
Binary files a/de.hhn.ai.prog2.blatt7.junit/out/test/TestGPI2/model/PizzaTest.class and /dev/null differ
diff --git a/de.hhn.ai.prog2.blatt7.junit/out/test/TestGPI2/services/OrderServiceTest.class b/de.hhn.ai.prog2.blatt7.junit/out/test/TestGPI2/services/OrderServiceTest.class
deleted file mode 100644
index c674935..0000000
Binary files a/de.hhn.ai.prog2.blatt7.junit/out/test/TestGPI2/services/OrderServiceTest.class and /dev/null differ
diff --git a/de.hhn.ai.prog2.blatt7.junit/src/model/Order.java b/de.hhn.ai.prog2.blatt7.junit/src/model/Order.java
index 4a29a90..c90f940 100644
--- a/de.hhn.ai.prog2.blatt7.junit/src/model/Order.java
+++ b/de.hhn.ai.prog2.blatt7.junit/src/model/Order.java
@@ -22,6 +22,7 @@ public class Order {
this.customer = customer;
this.pizzas = pizzas;
this.date = date;
+ state = OrderState.IN_PROGRESS;
}
public String getCustomer() {
@@ -73,6 +74,8 @@ public class Order {
this.state = state;
}
+ public OrderState getOrderState() {return this.state;}
+
public Date getDate() {
return date;
}
diff --git a/de.hhn.ai.prog2.blatt7.junit/src/model/Pizza.java b/de.hhn.ai.prog2.blatt7.junit/src/model/Pizza.java
index 3195020..5a49234 100644
--- a/de.hhn.ai.prog2.blatt7.junit/src/model/Pizza.java
+++ b/de.hhn.ai.prog2.blatt7.junit/src/model/Pizza.java
@@ -21,10 +21,13 @@ public class Pizza {
* Add a topping to the pizza. The same topping can be added twice to duplicate the amount.
*
* @param t
+ * @throws IllegalArgumentException more than 2 toppings of the same type aren't allowed
*/
public void addTopping(Toppings t) {
if (Collections.frequency(toppings, t) < 2)
this.toppings.add(t);
+ else
+ throw new IllegalArgumentException();
}
diff --git a/de.hhn.ai.prog2.blatt7.junit/src/services/dummy/PizzaServiceDummy.java b/de.hhn.ai.prog2.blatt7.junit/src/services/dummy/PizzaServiceDummy.java
index 3ec45d8..d26129b 100644
--- a/de.hhn.ai.prog2.blatt7.junit/src/services/dummy/PizzaServiceDummy.java
+++ b/de.hhn.ai.prog2.blatt7.junit/src/services/dummy/PizzaServiceDummy.java
@@ -33,7 +33,10 @@ public class PizzaServiceDummy implements IPizzaService {
for (int i = 0; i < toppingCounter; i++) {
Pizza.Toppings t = getRandomTopping();
- p.addTopping(t);
+ try {
+ p.addTopping(t);
+ } catch (IllegalArgumentException e) {}
+
}
p.setSize(getRandomSize());
p.setName(generateRandomName());
diff --git a/de.hhn.ai.prog2.blatt7.junit/src/services/impl/OrderService.java b/de.hhn.ai.prog2.blatt7.junit/src/services/impl/OrderService.java
index 5a2ac62..1c3a8e7 100644
--- a/de.hhn.ai.prog2.blatt7.junit/src/services/impl/OrderService.java
+++ b/de.hhn.ai.prog2.blatt7.junit/src/services/impl/OrderService.java
@@ -3,6 +3,7 @@ package services.impl;
import model.Order;
import sun.reflect.generics.reflectiveObjects.NotImplementedException;
+import java.util.ArrayList;
import java.util.List;
public class OrderService {
@@ -11,29 +12,31 @@ public class OrderService {
public OrderService(List orders) {
this.orders = orders;
- //TODO
- throw new NotImplementedException();
}
public void addOrder(Order o) {
- //TODO
- throw new NotImplementedException();
+ orders.add(o);
}
public void removeOrder(Order o) {
- //TODO
- throw new NotImplementedException();
+ orders.remove(o);
}
public List getAllNonDeliverdOrder() {
- //TODO
- throw new NotImplementedException();
- //return null;
+ List ret = new ArrayList<>();
+ for(Order order : orders) {
+ if(order.getOrderState() != Order.OrderState.DELIVERD)
+ ret.add(order);
+ }
+ return ret;
}
- public List getAllDeliverdOder() {
- //TODO
- throw new NotImplementedException();
- // return null;
+ public List getAllDeliverdOrder() {
+ List ret = new ArrayList<>();
+ for(Order order : orders) {
+ if(order.getOrderState() == Order.OrderState.DELIVERD)
+ ret.add(order);
+ }
+ return ret;
}
}
diff --git a/de.hhn.ai.prog2.blatt7.junit/tests/model/OrderTest.java b/de.hhn.ai.prog2.blatt7.junit/tests/model/OrderTest.java
index 61032d9..e234f35 100644
--- a/de.hhn.ai.prog2.blatt7.junit/tests/model/OrderTest.java
+++ b/de.hhn.ai.prog2.blatt7.junit/tests/model/OrderTest.java
@@ -1,25 +1,49 @@
package model;
+import model.exceptions.OrderException;
+import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
+import java.util.*;
+
import static org.junit.jupiter.api.Assertions.*;
class OrderTest {
+ private List pizzas;
+ private Order order;
+
+ @BeforeEach
+ void setUp() {
+ pizzas = new ArrayList<>(Arrays.asList(new Pizza(), new Pizza()));
+ order = new Order("Max Mustermann", pizzas, new Date());
+ }
+
@Test
void getCustomer() {
+ assertEquals("Max Mustermann", order.getCustomer());
+ assertNotEquals("Wrong", order.getCustomer());
}
@Test
void setCustomer() {
+ order.setCustomer("Max Mustermann 2");
+ assertEquals("Max Mustermann 2", order.getCustomer());
+ assertNotEquals("Max Mustermann", order.getCustomer());
}
@Test
void getPizzas() {
+ assertEquals(pizzas, order.getPizzas());
+ assertNotEquals(Arrays.asList(new Pizza(), new Pizza()), order.getPizzas());
}
@Test
- void setPizzas() {
+ void setPizzas() throws OrderException {
+ List newPizzas = new ArrayList<>(Arrays.asList(new Pizza(), new Pizza()));
+ order.setPizzas(newPizzas);
+ assertEquals(newPizzas, order.getPizzas());
+ assertNotEquals(pizzas, order.getPizzas());
}
/**
@@ -27,25 +51,35 @@ class OrderTest {
*/
@Test
void addPizzaAfterCompletion() {
-
+ order.setOrderState(Order.OrderState.DELIVERD);
+ assertThrows(OrderException.class, () -> order.setPizzas(pizzas));
}
/**
* Tests if the pizza is added to the pizza List.
*/
@Test
- void addPizzaBeforCompletion() {
+ void addPizzaBeforeCompletion() throws OrderException {
+ order.addPizza(new Pizza());
}
@Test
void setOrderState() {
- }
-
- @Test
- void getDate() {
+ order.setOrderState(Order.OrderState.DELIVERD);
+ assertEquals(Order.OrderState.DELIVERD, order.getOrderState());
+ assertNotEquals(Order.OrderState.WAIT, order.getOrderState());
}
@Test
void setDate() {
+ Date today = new Date();
+ Calendar c = Calendar.getInstance();
+ c.setTime(today);
+ c.add(Calendar.DAY_OF_MONTH, 21);
+ Date currentDatePlus21d = c.getTime();
+ assertThrows(IllegalArgumentException.class, () -> order.setDate(currentDatePlus21d));
+ c.add(Calendar.DAY_OF_MONTH, -2);
+ Date currentDatePlus19d = c.getTime();
+ assertDoesNotThrow(() -> order.setDate(currentDatePlus19d));
}
}
diff --git a/de.hhn.ai.prog2.blatt7.junit/tests/model/PizzaTest.java b/de.hhn.ai.prog2.blatt7.junit/tests/model/PizzaTest.java
index 56c97a9..3393a12 100644
--- a/de.hhn.ai.prog2.blatt7.junit/tests/model/PizzaTest.java
+++ b/de.hhn.ai.prog2.blatt7.junit/tests/model/PizzaTest.java
@@ -3,13 +3,17 @@ package model;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
+import services.dummy.PizzaServiceDummy;
import static org.junit.jupiter.api.Assertions.*;
class PizzaTest {
+ private PizzaServiceDummy pizzaServiceDummy = new PizzaServiceDummy();
+ private Pizza pizza;
@BeforeEach
void setUp() {
+ pizza = pizzaServiceDummy.generateRandomPizza();
}
@AfterEach
@@ -18,17 +22,35 @@ class PizzaTest {
@Test
void addTopping() {
+ Pizza pizza2 = new Pizza();
+ Pizza.Toppings topping = pizzaServiceDummy.getRandomTopping();
+ pizza2.addTopping(topping);
+ pizza2.addTopping(topping);
+ assertThrows(IllegalArgumentException.class, () -> pizza2.addTopping(topping));
}
@Test
void setSize() {
+ Pizza.Size size = pizzaServiceDummy.getRandomSize();
+ pizza.setSize(size);
+ assertEquals(size, pizza.getSize());
+ pizza.setSize(Pizza.Size.LARGE);
+ assertNotEquals(Pizza.Size.SMALL, pizza.getSize());
}
@Test
void setName() {
+ pizza.setName("Test 123");
+ assertEquals("Test 123", pizza.getName());
+ assertNotEquals("Wrong", pizza.getName());
}
@Test
void removeTopping() {
+ Pizza pizza2 = new Pizza();
+ Pizza.Toppings topping = pizzaServiceDummy.getRandomTopping();
+ pizza2.addTopping(topping);
+ pizza2.removeTopping(topping);
+ assertFalse(pizza2.getToppings().contains(topping));
}
}
\ No newline at end of file
diff --git a/de.hhn.ai.prog2.blatt7.junit/tests/services/OrderServiceTest.java b/de.hhn.ai.prog2.blatt7.junit/tests/services/OrderServiceTest.java
index 9b2e406..99adc72 100644
--- a/de.hhn.ai.prog2.blatt7.junit/tests/services/OrderServiceTest.java
+++ b/de.hhn.ai.prog2.blatt7.junit/tests/services/OrderServiceTest.java
@@ -1,15 +1,43 @@
package services;
+import model.Order;
+import model.Pizza;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
+import services.impl.OrderService;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Date;
+import java.util.List;
import static org.junit.jupiter.api.Assertions.*;
class OrderServiceTest {
+ OrderService service;
+ List orders;
+ Order newOrder;
@BeforeEach
void setUp() {
+ orders = new ArrayList<>(Arrays.asList(
+ new Order(
+ "Max Mustermann",
+ new ArrayList<>(Arrays.asList(new Pizza(), new Pizza())),
+ new Date()
+ ),
+ new Order(
+ "Frau Musterfrau",
+ new ArrayList<>(Arrays.asList(new Pizza(), new Pizza())),
+ new Date()
+ )));
+ service = new OrderService(orders);
+ newOrder = new Order(
+ "New Order",
+ new ArrayList<>(Arrays.asList(new Pizza(), new Pizza())),
+ new Date()
+ );
}
@AfterEach
@@ -18,17 +46,33 @@ class OrderServiceTest {
@Test
void addOrder() {
+ assertFalse(service.getAllNonDeliverdOrder().contains(newOrder));
+ service.addOrder(newOrder);
+ assertTrue(service.getAllNonDeliverdOrder().contains(newOrder));
}
@Test
void removeOrder() {
+ assertFalse(service.getAllNonDeliverdOrder().contains(newOrder));
+ service.addOrder(newOrder);
+ assertTrue(service.getAllNonDeliverdOrder().contains(newOrder));
+ service.removeOrder(newOrder);
+ assertFalse(service.getAllNonDeliverdOrder().contains(newOrder));
}
@Test
void getAllNonDeliverdOrder() {
+ assertEquals(2, service.getAllNonDeliverdOrder().size());
+ newOrder.setOrderState(Order.OrderState.DELIVERD);
+ service.addOrder(newOrder);
+ assertEquals(2, service.getAllNonDeliverdOrder().size());
}
@Test
void getAllDeliverdOder() {
+ assertEquals(0, service.getAllDeliverdOrder().size());
+ newOrder.setOrderState(Order.OrderState.DELIVERD);
+ service.addOrder(newOrder);
+ assertEquals(1, service.getAllDeliverdOrder().size());
}
}
\ No newline at end of file