File tree 6 files changed +14
-29
lines changed
6 files changed +14
-29
lines changed Original file line number Diff line number Diff line change 21
21
* THE SOFTWARE.
22
22
*/
23
23
24
- import org .slf4j .Logger ;
25
- import org .slf4j .LoggerFactory ;
26
-
27
24
/**
28
25
* Created by Alexis on 28-Apr-17. With Marker interface idea is to make empty interface and extend
29
26
* it. Basically it is just to identify the special objects from normal objects. Like in case of
@@ -46,22 +43,10 @@ public class App {
46
43
* @param args command line args
47
44
*/
48
45
public static void main (String [] args ) {
49
-
50
- final Logger logger = LoggerFactory .getLogger (App .class );
51
- Guard guard = new Guard ();
52
- Thief thief = new Thief ();
53
-
54
- if (guard instanceof Permission ) {
55
- guard .enter ();
56
- } else {
57
- logger .info ("You have no permission to enter, please leave this area" );
58
- }
59
-
60
- if (thief instanceof Permission ) {
61
- thief .steal ();
62
- } else {
63
- thief .doNothing ();
64
- }
46
+ var guard = new Guard ();
47
+ var thief = new Thief ();
48
+ guard .enter ();
49
+ thief .doNothing ();
65
50
}
66
51
}
67
52
Original file line number Diff line number Diff line change @@ -31,8 +31,7 @@ public class Guard implements Permission {
31
31
32
32
private static final Logger LOGGER = LoggerFactory .getLogger (Guard .class );
33
33
34
- protected static void enter () {
35
-
34
+ protected void enter () {
36
35
LOGGER .info ("You can enter" );
37
36
}
38
37
}
Original file line number Diff line number Diff line change @@ -35,7 +35,7 @@ protected static void steal() {
35
35
LOGGER .info ("Steal valuable items" );
36
36
}
37
37
38
- protected static void doNothing () {
38
+ protected void doNothing () {
39
39
LOGGER .info ("Pretend nothing happened and just leave" );
40
40
}
41
41
}
Original file line number Diff line number Diff line change @@ -30,7 +30,6 @@ public class AppTest {
30
30
31
31
@ Test
32
32
public void test () {
33
- String [] args = {};
34
- App .main (args );
33
+ App .main (new String []{});
35
34
}
36
35
}
Original file line number Diff line number Diff line change @@ -33,7 +33,7 @@ public class GuardTest {
33
33
34
34
@ Test
35
35
public void testGuard () {
36
- Guard guard = new Guard ();
36
+ var guard = new Guard ();
37
37
assertThat (guard , instanceOf (Permission .class ));
38
38
}
39
39
}
Original file line number Diff line number Diff line change 21
21
* THE SOFTWARE.
22
22
*/
23
23
24
- import org .junit .jupiter .api .Test ;
24
+ import static org .hamcrest .CoreMatchers .instanceOf ;
25
+ import static org .hamcrest .CoreMatchers .not ;
26
+ import static org .hamcrest .MatcherAssert .assertThat ;
25
27
26
- import static org .junit .jupiter .api .Assertions . assertFalse ;
28
+ import org .junit .jupiter .api .Test ;
27
29
28
30
/**
29
31
* Thief test
30
32
*/
31
33
public class ThiefTest {
32
34
@ Test
33
35
public void testThief () {
34
- Thief thief = new Thief ();
35
- assertFalse (thief instanceof Permission );
36
+ var thief = new Thief ();
37
+ assertThat (thief , not ( instanceOf ( Permission . class )) );
36
38
}
37
39
}
You can’t perform that action at this time.
0 commit comments