Improve callhome-protocol unit tests
[netconf.git] / netconf / callhome-protocol / src / test / java / org / opendaylight / netconf / callhome / protocol / CallHomeAuthorizationTest.java
index c354140544b97be45d7172029e64f2eb37248fb7..77ff086d1b5c98f18451d535e16bdadf0bebaecf 100644 (file)
@@ -7,7 +7,9 @@
  */
 package org.opendaylight.netconf.callhome.protocol;
 
+import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertThrows;
 import static org.junit.Assert.assertTrue;
 import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.ArgumentMatchers.anyString;
@@ -32,12 +34,13 @@ public class CallHomeAuthorizationTest {
         assertFalse(auth.isServerAllowed());
     }
 
-    @Test(expected = IllegalStateException.class)
+    @Test
     public void anAuthorizationOfRejectedCannotBeAppliedToASession() {
         // given
         CallHomeAuthorization auth = CallHomeAuthorization.rejected();
         // when
-        auth.applyTo(mock(ClientSession.class));
+        final var ex = assertThrows(IllegalStateException.class, () -> auth.applyTo(mock(ClientSession.class)));
+        assertEquals("Server is not allowed.", ex.getMessage());
     }
 
     @Test