1
1
package com .codedifferently .lesson16 .saiyanoop ;
2
2
3
3
import static org .junit .jupiter .api .Assertions .assertEquals ;
4
+ import static org .junit .jupiter .api .Assertions .fail ;
4
5
5
6
import com .codedifferently .lesson16 .saiyanoop .Saiyan .SaiyanForms ;
6
7
import java .util .ArrayList ;
@@ -14,20 +15,19 @@ void testgetPowerLevel() {
14
15
new Saiyan (
15
16
1200 ,
16
17
"Goku" ,
17
- new ArrayList <String >(Arrays .asList ("WristBands, Boots, Orange Gi, Blue Belt " )),
18
+ new ArrayList <String >(Arrays .asList ("Power Pole" , "Scouter" , "Flying Nimbus " )),
18
19
SaiyanForms .BASE ,
19
20
false );
20
21
assertEquals (1200 , saiyan .getPowerLevel ());
21
22
}
22
23
23
24
@ Test
24
- void testpowerLevelDroppingAndFormDown () {
25
+ void testpowerLevelDroppingAndFormDown () throws InvalidPowerLevelCustomExcepetion {
25
26
Saiyan saiyan =
26
27
new Saiyan (
27
28
4200 ,
28
29
"Goku" ,
29
- new ArrayList <String >(
30
- Arrays .asList ("WristBands, Boots, Orange Gi, Blue Belt, Blue Undershirt" )),
30
+ new ArrayList <String >(Arrays .asList ("Power Pole" , "Scouter" , "Flying Nimbus" )),
31
31
SaiyanForms .SSJ3 ,
32
32
false );
33
33
saiyan .setPowerLevel (3300 );
@@ -39,13 +39,12 @@ void testpowerLevelDroppingAndFormDown() {
39
39
}
40
40
41
41
@ Test
42
- void testpowerLevelRisingAndFormUp () {
42
+ void testpowerLevelRisingAndFormUp () throws InvalidPowerLevelCustomExcepetion {
43
43
Saiyan saiyan =
44
44
new Saiyan (
45
45
1200 ,
46
46
"Goku" ,
47
- new ArrayList <String >(
48
- Arrays .asList ("WristBands, Boots, Orange Gi, Blue Belt, Blue Undershirt" )),
47
+ new ArrayList <String >(Arrays .asList ("Power Pole" , "Scouter" , "Flying Nimbus" )),
49
48
SaiyanForms .BASE ,
50
49
false );
51
50
saiyan .setPowerLevel (2600 );
@@ -62,7 +61,7 @@ void testdoesHaveATail() {
62
61
new Saiyan (
63
62
1200 ,
64
63
"Goku" ,
65
- new ArrayList <String >(Arrays .asList ("WristBands, Boots, Orange Gi, Blue Belt " )),
64
+ new ArrayList <String >(Arrays .asList ("Power Pole" , "Scouter" , "Flying Nimbus " )),
66
65
SaiyanForms .BASE ,
67
66
false );
68
67
saiyan .setHasATail (true );
@@ -75,7 +74,7 @@ void testdoesNotHaveATail() {
75
74
new Saiyan (
76
75
1200 ,
77
76
"Goku" ,
78
- new ArrayList <String >(Arrays .asList ("WristBands, Boots, Orange Gi, Blue Belt " )),
77
+ new ArrayList <String >(Arrays .asList ("Power Pole" , "Scouter" , "Flying Nimbus " )),
79
78
SaiyanForms .BASE ,
80
79
false );
81
80
assertEquals (false , saiyan .isHasATail ());
@@ -87,7 +86,7 @@ void testgetName() {
87
86
new Saiyan (
88
87
1200 ,
89
88
"Goku" ,
90
- new ArrayList <String >(Arrays .asList ("WristBands, Boots, Orange Gi, Blue Belt " )),
89
+ new ArrayList <String >(Arrays .asList ("Power Pole" , "Scouter" , "Flying Nimbus " )),
91
90
SaiyanForms .BASE ,
92
91
false );
93
92
assertEquals ("Goku" , saiyan .getName ());
@@ -99,16 +98,79 @@ void testsetName() {
99
98
new Saiyan (
100
99
1200 ,
101
100
"Goku" ,
102
- new ArrayList <String >(Arrays .asList ("WristBands, Boots, Orange Gi, Blue Belt " )),
101
+ new ArrayList <String >(Arrays .asList ("Power Pole" , "Scouter" , "Flying Nimbus " )),
103
102
SaiyanForms .BASE ,
104
103
false );
105
104
saiyan .setName ("Kakarot" );
106
105
assertEquals ("Kakarot" , saiyan .getName ());
107
106
}
108
107
109
108
@ Test
110
- void testwhatAccessoriesTheyHaveOn () {}
109
+ void testgetAnAccessory () {
110
+ Saiyan saiyan =
111
+ new Saiyan (
112
+ 1200 ,
113
+ "Goku" ,
114
+ new ArrayList <String >(Arrays .asList ("Power Pole" , "Scouter" , "Flying Nimbus" )),
115
+ SaiyanForms .BASE ,
116
+ false );
117
+ assertEquals ("Power Pole" , saiyan .getAccessories ().get (0 ));
118
+ }
119
+
120
+ @ Test
121
+ void testaddingAnAccessory () {
122
+ Saiyan saiyan =
123
+ new Saiyan (
124
+ 1200 ,
125
+ "Goku" ,
126
+ new ArrayList <String >(Arrays .asList ("Power Pole" , "Scouter" , "Flying Nimbus" )),
127
+ SaiyanForms .BASE ,
128
+ false );
129
+ saiyan .addAccessories ("Senzu Bean" );
130
+ assertEquals (4 , saiyan .getAccessories ().size ());
131
+ }
132
+
133
+ @ Test
134
+ void testremovingAllAccessories () {
135
+ Saiyan saiyan =
136
+ new Saiyan (
137
+ 1200 ,
138
+ "Goku" ,
139
+ new ArrayList <String >(Arrays .asList ("Power Pole" , "Scouter" , "Flying Nimbus" )),
140
+ SaiyanForms .BASE ,
141
+ false );
142
+ saiyan .removeAllAccessories ();
143
+ assertEquals (0 , saiyan .getAccessories ().size ());
144
+ }
111
145
112
146
@ Test
113
- void test () {}
147
+ void testremoveAccessories () {
148
+ Saiyan saiyan =
149
+ new Saiyan (
150
+ 1200 ,
151
+ "Goku" ,
152
+ new ArrayList <String >(Arrays .asList ("Power Pole" , "Scouter" , "Flying Nimbus" )),
153
+ SaiyanForms .BASE ,
154
+ false );
155
+ saiyan .removeAccessories ("Power Pole" );
156
+ assertEquals (2 , saiyan .getAccessories ().size ());
157
+ }
158
+
159
+ @ Test
160
+ void testcanNotGetZeroOrNegativePowerLevel () throws InvalidPowerLevelCustomExcepetion {
161
+ Saiyan saiyan =
162
+ new Saiyan (
163
+ 1200 ,
164
+ "Goku" ,
165
+ new ArrayList <String >(Arrays .asList ("Power Pole" , "Scouter" , "Flying Nimbus" )),
166
+ SaiyanForms .BASE ,
167
+ false );
168
+
169
+ try {
170
+ saiyan .setPowerLevel (-10 );
171
+ fail ("Expected InvalidPowerLevelCustomException to be thrown" );
172
+ } catch (InvalidPowerLevelCustomExcepetion e ) {
173
+ assertEquals ("Power Level can not be zero or less!" , e .getMessage ());
174
+ }
175
+ }
114
176
}
0 commit comments