11package com .codedifferently .lesson16 .saiyanoop ;
22
33import static org .junit .jupiter .api .Assertions .assertEquals ;
4+ import static org .junit .jupiter .api .Assertions .fail ;
45
56import com .codedifferently .lesson16 .saiyanoop .Saiyan .SaiyanForms ;
67import java .util .ArrayList ;
@@ -14,20 +15,19 @@ void testgetPowerLevel() {
1415 new Saiyan (
1516 1200 ,
1617 "Goku" ,
17- new ArrayList <String >(Arrays .asList ("WristBands, Boots, Orange Gi, Blue Belt " )),
18+ new ArrayList <String >(Arrays .asList ("Power Pole" , "Scouter" , "Flying Nimbus " )),
1819 SaiyanForms .BASE ,
1920 false );
2021 assertEquals (1200 , saiyan .getPowerLevel ());
2122 }
2223
2324 @ Test
24- void testpowerLevelDroppingAndFormDown () {
25+ void testpowerLevelDroppingAndFormDown () throws InvalidPowerLevelCustomExcepetion {
2526 Saiyan saiyan =
2627 new Saiyan (
2728 4200 ,
2829 "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" )),
3131 SaiyanForms .SSJ3 ,
3232 false );
3333 saiyan .setPowerLevel (3300 );
@@ -39,13 +39,12 @@ void testpowerLevelDroppingAndFormDown() {
3939 }
4040
4141 @ Test
42- void testpowerLevelRisingAndFormUp () {
42+ void testpowerLevelRisingAndFormUp () throws InvalidPowerLevelCustomExcepetion {
4343 Saiyan saiyan =
4444 new Saiyan (
4545 1200 ,
4646 "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" )),
4948 SaiyanForms .BASE ,
5049 false );
5150 saiyan .setPowerLevel (2600 );
@@ -62,7 +61,7 @@ void testdoesHaveATail() {
6261 new Saiyan (
6362 1200 ,
6463 "Goku" ,
65- new ArrayList <String >(Arrays .asList ("WristBands, Boots, Orange Gi, Blue Belt " )),
64+ new ArrayList <String >(Arrays .asList ("Power Pole" , "Scouter" , "Flying Nimbus " )),
6665 SaiyanForms .BASE ,
6766 false );
6867 saiyan .setHasATail (true );
@@ -75,7 +74,7 @@ void testdoesNotHaveATail() {
7574 new Saiyan (
7675 1200 ,
7776 "Goku" ,
78- new ArrayList <String >(Arrays .asList ("WristBands, Boots, Orange Gi, Blue Belt " )),
77+ new ArrayList <String >(Arrays .asList ("Power Pole" , "Scouter" , "Flying Nimbus " )),
7978 SaiyanForms .BASE ,
8079 false );
8180 assertEquals (false , saiyan .isHasATail ());
@@ -87,7 +86,7 @@ void testgetName() {
8786 new Saiyan (
8887 1200 ,
8988 "Goku" ,
90- new ArrayList <String >(Arrays .asList ("WristBands, Boots, Orange Gi, Blue Belt " )),
89+ new ArrayList <String >(Arrays .asList ("Power Pole" , "Scouter" , "Flying Nimbus " )),
9190 SaiyanForms .BASE ,
9291 false );
9392 assertEquals ("Goku" , saiyan .getName ());
@@ -99,16 +98,79 @@ void testsetName() {
9998 new Saiyan (
10099 1200 ,
101100 "Goku" ,
102- new ArrayList <String >(Arrays .asList ("WristBands, Boots, Orange Gi, Blue Belt " )),
101+ new ArrayList <String >(Arrays .asList ("Power Pole" , "Scouter" , "Flying Nimbus " )),
103102 SaiyanForms .BASE ,
104103 false );
105104 saiyan .setName ("Kakarot" );
106105 assertEquals ("Kakarot" , saiyan .getName ());
107106 }
108107
109108 @ 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+ }
111145
112146 @ 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+ }
114176}
0 commit comments