@Test public void testExceptionMessage() { User user = createMock(User.class); expect(user.getLogin()).andStubReturn("thomas.graf"); replay(user); PermissionException noReadPermEx = new PermissionException(user, READ, new TestSecurable()); PermissionException noWritePermEx = new PermissionException(user, WRITE, new TestSecurable()); Assert.assertEquals("User 'thomas.graf' does not have permission 'weblounge:read' on 'page:3C9D1C88-0C8D-11E6-AAF9-AB2752357C51'", noReadPermEx.getMessage()); Assert.assertEquals("User 'thomas.graf' does not have permission 'weblounge:write' on 'page:3C9D1C88-0C8D-11E6-AAF9-AB2752357C51'", noWritePermEx.getMessage()); }
@Override public String getMessage() { return String.format("User '%s' does not have permission '%s' on '%s'", user.getLogin(), action, securable); }
PermissionException extends RuntimeException { @Override public String getMessage() { return String.format("User '%s' does not have permission '%s' on '%s'", user.getLogin(), action, securable); } }
PermissionException extends RuntimeException { @Override public String getMessage() { return String.format("User '%s' does not have permission '%s' on '%s'", user.getLogin(), action, securable); } PermissionException(User user, Action action, Securable securable); }
PermissionException extends RuntimeException { @Override public String getMessage() { return String.format("User '%s' does not have permission '%s' on '%s'", user.getLogin(), action, securable); } PermissionException(User user, Action action, Securable securable); @Override String getMessage(); }
PermissionException extends RuntimeException { @Override public String getMessage() { return String.format("User '%s' does not have permission '%s' on '%s'", user.getLogin(), action, securable); } PermissionException(User user, Action action, Securable securable); @Override String getMessage();  }