Modernize testutils tests
[yangtools.git] / common / testutils / src / test / java / org / opendaylight / yangtools / testutils / mockito / tests / MockitoExampleTutorialTest.java
index aad4655bcf0e3cf1c5681dae20a95622030539fb..f3faaaa11452ba5b8122bc81c10aa19d0d2265ec 100644 (file)
@@ -9,7 +9,7 @@ package org.opendaylight.yangtools.testutils.mockito.tests;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNull;
-import static org.junit.Assert.fail;
+import static org.junit.Assert.assertThrows;
 import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.Mockito.doAnswer;
 import static org.mockito.Mockito.doReturn;
@@ -78,12 +78,7 @@ public class MockitoExampleTutorialTest {
         // NOT when(s.foobar(any())).thenReturn(123) BUT must be like this:
         doReturn(123).when(service).foobar(any());
         assertEquals(123, service.foobar(new File("hello.txt")));
-        try {
-            service.foo();
-            fail("expected NotImplementedException");
-        } catch (UnstubbedMethodException e) {
-            // OK
-        }
+        assertThrows(UnstubbedMethodException.class, service::foo);
     }
 
     @Test
@@ -96,5 +91,4 @@ public class MockitoExampleTutorialTest {
         assertEquals(123, service.foobar(new File("hello.txt")));
         assertEquals(0, service.foobar(new File("belo.txt")));
     }
-
 }