33import com .baeldung .templatemethodpattern .model .HighEndComputer ;
44import com .baeldung .templatemethodpattern .model .StandardComputer ;
55import org .junit .Assert ;
6+ import static org .junit .Assert .assertEquals ;
67import org .junit .BeforeClass ;
78import org .junit .Test ;
89
910public class TemplateMethodPatternTest {
10-
11+
1112 private static StandardComputer standardComputer ;
1213 private static HighEndComputer highEndComputer ;
1314
@@ -20,101 +21,54 @@ public static void setUpStandardComputerInstance() {
2021 public static void setUpHighEndComputerInstance () {
2122 highEndComputer = new HighEndComputer ();
2223 }
23-
24- @ Test
25- public void givenStandardProcessor_whenAddingProcessor_thenEqualAssertion () {
26- standardComputer .addProcessor ();
27- Assert .assertEquals ("Standard Processor" , standardComputer
28- .getComputerParts ().get ("Processor" ));
29- }
30-
24+
3125 @ Test
3226 public void givenStandardMotherBoard_whenAddingMotherBoard_thenEqualAssertion () {
3327 standardComputer .addMotherboard ();
34- Assert .assertEquals ("Standard Motherboard" , standardComputer
35- .getComputerParts ().get ("Motherboard" ));
28+ assertEquals ("Standard Motherboard" , standardComputer .getComputerParts ().get ("Motherboard" ));
3629 }
37-
38- @ Test
39- public void givenStandardMemory_whenAddingMemory_thenEqualAssertion () {
40- standardComputer .addMemory ();
41- Assert .assertEquals ("8GB" , standardComputer
42- .getComputerParts ().get ("Memory" ));
43- }
44-
45- @ Test
46- public void givenStandardHardDrive_whenAddingHardDrive_thenEqualAssertion () {
47- standardComputer .addHardDrive ();
48- Assert .assertEquals ("1TB Hard Drive" , standardComputer
49- .getComputerParts ().get ("Hard Drive" ));
50- }
51-
30+
5231 @ Test
53- public void givenStandardGraphicaCard_whenAddingGraphicCard_thenEqualAssertion () {
54- standardComputer .addGraphicCard ();
55- Assert . assertEquals ("Standard Graphic Card " , standardComputer
56- . getComputerParts ().get ("Graphic Card" ));
32+ public void givenStandardMotheroboard_whenSetup_thenTwoEqualAssertions () {
33+ standardComputer .setupMotherboard ();
34+ assertEquals ("Screwing the standard motherboard to the case. " , standardComputer . getMotherboardSetupStatus (). get ( 0 ));
35+ assertEquals ( "Plugin in the power supply connectors." , standardComputer . getMotherboardSetupStatus ().get (1 ));
5736 }
5837
5938 @ Test
60- public void givenStandardSoundCard_whenAddingSoundCard_thenEqualAssertion () {
61- standardComputer .addSoundCard ();
62- Assert .assertEquals ("Standard Sound Card" , standardComputer
63- .getComputerParts ().get ("Sound Card" ));
39+ public void givenStandardProcessor_whenAddingProcessor_thenEqualAssertion () {
40+ standardComputer .addProcessor ();
41+ assertEquals ("Standard Processor" , standardComputer .getComputerParts ().get ("Processor" ));
6442 }
65-
43+
6644 @ Test
67- public void givenAllStandardParts_whenBuildingComputer_thenSixParts () {
45+ public void givenAllStandardParts_whenBuildingComputer_thenTwoParts () {
6846 standardComputer .buildComputer ();
69- Assert .assertEquals (6 , standardComputer
70- .getComputerParts ().size ());
47+ assertEquals (2 , standardComputer .getComputerParts ().size ());
7148 }
72-
73- @ Test
74- public void givenHightEndProcessor_whenAddingProcessor_thenEqualAssertion () {
75- highEndComputer .addProcessor ();
76- Assert .assertEquals ("High End Processor" , highEndComputer
77- .getComputerParts ().get ("Processor" ));
78- }
79-
49+
8050 @ Test
8151 public void givenHighEnddMotherBoard_whenAddingMotherBoard_thenEqualAssertion () {
8252 highEndComputer .addMotherboard ();
83- Assert .assertEquals ("High End Motherboard" , highEndComputer
84- .getComputerParts ().get ("Motherboard" ));
53+ Assert .assertEquals ("High-end Motherboard" , highEndComputer .getComputerParts ().get ("Motherboard" ));
8554 }
8655
8756 @ Test
88- public void givenHighEndMemory_whenAddingMemory_thenEqualAssertion () {
89- highEndComputer .addMemory ();
90- Assert . assertEquals ("16GB " , highEndComputer
91- . getComputerParts ().get ("Memory" ));
57+ public void givenHighEnddMotheroboard_whenSetup_thenTwoEqualAssertions () {
58+ highEndComputer .setupMotherboard ();
59+ assertEquals ("Screwing the high-end motherboard to the case. " , highEndComputer . getMotherboardSetupStatus (). get ( 0 ));
60+ assertEquals ( "Plugin in the power supply connectors." , highEndComputer . getMotherboardSetupStatus ().get (1 ));
9261 }
9362
9463 @ Test
95- public void givenHighEndHardDrive_whenAddingHardDrive_thenEqualAssertion () {
96- highEndComputer .addHardDrive ();
97- Assert .assertEquals ("2TB Hard Drive" , highEndComputer
98- .getComputerParts ().get ("Hard Drive" ));
99- }
100-
101- @ Test
102- public void givenHighEndGraphicCard_whenAddingGraphicCard_thenEqualAssertion () {
103- highEndComputer .addGraphicCard ();
104- Assert .assertEquals ("High End Graphic Card" , highEndComputer
105- .getComputerParts ().get ("Graphic Card" ));
106- }
107-
108- @ Test
109- public void givenHighEndSoundCard_whenAddingSoundCard_thenEqualAssertion () {
110- highEndComputer .addSoundCard ();
111- Assert .assertEquals ("High End Sound Card" , highEndComputer
112- .getComputerParts ().get ("Sound Card" ));
64+ public void givenHightEndProcessor_whenAddingProcessor_thenEqualAssertion () {
65+ highEndComputer .addProcessor ();
66+ Assert .assertEquals ("High-end Processor" , highEndComputer .getComputerParts ().get ("Processor" ));
11367 }
11468
11569 @ Test
116- public void givenAllHighEndParts_whenBuildingComputer_thenSixParts () {
70+ public void givenAllHighEnddParts_whenBuildingComputer_thenTwoParts () {
11771 highEndComputer .buildComputer ();
118- Assert . assertEquals (6 , highEndComputer .getComputerParts ().size ());
72+ assertEquals (2 , highEndComputer .getComputerParts ().size ());
11973 }
12074}
0 commit comments