-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMonitoringTest.java
More file actions
131 lines (107 loc) · 6.05 KB
/
Copy pathMonitoringTest.java
File metadata and controls
131 lines (107 loc) · 6.05 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
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;
import java.util.ArrayList;
/**
* The test class for Monitoring class.
*/
class MonitoringTest {
@Test
void getLargestAverageObservatory()
{
Monitoring monitoring = new Monitoring();
Earthquake earthquake1 = new Earthquake(8.6, 34.5, 55.3, 1981);
Earthquake earthquake2 = new Earthquake(9.9, 54.2, 67.8, 1998);
Earthquake earthquake3 = new Earthquake(6.4, 75.3, 45.6, 1957);
Observatory observatory1 = new Observatory("Newcastle", "UK", 1951, 30.5);
observatory1.earthquakeList.add(earthquake1);
observatory1.earthquakeList.add(earthquake2);
observatory1.earthquakeList.add(earthquake3);
Earthquake earthquake4 = new Earthquake(3.4, -65.0, 34.6, 1921);
Earthquake earthquake5 = new Earthquake(5.3, 65.7, 72.8, 1943);
Earthquake earthquake6 = new Earthquake(7.2, 124.6, -75.3, 1898);
Observatory observatory2 = new Observatory("London", "UK", 1896, 59.3);
observatory2.earthquakeList.add(earthquake4);
observatory2.earthquakeList.add(earthquake5);
observatory2.earthquakeList.add(earthquake6);
Earthquake earthquake7 = new Earthquake(5.6, 76.7, -34.6, 1911);
Earthquake earthquake8 = new Earthquake(4.7, -67.4, 156.8, 1955);
Earthquake earthquake9 = new Earthquake(8.3, 56.4, -111.1, 1949);
Observatory observatory3 = new Observatory("Madrid", "Spain", 1910, 49.6);
observatory3.earthquakeList.add(earthquake7);
observatory3.earthquakeList.add(earthquake8);
observatory3.earthquakeList.add(earthquake9);
monitoring.observatoryList.add(observatory1);
monitoring.observatoryList.add(observatory2);
monitoring.observatoryList.add(observatory3);
assertEquals(observatory1, monitoring.getLargestAverageObservatory());
}
@Test
void getLargestMagnitudeRecord()
{
Monitoring monitoring = new Monitoring();
Earthquake earthquake1 = new Earthquake(8.6, 34.5, 55.3, 1981);
Earthquake earthquake2 = new Earthquake(9.9, 54.2, 67.8, 1998);
Earthquake earthquake3 = new Earthquake(6.4, 75.3, 45.6, 1957);
Observatory observatory1 = new Observatory("Newcastle", "UK", 1951, 30.5);
observatory1.earthquakeList.add(earthquake1);
observatory1.earthquakeList.add(earthquake2);
observatory1.earthquakeList.add(earthquake3);
Earthquake earthquake4 = new Earthquake(3.4, -65.0, 34.6, 1921);
Earthquake earthquake5 = new Earthquake(5.3, 65.7, 72.8, 1943);
Earthquake earthquake6 = new Earthquake(7.2, 124.6, -75.3, 1898);
Observatory observatory2 = new Observatory("London", "UK", 1896, 59.3);
observatory2.earthquakeList.add(earthquake4);
observatory2.earthquakeList.add(earthquake5);
observatory2.earthquakeList.add(earthquake6);
Earthquake earthquake7 = new Earthquake(5.6, 76.7, -34.6, 1911);
Earthquake earthquake8 = new Earthquake(4.7, -67.4, 156.8, 1955);
Earthquake earthquake9 = new Earthquake(8.3, 56.4, -111.1, 1949);
Observatory observatory3 = new Observatory("Madrid", "Spain", 1910, 49.6);
observatory3.earthquakeList.add(earthquake7);
observatory3.earthquakeList.add(earthquake8);
observatory3.earthquakeList.add(earthquake9);
monitoring.observatoryList.add(observatory1);
monitoring.observatoryList.add(observatory2);
monitoring.observatoryList.add(observatory3);
assertEquals(9.9, monitoring.getLargestMagnitudeRecord().getLargestMagnitude());
}
@Test
void getAllGreaterThanGivenNumber()
{
Monitoring monitoring = new Monitoring();
Earthquake earthquake1 = new Earthquake(8.6, 34.5, 55.3, 1981);
Earthquake earthquake2 = new Earthquake(9.9, 54.2, 67.8, 1998);
Earthquake earthquake3 = new Earthquake(6.4, 75.3, 45.6, 1957);
Observatory observatory1 = new Observatory("Newcastle", "UK", 1951, 30.5);
observatory1.earthquakeList.add(earthquake1);
observatory1.earthquakeList.add(earthquake2);
observatory1.earthquakeList.add(earthquake3);
Earthquake earthquake4 = new Earthquake(3.4, -65.0, 34.6, 1921);
Earthquake earthquake5 = new Earthquake(5.3, 65.7, 72.8, 1943);
Earthquake earthquake6 = new Earthquake(7.2, 124.6, -75.3, 1898);
Observatory observatory2 = new Observatory("London", "UK", 1896, 59.3);
observatory2.earthquakeList.add(earthquake4);
observatory2.earthquakeList.add(earthquake5);
observatory2.earthquakeList.add(earthquake6);
Earthquake earthquake7 = new Earthquake(5.6, 76.7, -34.6, 1911);
Earthquake earthquake8 = new Earthquake(4.7, -67.4, 156.8, 1955);
Earthquake earthquake9 = new Earthquake(8.3, 56.4, -111.1, 1949);
Observatory observatory3 = new Observatory("Madrid", "Spain", 1910, 49.6);
observatory3.earthquakeList.add(earthquake7);
observatory3.earthquakeList.add(earthquake8);
observatory3.earthquakeList.add(earthquake9);
monitoring.observatoryList.add(observatory1);
monitoring.observatoryList.add(observatory2);
monitoring.observatoryList.add(observatory3);
ArrayList<Earthquake> earthquakeListGreaterThanGivenNumber = monitoring.getAllGreaterThanGivenNumber(6.5);
assertTrue(earthquakeListGreaterThanGivenNumber.contains(earthquake1));
assertTrue(earthquakeListGreaterThanGivenNumber.contains(earthquake2));
assertFalse(earthquakeListGreaterThanGivenNumber.contains(earthquake3));
assertFalse(earthquakeListGreaterThanGivenNumber.contains(earthquake4));
assertFalse(earthquakeListGreaterThanGivenNumber.contains(earthquake5));
assertTrue(earthquakeListGreaterThanGivenNumber.contains(earthquake6));
assertFalse(earthquakeListGreaterThanGivenNumber.contains(earthquake7));
assertFalse(earthquakeListGreaterThanGivenNumber.contains(earthquake8));
assertTrue(earthquakeListGreaterThanGivenNumber.contains(earthquake9));
}
}