AuthorizedUser { public void checkPermission(String permission){ if (permission!=null && !permissions.contains(permission)){ throw new IllegalStateException("permission required: "+permission); } } AuthorizedUser(String user, Locale locale, Set<String> permissions);  AuthorizedUser(String user, Locale locale, String... permissions); void checkPermission(String permission); boolean checkPermissionValid(String permission); Locale getLocale(); String getUserName();  }
@Test public void test_permission(){ AuthorizedUser user = new AuthorizedUser("us",Locale.ENGLISH,"TEST_PERMISSION"); user.checkPermission(null); user.checkPermission(null); }
@Test public void test_permission_missing(){ Assertions.assertThrows(IllegalStateException.class, () -> { AuthorizedUser user = new AuthorizedUser("us", Locale.ENGLISH, "TEST_PERMISSION"); user.checkPermission("hgfdhghgdh"); }); }