1
1
package domain ;
2
2
3
- import org .jetbrains .annotations .NotNull ;
4
3
import org .junit .jupiter .api .*;
5
4
6
5
public class EngineTest {
@@ -11,7 +10,6 @@ public void setUp() {
11
10
engine = new Engine ();
12
11
}
13
12
14
- @ NotNull
15
13
public static Order constructOrder (int id , int customer , int price , int quantity ) {
16
14
Order order = new Order ();
17
15
order .setId (id );
@@ -26,14 +24,12 @@ public static Order constructOrder(int id, int customer, int price, int quantity
26
24
@ Test
27
25
@ DisplayName ("Test average quantity with no orders" )
28
26
public void testAverageQuantityNoOrders () {
29
- setUp ();
30
27
Assertions .assertEquals (0 , engine .getAverageOrderQuantityByCustomer (1 ));
31
28
}
32
29
33
30
@ Test
34
31
@ DisplayName ("Test average quantity with one order" )
35
32
public void testAverageQuantityOneOrder () {
36
- setUp ();
37
33
Order order = constructOrder (0 , 1 , 4 , 2 );
38
34
engine .orderHistory .add (order );
39
35
Assertions .assertEquals (2 , engine .getAverageOrderQuantityByCustomer (1 ));
@@ -42,7 +38,6 @@ public void testAverageQuantityOneOrder() {
42
38
@ Test
43
39
@ DisplayName ("Test average quantity with multiple orders" )
44
40
public void testAverageQuantityMultipleOrders () {
45
- setUp ();
46
41
Order order = constructOrder (0 , 1 , 4 , 2 );
47
42
Order order2 = constructOrder (1 , 1 , 8 , 6 );
48
43
engine .orderHistory .add (order );
@@ -53,7 +48,6 @@ public void testAverageQuantityMultipleOrders() {
53
48
@ Test
54
49
@ DisplayName ("Test average quantity with unknown customer" )
55
50
public void testAverageQuantityUnknownCustomer () {
56
- setUp ();
57
51
Order order = constructOrder (0 , 1 , 4 , 2 );
58
52
engine .orderHistory .add (order );
59
53
Assertions .assertThrows (Exception .class , () -> engine .getAverageOrderQuantityByCustomer (2 ));
@@ -64,14 +58,12 @@ public void testAverageQuantityUnknownCustomer() {
64
58
@ Test
65
59
@ DisplayName ("Test quantity pattern with no orders" )
66
60
public void testQuantityPatternNoOrders () {
67
- setUp ();
68
61
Assertions .assertEquals (0 , engine .getQuantityPatternByPrice (1 ));
69
62
}
70
63
71
64
@ Test
72
65
@ DisplayName ("Test quantity pattern with linear increasing quantity for a price" )
73
66
public void testQuantityPatternWithPattern () {
74
- setUp ();
75
67
Order order = constructOrder (0 , 1 , 4 , 2 );
76
68
Order order2 = constructOrder (1 , 2 , 4 , 8 );
77
69
Order order3 = constructOrder (2 , 2 , 4 , 14 );
@@ -84,7 +76,6 @@ public void testQuantityPatternWithPattern() {
84
76
@ Test
85
77
@ DisplayName ("Test quantity pattern without pattern" )
86
78
public void testQuantityPatternWithoutPattern () {
87
- setUp ();
88
79
Order order = constructOrder (0 , 1 , 4 , 2 );
89
80
Order order2 = constructOrder (1 , 2 , 4 , 8 );
90
81
Order order3 = constructOrder (2 , 2 , 4 , 13 );
@@ -97,7 +88,6 @@ public void testQuantityPatternWithoutPattern() {
97
88
@ Test
98
89
@ DisplayName ("Test quantity pattern with pattern and different prices" )
99
90
public void testQuantityPatternWithPatternAndDifferentPrices () {
100
- setUp ();
101
91
Order order = constructOrder (0 , 1 , 4 , 2 );
102
92
Order order2 = constructOrder (1 , 2 , 4 , 8 );
103
93
Order order3 = constructOrder (2 , 2 , 5 , 13 );
@@ -114,7 +104,6 @@ public void testQuantityPatternWithPatternAndDifferentPrices() {
114
104
@ Test
115
105
@ DisplayName ("Test fraudulent quantity with order quantity more than the average" )
116
106
public void testFraudulentQuantityMoreThanAvg () {
117
- setUp ();
118
107
Order order = constructOrder (0 , 1 , 4 , 2 );
119
108
Order order2 = constructOrder (1 , 1 , 8 , 6 );
120
109
engine .orderHistory .add (order );
@@ -124,7 +113,6 @@ public void testFraudulentQuantityMoreThanAvg() {
124
113
@ Test
125
114
@ DisplayName ("Test fraudulent quantity with order quantity equal to the average" )
126
115
public void testFraudulentQuantityEqualToAvg () {
127
- setUp ();
128
116
Order order = constructOrder (0 , 1 , 4 , 2 );
129
117
engine .orderHistory .add (order );
130
118
Assertions .assertEquals (0 , engine .getCustomerFraudulentQuantity (order ));
@@ -133,7 +121,6 @@ public void testFraudulentQuantityEqualToAvg() {
133
121
@ Test
134
122
@ DisplayName ("Test fraudulent quantity with order quantity less than the average" )
135
123
public void testFraudulentQuantityLessThanAvg () {
136
- setUp ();
137
124
Order order = constructOrder (0 , 1 , 4 , 2 );
138
125
Order order2 = constructOrder (1 , 1 , 8 , 6 );
139
126
engine .orderHistory .add (order2 );
@@ -145,7 +132,6 @@ public void testFraudulentQuantityLessThanAvg() {
145
132
@ Test
146
133
@ DisplayName ("Test adding already existing order" )
147
134
public void testAddingAlreadyExistingOrder () {
148
- setUp ();
149
135
Order order = constructOrder (0 , 1 , 4 , 2 );
150
136
engine .orderHistory .add (order );
151
137
Assertions .assertEquals (0 , engine .addOrderAndGetFraudulentQuantity (order ));
@@ -154,7 +140,6 @@ public void testAddingAlreadyExistingOrder() {
154
140
@ Test
155
141
@ DisplayName ("Test adding order and getting fraudulent quantity (if not 0)" )
156
142
public void testAddOrderAndGetFraudulent () {
157
- setUp ();
158
143
Order order = constructOrder (0 , 1 , 4 , 2 );
159
144
Order order2 = constructOrder (1 , 1 , 8 , 6 );
160
145
engine .orderHistory .add (order );
@@ -165,7 +150,6 @@ public void testAddOrderAndGetFraudulent() {
165
150
@ Test
166
151
@ DisplayName ("Test adding order and getting fraudulent quantity of 0 (should return pattern)" )
167
152
public void testAddOrderAndGetFraudulentBelowAvg () {
168
- setUp ();
169
153
Order order = constructOrder (0 , 1 , 4 , 8 );
170
154
Order order2 = constructOrder (1 , 1 , 4 , 14 );
171
155
Order order3 = constructOrder (2 , 1 , 4 , 2 );
0 commit comments