File tree Expand file tree Collapse file tree 14 files changed +192
-4
lines changed Expand file tree Collapse file tree 14 files changed +192
-4
lines changed Original file line number Diff line number Diff line change 10
10
<modelVersion >4.0.0</modelVersion >
11
11
12
12
<artifactId >extension-objects</artifactId >
13
+ <dependencies >
14
+ <dependency >
15
+ <groupId >junit</groupId >
16
+ <artifactId >junit</artifactId >
17
+ </dependency >
18
+ </dependencies >
13
19
14
20
15
- </project >
21
+ </project >
Original file line number Diff line number Diff line change @@ -38,6 +38,7 @@ private static void checkExtensionsForUnit(Unit unit) {
38
38
SergeantExtension sergeantExtension = (SergeantExtension ) unit .getUnitExtension ("SergeantExtension" );
39
39
CommanderExtension commanderExtension = (CommanderExtension ) unit .getUnitExtension ("CommanderExtension" );
40
40
41
+ //if unit have extension call the method
41
42
if (soldierExtension != null ) {
42
43
soldierExtension .soldierReady ();
43
44
} else {
@@ -51,7 +52,7 @@ private static void checkExtensionsForUnit(Unit unit) {
51
52
}
52
53
53
54
if (commanderExtension != null ) {
54
- // commanderExtension.sergeantReady ();
55
+ commanderExtension .commanderReady ();
55
56
} else {
56
57
System .out .println (unit .getName () + " without CommanderExtension" );
57
58
}
Original file line number Diff line number Diff line change 4
4
* Created by Srdjan on 27-Apr-17.
5
5
*/
6
6
public interface CommanderExtension extends UnitExtension {
7
+
8
+ void commanderReady ();
7
9
}
Original file line number Diff line number Diff line change @@ -13,4 +13,9 @@ public class Commander implements CommanderExtension {
13
13
public Commander (CommanderUnit commanderUnit ) {
14
14
this .unit = commanderUnit ;
15
15
}
16
+
17
+ @ Override
18
+ public void commanderReady () {
19
+ System .out .println ("[Commander] " + unit .getName () + " is ready!" );
20
+ }
16
21
}
Original file line number Diff line number Diff line change @@ -16,6 +16,6 @@ public Sergeant(SergeantUnit sergeantUnit) {
16
16
17
17
@ Override
18
18
public void sergeantReady () {
19
- System .out .println ("[Sergeant] " + unit .getName () + " do command ! " );
19
+ System .out .println ("[Sergeant] " + unit .getName () + " is ready ! " );
20
20
}
21
21
}
Original file line number Diff line number Diff line change @@ -16,6 +16,6 @@ public Soldier(SoldierUnit soldierUnit) {
16
16
17
17
@ Override
18
18
public void soldierReady () {
19
- System .out .println ("[Solider] " + unit .getName () + " do command " );
19
+ System .out .println ("[Solider] " + unit .getName () + " is ready! " );
20
20
}
21
21
}
Original file line number Diff line number Diff line change
1
+ import org .junit .Test ;
2
+
3
+ import static org .junit .Assert .*;
4
+
5
+ /**
6
+ * Created by Srdjan on 03-May-17.
7
+ */
8
+ public class AppTest {
9
+ @ Test
10
+ public void main () throws Exception {
11
+
12
+ String [] args = {};
13
+ App .main (args );
14
+ }
15
+
16
+ }
Original file line number Diff line number Diff line change
1
+ package concreteextensions ;
2
+
3
+ import org .junit .Test ;
4
+ import units .CommanderUnit ;
5
+
6
+ import static org .junit .Assert .*;
7
+
8
+ /**
9
+ * Created by Srdjan on 03-May-17.
10
+ */
11
+ public class CommanderTest {
12
+ @ Test
13
+ public void commanderReady () throws Exception {
14
+ final Commander commander = new Commander (new CommanderUnit ("CommanderUnitTest" ));
15
+
16
+ commander .commanderReady ();
17
+ }
18
+
19
+ }
Original file line number Diff line number Diff line change
1
+ package concreteextensions ;
2
+
3
+ import org .junit .Test ;
4
+ import units .SergeantUnit ;
5
+
6
+ import static org .junit .Assert .*;
7
+
8
+ /**
9
+ * Created by Srdjan on 03-May-17.
10
+ */
11
+ public class SergeantTest {
12
+ @ Test
13
+ public void sergeantReady () throws Exception {
14
+ final Sergeant sergeant = new Sergeant (new SergeantUnit ("SergeantUnitTest" ));
15
+
16
+ sergeant .sergeantReady ();
17
+ }
18
+
19
+ }
Original file line number Diff line number Diff line change
1
+ package concreteextensions ;
2
+
3
+ import org .junit .Test ;
4
+ import units .SoldierUnit ;
5
+
6
+ import static org .junit .Assert .*;
7
+
8
+ /**
9
+ * Created by Srdjan on 03-May-17.
10
+ */
11
+ public class SoldierTest {
12
+ @ Test
13
+ public void soldierReady () throws Exception {
14
+ final Soldier soldier = new Soldier (new SoldierUnit ("SoldierUnitTest" ));
15
+
16
+ soldier .soldierReady ();
17
+ }
18
+
19
+ }
You can’t perform that action at this time.
0 commit comments