-
Notifications
You must be signed in to change notification settings - Fork 0
/
RestaurantServiceTest.java
69 lines (52 loc) · 3.01 KB
/
RestaurantServiceTest.java
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
import org.junit.jupiter.api.*;
import java.time.LocalTime;
import static org.junit.jupiter.api.Assertions.*;
class RestaurantServiceTest {
RestaurantService service = new RestaurantService();
Restaurant restaurant;
//REFACTOR ALL THE REPEATED LINES OF CODE
//>>>>>>>>>>>>>>>>>>>>>>SEARCHING<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
@Test
public void searching_for_existing_restaurant_should_return_expected_restaurant_object() throws restaurantNotFoundException {
//WRITE UNIT TEST CASE HERE
}
//You may watch the video by Muthukumaran on how to write exceptions in Course 3: Testing and Version control: Optional content
@Test
public void searching_for_non_existing_restaurant_should_throw_exception() throws restaurantNotFoundException {
//WRITE UNIT TEST CASE HERE
}
//<<<<<<<<<<<<<<<<<<<<SEARCHING>>>>>>>>>>>>>>>>>>>>>>>>>>
//>>>>>>>>>>>>>>>>>>>>>>ADMIN: ADDING & REMOVING RESTAURANTS<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
@Test
public void remove_restaurant_should_reduce_list_of_restaurants_size_by_1() throws restaurantNotFoundException {
LocalTime openingTime = LocalTime.parse("10:30:00");
LocalTime closingTime = LocalTime.parse("22:00:00");
restaurant = service.addRestaurant("Amelie's cafe","Chennai",openingTime,closingTime);
restaurant.addToMenu("Sweet corn soup",119);
restaurant.addToMenu("Vegetable lasagne", 269);
int initialNumberOfRestaurants = service.getRestaurants().size();
service.removeRestaurant("Amelie's cafe");
assertEquals(initialNumberOfRestaurants-1, service.getRestaurants().size());
}
@Test
public void removing_restaurant_that_does_not_exist_should_throw_exception() throws restaurantNotFoundException {
LocalTime openingTime = LocalTime.parse("10:30:00");
LocalTime closingTime = LocalTime.parse("22:00:00");
restaurant = service.addRestaurant("Amelie's cafe","Chennai",openingTime,closingTime);
restaurant.addToMenu("Sweet corn soup",119);
restaurant.addToMenu("Vegetable lasagne", 269);
assertThrows(restaurantNotFoundException.class,()->service.removeRestaurant("Pantry d'or"));
}
@Test
public void add_restaurant_should_increase_list_of_restaurants_size_by_1(){
LocalTime openingTime = LocalTime.parse("10:30:00");
LocalTime closingTime = LocalTime.parse("22:00:00");
restaurant = service.addRestaurant("Amelie's cafe","Chennai",openingTime,closingTime);
restaurant.addToMenu("Sweet corn soup",119);
restaurant.addToMenu("Vegetable lasagne", 269);
int initialNumberOfRestaurants = service.getRestaurants().size();
service.addRestaurant("Pumpkin Tales","Chennai",LocalTime.parse("12:00:00"),LocalTime.parse("23:00:00"));
assertEquals(initialNumberOfRestaurants + 1,service.getRestaurants().size());
}
//<<<<<<<<<<<<<<<<<<<<ADMIN: ADDING & REMOVING RESTAURANTS>>>>>>>>>>>>>>>>>>>>>>>>>>
}