User user = new User();
user.setUsername("dummyuser" + TestUtil.randomInt());
user.setPassword("password");
userResource.createUser(user);
Owner owner1 = createOwner();
Role owner1Role = new Role(owner1.getKey() + " role");
owner1Role.addPermission(new PermissionBlueprint(PermissionType.USERNAME_CONSUMERS,
owner1, Access.ALL));
owner1Role.addUser(user);
roleCurator.create(owner1Role);
Set<Permission> perms = new HashSet<Permission>();
perms.add(new UsernameConsumersPermission(user, owner1));
Principal userPrincipal = new UserPrincipal(user.getUsername(), perms, false);
List<Owner> owners = userResource.listUsersOwners(user.getUsername(),
userPrincipal);
assertEquals(1, owners.size());
assertEquals(owner1.getKey(), owners.get(0).getKey());
}