Validate request bodies in controller methods
[portal/ric-dashboard.git] / dashboard / webapp-backend / src / test / java / org / oransc / ric / portal / dashboard / DashboardUserManagerTest.java
index a181159..6888774 100644 (file)
@@ -24,6 +24,7 @@ import java.util.HashSet;
 import java.util.Set;
 
 import org.junit.Assert;
+import org.junit.jupiter.api.Assertions;
 import org.junit.jupiter.api.Test;
 import org.onap.portalsdk.core.onboarding.exception.PortalAPIException;
 import org.onap.portalsdk.core.restful.domain.EcompRole;
@@ -59,12 +60,9 @@ public class DashboardUserManagerTest {
                EcompUser user = createEcompUser(loginId);
                dum.createUser(user);
                logger.info("Created user {}", user);
-               try {
+               Assertions.assertThrows(PortalAPIException.class, () -> {
                        dum.createUser(user);
-                       throw new Exception("Unexpected success");
-               } catch (PortalAPIException ex) {
-                       logger.info("caught expected exception: {}", ex.toString());
-               }
+               });
                Assert.assertFalse(dum.getUsers().isEmpty());
                EcompUser fetched = dum.getUser(loginId);
                Assert.assertEquals(fetched, user);
@@ -73,11 +71,9 @@ public class DashboardUserManagerTest {
                EcompUser missing = dum.getUser("foo");
                Assert.assertNull(missing);
                EcompUser unk = createEcompUser("unknown");
-               try {
+               Assertions.assertThrows(PortalAPIException.class, () -> {
                        dum.updateUser("unk", unk);
-               } catch (PortalAPIException ex) {
-                       logger.info("caught expected exception: {}", ex.toString());
-               }
+               });
        }
 
 }