23
23
24
24
package com .iluwatar .abstractdocument ;
25
25
26
+ import static org .junit .jupiter .api .Assertions .assertEquals ;
27
+
26
28
import com .iluwatar .abstractdocument .domain .Car ;
27
29
import com .iluwatar .abstractdocument .domain .Part ;
28
30
import com .iluwatar .abstractdocument .domain .enums .Property ;
29
- import org .junit .jupiter .api .Test ;
30
-
31
31
import java .util .List ;
32
32
import java .util .Map ;
33
-
34
- import static org .junit .jupiter .api .Assertions .assertEquals ;
33
+ import org .junit .jupiter .api .Test ;
35
34
36
35
/**
37
36
* Test for Part and Car
@@ -47,27 +46,27 @@ public class DomainTest {
47
46
48
47
@ Test
49
48
public void shouldConstructPart () {
50
- Map < String , Object > partProperties = Map .of (
51
- Property .TYPE .toString (), TEST_PART_TYPE ,
52
- Property .MODEL .toString (), TEST_PART_MODEL ,
53
- Property .PRICE .toString (), TEST_PART_PRICE );
54
- Part part = new Part ( partProperties );
55
-
56
- assertEquals (TEST_PART_TYPE , part .getType ().get ());
57
- assertEquals (TEST_PART_MODEL , part .getModel ().get ());
58
- assertEquals (TEST_PART_PRICE , part .getPrice ().get ());
49
+ var partProperties = Map .of (
50
+ Property .TYPE .toString (), TEST_PART_TYPE ,
51
+ Property .MODEL .toString (), TEST_PART_MODEL ,
52
+ Property .PRICE .toString (), ( Object ) TEST_PART_PRICE
53
+ );
54
+ var part = new Part ( partProperties );
55
+ assertEquals (TEST_PART_TYPE , part .getType ().orElseThrow ());
56
+ assertEquals (TEST_PART_MODEL , part .getModel ().orElseThrow ());
57
+ assertEquals (TEST_PART_PRICE , part .getPrice ().orElseThrow ());
59
58
}
60
59
61
60
@ Test
62
61
public void shouldConstructCar () {
63
- Map < String , Object > carProperties = Map .of (
64
- Property .MODEL .toString (), TEST_CAR_MODEL ,
65
- Property .PRICE .toString (), TEST_CAR_PRICE ,
66
- Property .PARTS .toString (), List .of (Map .of (), Map .of ()));
67
- Car car = new Car ( carProperties );
68
-
69
- assertEquals (TEST_CAR_MODEL , car .getModel ().get ());
70
- assertEquals (TEST_CAR_PRICE , car .getPrice ().get ());
62
+ var carProperties = Map .of (
63
+ Property .MODEL .toString (), TEST_CAR_MODEL ,
64
+ Property .PRICE .toString (), TEST_CAR_PRICE ,
65
+ Property .PARTS .toString (), List .of (Map .of (), Map .of ())
66
+ );
67
+ var car = new Car ( carProperties );
68
+ assertEquals (TEST_CAR_MODEL , car .getModel ().orElseThrow ());
69
+ assertEquals (TEST_CAR_PRICE , car .getPrice ().orElseThrow ());
71
70
assertEquals (2 , car .getParts ().count ());
72
71
}
73
72
0 commit comments