-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOrderTest.java
More file actions
144 lines (134 loc) · 4.36 KB
/
Copy pathOrderTest.java
File metadata and controls
144 lines (134 loc) · 4.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
import static org.junit.Assert.*;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
/**
* The test class OrderTest.
*
* @author David J. Barnes and Michael Kölling
* @version 2016.02.29
* @version 2024.10.07 DP classes
*/
public class OrderTest
{
Order order1;
Order order2;
Order order3;
Location location1;
Location destination1;
Location location2;
Location destination2;
Location location3;
Location destination3;
/**
* Default constructor for test class OrderTest
*/
public OrderTest()
{
}
/**
* Sets up the test fixture.
*
* Called before every test case method.
*/
@Before
public void setUp()
{
location1 = new Location(3,5);
destination1 = new Location(6,1);
location2 = new Location(8,3);
destination2 = new Location(2,6);
location3 = new Location(13,5);
destination3 = new Location(4,10);
order1 = new UrgentOrder("Pablo", location1, destination1, 11, 1.6, "Banana Vintage Cáceres",
Surcharge.MEDIUM, Urgency.IMPORTANT);
order2 = new MedicalOrder("Lucía", location2, destination2, 16, 2.4, "Decathlon Cáceres",
Urgency.EMERGENCY);
order3 = new NonUrgentOrder("Pepe", location3, destination3, 19, 3.6, "Ferretería AlClavo",
Surcharge.LOW, Urgency.NONESSENTIAL);
}
/**
* Tears down the test fixture.
*
* Called after every test case method.
*/
@After
public void tearDown()
{
}
/**
* Test basic creation of an order.
* Ensure that the location and destination locations
* have been set.
*/
@Test
public void testCreation()
{
assertEquals("Pablo", order1.getSendingName());
assertEquals(location1, order1.getLocation());
assertEquals(destination1, order1.getDestination());
assertEquals(11, order1.getDeliveryTime());
assertEquals(1.6, order1.getWeight(), 0.001);
assertEquals("Banana Vintage Cáceres", order1.getDestinationName());
//Misma prueba realizada de otra manera:
//para location
assertEquals(order1.getLocation().getX(),3);
assertEquals(order1.getLocation().getY(),5);
//para destination
assertEquals(order1.getDestination().getX(),6);
assertEquals(order1.getDestination().getY(),1);
}
/**
* Test of the getDeliveryPersonName method.
* Ensure that this method gets and returns the name of the delivery person correctly.
*/
@Test
public void testGetDeliveryPersonName()
{
order2.setDeliveryPersonName("Felicia");
assertEquals("Felicia", order2.getDeliveryPersonName());
//Misma prueba utilizando otra aserción:
assertTrue(order2.getDeliveryPersonName() == "Felicia");
}
/**
* Test of the getDestination method.
* Ensure that this method gets and returns the destination location correctly.
*/
@Test
public void testGetDestination ()
{
assertEquals(order3.getDestination(),destination3);
//Misma prueba utilizando otra aserción:
assertTrue(order3.getDestination() == destination3);
}
/**
* Test of the charge method.
* Ensure that this method gets and returns the surcharge value correctly.
*/
@Test
public void getCharge ()
{
assertEquals(order1.charge(), 20);
assertEquals(order2.charge(), 0);
assertEquals(order3.charge(), 4);
//Misma prueba utilizando otra aserción:
assertTrue(order1.charge() == 20);
assertTrue(order2.charge() == 0);
assertTrue(order3.charge() == 4);
}
/**
* Test of the calculateEvaluationDP method.
* Ensure that this method gets and returns the new valoration value of the delivery person correctly.
*/
@Test
public void testCalculateEvaluationDP ()
{
assertEquals(order1.calculateEvaluationDP(), 10);
assertEquals(order2.calculateEvaluationDP(), 15);
assertEquals(order3.calculateEvaluationDP(), 5);
//Misma prueba utilizando otra aserción:
assertTrue(order1.calculateEvaluationDP() == 10);
assertTrue(order2.calculateEvaluationDP() == 15);
assertTrue(order3.calculateEvaluationDP() == 5);
}
}