diff --git a/marker/src/main/java/App.java b/marker/src/main/java/App.java index 384c999dc..c7b4530c6 100644 --- a/marker/src/main/java/App.java +++ b/marker/src/main/java/App.java @@ -21,9 +21,6 @@ * THE SOFTWARE. */ -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - /** * Created by Alexis on 28-Apr-17. With Marker interface idea is to make empty interface and extend * it. Basically it is just to identify the special objects from normal objects. Like in case of @@ -46,22 +43,10 @@ public class App { * @param args command line args */ public static void main(String[] args) { - - final Logger logger = LoggerFactory.getLogger(App.class); - Guard guard = new Guard(); - Thief thief = new Thief(); - - if (guard instanceof Permission) { - guard.enter(); - } else { - logger.info("You have no permission to enter, please leave this area"); - } - - if (thief instanceof Permission) { - thief.steal(); - } else { - thief.doNothing(); - } + var guard = new Guard(); + var thief = new Thief(); + guard.enter(); + thief.doNothing(); } } diff --git a/marker/src/main/java/Guard.java b/marker/src/main/java/Guard.java index 9a57e15fd..54443603c 100644 --- a/marker/src/main/java/Guard.java +++ b/marker/src/main/java/Guard.java @@ -31,8 +31,7 @@ public class Guard implements Permission { private static final Logger LOGGER = LoggerFactory.getLogger(Guard.class); - protected static void enter() { - + protected void enter() { LOGGER.info("You can enter"); } } diff --git a/marker/src/main/java/Thief.java b/marker/src/main/java/Thief.java index 341eae377..22155ef7b 100644 --- a/marker/src/main/java/Thief.java +++ b/marker/src/main/java/Thief.java @@ -35,7 +35,7 @@ public class Thief { LOGGER.info("Steal valuable items"); } - protected static void doNothing() { + protected void doNothing() { LOGGER.info("Pretend nothing happened and just leave"); } } diff --git a/marker/src/test/java/AppTest.java b/marker/src/test/java/AppTest.java index 5d63db0ad..13295a9e5 100644 --- a/marker/src/test/java/AppTest.java +++ b/marker/src/test/java/AppTest.java @@ -30,7 +30,6 @@ public class AppTest { @Test public void test() { - String[] args = {}; - App.main(args); + App.main(new String[]{}); } } diff --git a/marker/src/test/java/GuardTest.java b/marker/src/test/java/GuardTest.java index 615d4e129..ae92c27dc 100644 --- a/marker/src/test/java/GuardTest.java +++ b/marker/src/test/java/GuardTest.java @@ -33,7 +33,7 @@ public class GuardTest { @Test public void testGuard() { - Guard guard = new Guard(); + var guard = new Guard(); assertThat(guard, instanceOf(Permission.class)); } } \ No newline at end of file diff --git a/marker/src/test/java/ThiefTest.java b/marker/src/test/java/ThiefTest.java index 2732fc78a..dc081acf8 100644 --- a/marker/src/test/java/ThiefTest.java +++ b/marker/src/test/java/ThiefTest.java @@ -21,9 +21,11 @@ * THE SOFTWARE. */ -import org.junit.jupiter.api.Test; +import static org.hamcrest.CoreMatchers.instanceOf; +import static org.hamcrest.CoreMatchers.not; +import static org.hamcrest.MatcherAssert.assertThat; -import static org.junit.jupiter.api.Assertions.assertFalse; +import org.junit.jupiter.api.Test; /** * Thief test @@ -31,7 +33,7 @@ import static org.junit.jupiter.api.Assertions.assertFalse; public class ThiefTest { @Test public void testThief() { - Thief thief = new Thief(); - assertFalse(thief instanceof Permission); + var thief = new Thief(); + assertThat(thief, not(instanceOf(Permission.class))); } } \ No newline at end of file