-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPropertiesModelTest.java
More file actions
235 lines (210 loc) · 6.8 KB
/
PropertiesModelTest.java
File metadata and controls
235 lines (210 loc) · 6.8 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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
import static org.junit.jupiter.api.Assertions.*;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
/**
* The test class PropertiesModelTest.
*
* @author Kwan Yui Chiu (K21003778)
* @version 15-03-2022
*/
public class PropertiesModelTest
{
private PropertiesModel properti1;
/**
* Default constructor for test class PropertiesModelTest
*/
public PropertiesModelTest()
{
}
/**
* Sets up the test fixture.
*
* Called before every test case method.
*/
@BeforeEach
public void setUp()
{
this.properti1 = new PropertiesModel();
}
/**
* Tears down the test fixture.
*
* Called after every test case method.
*/
@AfterEach
public void tearDown()
{
}
/**
* A test for the test class to work
*/
@Test
public void emptyTest()
{
assertTrue(true);
}
/**
* Test if data is loaded successfully
*/
@Test
public void canLoadData()
{
assertEquals(53904,this.properti1.getProperties().size());
assertTrue("property-london.csv".equals(this.properti1.getFileName()));
}
/**
* Test if different files can be loaded
*/
@Test
public void canLoadSeperateData()
{
PropertiesModel p2 = new PropertiesModel("property-bristol.csv");
assertEquals(1631,p2.getProperties().size());
assertTrue("property-bristol.csv".equals(p2.getFileName()));
}
/**
* Test for getting the correct most expensive borough
*/
@Test
public void getCorrectMostExpensiveBorough()
{
assertTrue(this.properti1.getMostExpensiveBorough().equals("Westminster"));
}
/**
* Test for getting correct number of borough
*/
@Test
public void getCorrectNoBorough()
{
assertEquals(33,this.properti1.noPropertiesPerBorough(13).size());
}
/**
* Test for getting correct number of homes or apartments from london data set
*/
@Test
public void getCorrectNumberHomesOrApart()
{
assertEquals(27175,this.properti1.getNumberOfHomesOrApart());
}
/**
* Test for getting correct average of number of reviews from london data set
*/
@Test
public void getCorrectAverageNumberReviews()
{
assertEquals("12.47",this.properti1.getAverageNumberReviews());
}
/**
* Test for getting correct number of properties with no price filters
*/
@Test
public void getCorrectNumberPropertiesWithNoBound()
{
assertEquals(33,this.properti1.noPropertiesPerBorough().size());
assertEquals(5613,this.properti1.noPropertiesPerBorough().get("Tower Hamlets"));
}
/**
* Test for getting correct number of properties with lower bound filter from london data set
*/
@Test
public void getCorrectNumberPropertiesWithLB()
{
assertEquals(33,this.properti1.noPropertiesPerBorough(100).size());
assertEquals(4184,this.properti1.noPropertiesPerBorough(100).get("Westminster"));
}
/**
* Test for getting correct number of properties with LB and UB price filter from london data set
*/
@Test
public void getCorrectNumberPropertiesWithLB_andUB()
{
assertEquals(33,this.properti1.noPropertiesPerBorough(100,10000).size());
assertEquals(4160,this.properti1.noPropertiesPerBorough(100,10000).get("Westminster"));
}
/**
* Test for getting correct list of properties with LB and UB price filter from london data set
*/
@Test
public void getCorrectNumberPropertiesWithLB_andUB_withPropertiesObject()
{
assertEquals(4160,this.properti1.getPropertiesWithinSpecificRange("Westminster", 100, 10000).size());
assertTrue(this.properti1.getPropertiesWithinSpecificRange("Westminster", 100, 10000).get(0) instanceof PropertyListing);
}
/**
* Test for getting correct cheapest price of properties with no price filter from london data set
*/
@Test
public void getCorrectCheapestPropertyWithNoBound()
{
assertEquals(33,this.properti1.noPropertiesPerBorough().size());
assertEquals(8,this.properti1.minPricePerNight());
}
/**
* Test for getting correct cheapest price of properties with LB price filter from london data set
*/
@Test
public void getCorrectCheapestPropertyWithLB()
{
assertEquals(33,this.properti1.noPropertiesPerBorough(100).size());
assertEquals(100,this.properti1.minPricePerNight(100));
}
/**
* Test for getting correct cheapest price of properties with LB and UB price filter from london data set
*/
@Test
public void getCorrectCheapestPropertyWithLB_andUB()
{
assertEquals(33,this.properti1.noPropertiesPerBorough(100,10000).size());
assertEquals(100,this.properti1.minPricePerNight(100, 10000));
}
/**
* Test for getting correct most expensive price of properties with no price filter from london data set
*/
@Test
public void getCorrectExpensivePropertyWithNoBound()
{
assertEquals(33,this.properti1.noPropertiesPerBorough().size());
assertEquals(2000000,this.properti1.maxPricePerNight());
}
/**
* Test for getting correct most expensive price of properties with LB price filter from london data set
*/
@Test
public void getCorrectExpensivePropertyWithLB()
{
assertEquals(33,this.properti1.noPropertiesPerBorough(100).size());
assertEquals(2000000,this.properti1.maxPricePerNight(100));
}
/**
* Test for getting correct most expensive price of properties with UB and LB price filter from london data set
*/
@Test
public void getCorrectExpensivePropertyWithLB_andUB()
{
assertEquals(33,this.properti1.noPropertiesPerBorough(100,10000).size());
assertEquals(9900,this.properti1.maxPricePerNight(100, 10000));
}
/**
* Test for getting correct most host listing count borough from london data set
*/
@Test
public void getCorrectMostCalculatedHostListingCountBorough()
{
assertTrue(this.properti1.getBoroughWithHighestListingCount().equals("Kensington and Chelsea"));
}
/**
* Test for getting correct most listing host from london data set
*/
@Test
public void getCorrectHostWithMostListing(){
assertTrue("Tom".equals(this.properti1.getHostWithMostListing()));
}
/**
* Test for getting correct most listing ID with longest available period from london data set
*/
@Test
public void getCorrectListingIDWithLongestAvailablePeriod(){
assertTrue("735298".equals(this.properti1.getListingIDOfPropertyWithLongestAvailablePeriod()));
}
}