@Test
public void unassigningNonExistantRoleGivesResourceNotFoundError() {
MockGateKeeper mockGateKeeper = new MockGateKeeper();
mockGateKeeper.allowRoleToUser("test@example.com", Role.PORTAL_ADMIN);
mockGateKeeper.allowRoleToUser("test@example.com", Role.DEVELOPER);
AdminAPI api = new AdminAPI();
api.setGateKeeper(mockGateKeeper);
User user = UserServiceFactory.getUserService().getCurrentUser();
String email = "dummy_" + UUID.randomUUID() + "@dummy.com";
APIResponse resp = api.addUser(email, user);
assertTrue(resp.statusCode == Status.SUCCESS);
//first add role
String role = "role_" + UUID.randomUUID();
resp = api.addRole(role, user);
assertTrue(resp.statusCode == Status.SUCCESS);
resp = api.assignRoleToUser(email, role, user);
assertTrue(resp.statusCode == Status.SUCCESS);
resp = api.unassignRoleToUser(email, role, user);
assertTrue(resp.statusCode == Status.SUCCESS);
//try to unassign again
resp = api.unassignRoleToUser(email, role, user);
assertTrue(resp.statusCode == Status.ERROR_RESOURCE_DOES_NOT_EXIST);
}