Fix tests in exercies 7
This commit is contained in:
parent
fb42dba6a3
commit
fe1920d94c
5 changed files with 100 additions and 76 deletions
|
@ -2,9 +2,9 @@
|
|||
<project version="4">
|
||||
<component name="ChangeListManager">
|
||||
<list default="true" id="ce5d9264-6543-4dfb-9894-4df6c2616d5e" name="Default" comment="">
|
||||
<change afterPath="$PROJECT_DIR$/../de.hhn.ai.prog2.blatt8.internationalisierung/src/locale_de_DE.properties" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/../de.hhn.ai.prog2.blatt8.internationalisierung/src/locale_en.properties" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/tests/model/OrderTest.java" beforeDir="false" afterPath="$PROJECT_DIR$/tests/model/OrderTest.java" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/tests/model/PizzaTest.java" beforeDir="false" afterPath="$PROJECT_DIR$/tests/model/PizzaTest.java" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/../de.hhn.ai.prog2.blatt9.properties/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/../de.hhn.ai.prog2.blatt9.properties/.idea/workspace.xml" afterDir="false" />
|
||||
</list>
|
||||
<ignored path="$PROJECT_DIR$/out/" />
|
||||
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
|
||||
|
@ -23,8 +23,8 @@
|
|||
<file pinned="false" current-in-tab="false">
|
||||
<entry file="file://$PROJECT_DIR$/tests/model/PizzaTest.java">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="705">
|
||||
<caret line="54" selection-start-line="54" selection-end-line="54" />
|
||||
<state relative-caret-position="195">
|
||||
<caret line="13" selection-start-line="12" selection-end-line="13" />
|
||||
<folding>
|
||||
<element signature="imports" expanded="true" />
|
||||
<element signature="e#377#378#0" expanded="true" />
|
||||
|
@ -51,11 +51,11 @@
|
|||
</provider>
|
||||
</entry>
|
||||
</file>
|
||||
<file pinned="false" current-in-tab="false">
|
||||
<file pinned="false" current-in-tab="true">
|
||||
<entry file="file://$PROJECT_DIR$/tests/model/OrderTest.java">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="1110">
|
||||
<caret line="80" column="40" selection-start-line="80" selection-start-column="40" selection-end-line="80" selection-end-column="40" />
|
||||
<state relative-caret-position="1560">
|
||||
<caret line="112" column="40" selection-start-line="112" selection-start-column="40" selection-end-line="112" selection-end-column="40" />
|
||||
<folding>
|
||||
<element signature="imports" expanded="true" />
|
||||
</folding>
|
||||
|
@ -63,7 +63,7 @@
|
|||
</provider>
|
||||
</entry>
|
||||
</file>
|
||||
<file pinned="false" current-in-tab="true">
|
||||
<file pinned="false" current-in-tab="false">
|
||||
<entry file="file://$PROJECT_DIR$/tests/services/OrderServiceTest.java">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="945">
|
||||
|
@ -163,10 +163,10 @@
|
|||
<detection-done>true</detection-done>
|
||||
<sorting>DEFINITION_ORDER</sorting>
|
||||
</component>
|
||||
<component name="ProjectFrameBounds">
|
||||
<option name="x" value="1280" />
|
||||
<component name="ProjectFrameBounds" extendedState="6">
|
||||
<option name="x" value="787" />
|
||||
<option name="width" value="2560" />
|
||||
<option name="height" value="1410" />
|
||||
<option name="height" value="1046" />
|
||||
</component>
|
||||
<component name="ProjectLevelVcsManager" settingsEditedManually="true" />
|
||||
<component name="ProjectView">
|
||||
|
@ -175,6 +175,7 @@
|
|||
</navigator>
|
||||
<panes>
|
||||
<pane id="Scope" />
|
||||
<pane id="PackagesPane" />
|
||||
<pane id="ProjectPane">
|
||||
<subPane>
|
||||
<expand>
|
||||
|
@ -193,19 +194,6 @@
|
|||
<item name="src" type="462c0819:PsiDirectoryNode" />
|
||||
<item name="model" type="462c0819:PsiDirectoryNode" />
|
||||
</path>
|
||||
<path>
|
||||
<item name="de.hhn.ai.prog2.blatt7.junit" type="b2602c69:ProjectViewProjectNode" />
|
||||
<item name="de.hhn.ai.prog2.blatt7.junit" type="462c0819:PsiDirectoryNode" />
|
||||
<item name="src" type="462c0819:PsiDirectoryNode" />
|
||||
<item name="services" type="462c0819:PsiDirectoryNode" />
|
||||
</path>
|
||||
<path>
|
||||
<item name="de.hhn.ai.prog2.blatt7.junit" type="b2602c69:ProjectViewProjectNode" />
|
||||
<item name="de.hhn.ai.prog2.blatt7.junit" type="462c0819:PsiDirectoryNode" />
|
||||
<item name="src" type="462c0819:PsiDirectoryNode" />
|
||||
<item name="services" type="462c0819:PsiDirectoryNode" />
|
||||
<item name="impl" type="462c0819:PsiDirectoryNode" />
|
||||
</path>
|
||||
<path>
|
||||
<item name="de.hhn.ai.prog2.blatt7.junit" type="b2602c69:ProjectViewProjectNode" />
|
||||
<item name="de.hhn.ai.prog2.blatt7.junit" type="462c0819:PsiDirectoryNode" />
|
||||
|
@ -227,7 +215,6 @@
|
|||
<select />
|
||||
</subPane>
|
||||
</pane>
|
||||
<pane id="PackagesPane" />
|
||||
</panes>
|
||||
</component>
|
||||
<component name="PropertiesComponent">
|
||||
|
@ -276,7 +263,7 @@
|
|||
</list>
|
||||
</option>
|
||||
</component>
|
||||
<component name="RunManager" selected="JUnit.OrderServiceTest">
|
||||
<component name="RunManager" selected="JUnit.PizzaTest">
|
||||
<configuration default="true" type="Applet">
|
||||
<option name="POLICY_FILE" value="$APPLICATION_HOME_DIR$/bin/appletviewer.policy" />
|
||||
<method v="2">
|
||||
|
@ -401,9 +388,9 @@
|
|||
</list>
|
||||
<recent_temporary>
|
||||
<list>
|
||||
<item itemvalue="JUnit.OrderServiceTest" />
|
||||
<item itemvalue="JUnit.OrderTest" />
|
||||
<item itemvalue="JUnit.PizzaTest" />
|
||||
<item itemvalue="JUnit.OrderTest" />
|
||||
<item itemvalue="JUnit.OrderServiceTest" />
|
||||
<item itemvalue="JUnit.PizzaTest.removeTopping" />
|
||||
<item itemvalue="Application.Order" />
|
||||
</list>
|
||||
|
@ -433,12 +420,6 @@
|
|||
<servers />
|
||||
</component>
|
||||
<component name="TestHistory">
|
||||
<history-entry file="OrderTest - 2019.06.27 at 18h 05m 40s.xml">
|
||||
<configuration name="OrderTest" configurationId="JUnit" />
|
||||
</history-entry>
|
||||
<history-entry file="PizzaTest - 2019.06.27 at 18h 06m 59s.xml">
|
||||
<configuration name="PizzaTest" configurationId="JUnit" />
|
||||
</history-entry>
|
||||
<history-entry file="PizzaTest - 2019.06.27 at 18h 07m 13s.xml">
|
||||
<configuration name="PizzaTest" configurationId="JUnit" />
|
||||
</history-entry>
|
||||
|
@ -463,14 +444,20 @@
|
|||
<history-entry file="OrderServiceTest - 2019.06.27 at 18h 24m 57s.xml">
|
||||
<configuration name="OrderServiceTest" configurationId="JUnit" />
|
||||
</history-entry>
|
||||
<history-entry file="OrderTest - 2019.07.04 at 12h 06m 28s.xml">
|
||||
<configuration name="OrderTest" configurationId="JUnit" />
|
||||
</history-entry>
|
||||
<history-entry file="PizzaTest - 2019.07.04 at 12h 06m 38s.xml">
|
||||
<configuration name="PizzaTest" configurationId="JUnit" />
|
||||
</history-entry>
|
||||
</component>
|
||||
<component name="TimeTrackingManager">
|
||||
<option name="totallyTimeSpent" value="21861000" />
|
||||
</component>
|
||||
<component name="ToolWindowManager">
|
||||
<frame x="1280" y="0" width="2560" height="1410" extended-state="0" />
|
||||
<frame x="1280" y="0" width="2560" height="1410" extended-state="6" />
|
||||
<layout>
|
||||
<window_info content_ui="combo" id="Project" order="0" visible="true" weight="0.12708499" />
|
||||
<window_info active="true" content_ui="combo" id="Project" order="0" visible="true" weight="0.12787926" />
|
||||
<window_info id="Structure" order="1" weight="0.25" />
|
||||
<window_info id="Image Layers" order="2" />
|
||||
<window_info id="Designer" order="3" />
|
||||
|
@ -479,7 +466,7 @@
|
|||
<window_info id="Favorites" order="6" side_tool="true" />
|
||||
<window_info anchor="bottom" id="Message" order="0" />
|
||||
<window_info anchor="bottom" id="Find" order="1" />
|
||||
<window_info anchor="bottom" id="Run" order="2" weight="0.28892332" />
|
||||
<window_info anchor="bottom" id="Run" order="2" weight="0.40172786" />
|
||||
<window_info anchor="bottom" id="Debug" order="3" weight="0.4" />
|
||||
<window_info anchor="bottom" id="Cvs" order="4" weight="0.25" />
|
||||
<window_info anchor="bottom" id="Inspection" order="5" weight="0.4" />
|
||||
|
@ -599,18 +586,6 @@
|
|||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/src/services/Date.java" />
|
||||
<entry file="file://$PROJECT_DIR$/tests/model/PizzaTest.java">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="705">
|
||||
<caret line="54" selection-start-line="54" selection-end-line="54" />
|
||||
<folding>
|
||||
<element signature="imports" expanded="true" />
|
||||
<element signature="e#377#378#0" expanded="true" />
|
||||
<element signature="e#440#441#0" expanded="true" />
|
||||
</folding>
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/src/services/dummy/PizzaServiceDummy.java">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="495">
|
||||
|
@ -626,23 +601,6 @@
|
|||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/tests/model/OrderTest.java">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="1110">
|
||||
<caret line="80" column="40" selection-start-line="80" selection-start-column="40" selection-end-line="80" selection-end-column="40" />
|
||||
<folding>
|
||||
<element signature="imports" expanded="true" />
|
||||
</folding>
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/tests/services/OrderServiceTest.java">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="945">
|
||||
<caret line="75" column="22" selection-start-line="75" selection-start-column="22" selection-end-line="75" selection-end-column="22" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/src/model/Pizza.java">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="1245">
|
||||
|
@ -676,6 +634,35 @@
|
|||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/tests/services/OrderServiceTest.java">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="945">
|
||||
<caret line="75" column="22" selection-start-line="75" selection-start-column="22" selection-end-line="75" selection-end-column="22" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/tests/model/PizzaTest.java">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="195">
|
||||
<caret line="13" selection-start-line="12" selection-end-line="13" />
|
||||
<folding>
|
||||
<element signature="imports" expanded="true" />
|
||||
<element signature="e#377#378#0" expanded="true" />
|
||||
<element signature="e#440#441#0" expanded="true" />
|
||||
</folding>
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/tests/model/OrderTest.java">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="1560">
|
||||
<caret line="112" column="40" selection-start-line="112" selection-start-column="40" selection-end-line="112" selection-end-column="40" />
|
||||
<folding>
|
||||
<element signature="imports" expanded="true" />
|
||||
</folding>
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
</component>
|
||||
<component name="masterDetails">
|
||||
<states>
|
||||
|
|
Binary file not shown.
Binary file not shown.
|
@ -22,6 +22,10 @@ class OrderTest {
|
|||
@Test
|
||||
void getCustomer() {
|
||||
assertEquals("Max Mustermann", order.getCustomer());
|
||||
}
|
||||
|
||||
@Test
|
||||
void getWrongCustomber() {
|
||||
assertNotEquals("Wrong", order.getCustomer());
|
||||
}
|
||||
|
||||
|
@ -29,12 +33,21 @@ class OrderTest {
|
|||
void setCustomer() {
|
||||
order.setCustomer("Max Mustermann 2");
|
||||
assertEquals("Max Mustermann 2", order.getCustomer());
|
||||
}
|
||||
|
||||
@Test
|
||||
void setWrongCustomer() {
|
||||
order.setCustomer("Max Mustermann 2");
|
||||
assertNotEquals("Max Mustermann", order.getCustomer());
|
||||
}
|
||||
|
||||
@Test
|
||||
void getPizzas() {
|
||||
assertEquals(pizzas, order.getPizzas());
|
||||
}
|
||||
|
||||
@Test
|
||||
void getWrongPizzas() {
|
||||
assertNotEquals(Arrays.asList(new Pizza(), new Pizza()), order.getPizzas());
|
||||
}
|
||||
|
||||
|
@ -43,11 +56,18 @@ class OrderTest {
|
|||
List<Pizza> newPizzas = new ArrayList<>(Arrays.asList(new Pizza(), new Pizza()));
|
||||
order.setPizzas(newPizzas);
|
||||
assertEquals(newPizzas, order.getPizzas());
|
||||
}
|
||||
|
||||
@Test
|
||||
void setPizzasUpdatesCorrectly() throws OrderException {
|
||||
List<Pizza> newPizzas = new ArrayList<>(Arrays.asList(new Pizza(), new Pizza()));
|
||||
order.setPizzas(newPizzas);
|
||||
assertNotEquals(pizzas, order.getPizzas());
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests if the exception is thrown when order is not in {@link model.Order.OrderState#IN_PROGRESS}
|
||||
* Tests if the exception is thrown when order is not in
|
||||
* {@link model.Order.OrderState#IN_PROGRESS}
|
||||
*/
|
||||
@Test
|
||||
void addPizzaAfterCompletion() {
|
||||
|
@ -67,18 +87,30 @@ class OrderTest {
|
|||
void setOrderState() {
|
||||
order.setOrderState(Order.OrderState.DELIVERD);
|
||||
assertEquals(Order.OrderState.DELIVERD, order.getOrderState());
|
||||
}
|
||||
|
||||
@Test
|
||||
void setOrderStateUpdatesCorrectly() {
|
||||
order.setOrderState(Order.OrderState.DELIVERD);
|
||||
assertNotEquals(Order.OrderState.WAIT, order.getOrderState());
|
||||
}
|
||||
|
||||
@Test
|
||||
void setWrongDate() {
|
||||
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));
|
||||
}
|
||||
|
||||
@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);
|
||||
c.add(Calendar.DAY_OF_MONTH, 19);
|
||||
Date currentDatePlus19d = c.getTime();
|
||||
assertDoesNotThrow(() -> order.setDate(currentDatePlus19d));
|
||||
}
|
||||
|
|
|
@ -16,10 +16,6 @@ class PizzaTest {
|
|||
pizza = pizzaServiceDummy.generateRandomPizza();
|
||||
}
|
||||
|
||||
@AfterEach
|
||||
void tearDown() {
|
||||
}
|
||||
|
||||
@Test
|
||||
void addTopping() {
|
||||
Pizza pizza2 = new Pizza();
|
||||
|
@ -34,6 +30,10 @@ class PizzaTest {
|
|||
Pizza.Size size = pizzaServiceDummy.getRandomSize();
|
||||
pizza.setSize(size);
|
||||
assertEquals(size, pizza.getSize());
|
||||
}
|
||||
|
||||
@Test
|
||||
void setSizeWorkingCorrectly() {
|
||||
pizza.setSize(Pizza.Size.LARGE);
|
||||
assertNotEquals(Pizza.Size.SMALL, pizza.getSize());
|
||||
}
|
||||
|
@ -42,6 +42,11 @@ class PizzaTest {
|
|||
void setName() {
|
||||
pizza.setName("Test 123");
|
||||
assertEquals("Test 123", pizza.getName());
|
||||
}
|
||||
|
||||
@Test
|
||||
void setNameWorkingCorreclty() {
|
||||
pizza.setName("Test 123");
|
||||
assertNotEquals("Wrong", pizza.getName());
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue