@Test public void addPermissionToDatabase() { new UserAuthorizer(mockUserService, mockPermissionDb).grantPermission(USER, READ_ACCESS);
// The test will fail if any of these methods is not called. verify(mockUserService).isUserActive(USER); verify(mockPermissionDb).getPermissions(USER); verify(mockPermissionDb).isValidPermission(READ_ACCESS); verify(mockPermissionDb).addPermission(USER, READ_ACCESS); }
// Verify only the state-changing method. verify(mockPermissionDb).addPermission(USER, READ_ACCESS); }