-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathPartitioningMenuTest.java
More file actions
50 lines (42 loc) · 1.62 KB
/
PartitioningMenuTest.java
File metadata and controls
50 lines (42 loc) · 1.62 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
package com.example.modernjava.chapter06;
import com.example.modernjava.data.DishData;
import com.example.modernjava.record.Dish;
import lombok.extern.slf4j.Slf4j;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import java.util.List;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
@Slf4j
class PartitioningMenuTest {
private List<Dish> menu;
@BeforeEach
void setUp() {
menu = DishData.DISHES;
}
@Test
void testPartitionByVegetarian() {
final var result = PartitioningMenu.partitionByVegetarian(menu);
assertNotNull(result);
assertEquals(4, result.get(true).size());
assertEquals(5, result.get(false).size());
log.info("Dishes partitioned by vegetarian: {}", result);
}
@Test
void testVegetarianDishesByType() {
final var result = PartitioningMenu.vegetarianDishesByType(menu);
assertNotNull(result);
assertEquals(4, result.get(true).get(Dish.Type.OTHER).size());
assertEquals(2, result.get(false).get(Dish.Type.FISH).size());
assertEquals(3, result.get(false).get(Dish.Type.MEAT).size());
log.info("Vegetarian dishes by type: {}", result);
}
@Test
void testMostCaloricPartitionedByVegetarian() {
final var result = PartitioningMenu.mostCaloricPartitionedByVegetarian(menu);
assertNotNull(result);
assertEquals("pizza", result.get(true).name());
assertEquals("pork", result.get(false).name());
log.info("Most caloric partitioned by vegetarian: {}", result);
}
}