Search in sources :

Example 11 with Role

use of org.ovirt.engine.api.model.Role in project ovirt-engine by oVirt.

the class PermissionMapper method map.

@Mapping(from = org.ovirt.engine.core.common.businessentities.Permission.class, to = Permission.class)
public static Permission map(org.ovirt.engine.core.common.businessentities.Permission entity, Permission template) {
    Permission model = template != null ? template : new Permission();
    model.setId(entity.getId().toString());
    if (entity.getRoleId() != null) {
        model.setRole(new Role());
        model.getRole().setId(entity.getRoleId().toString());
    }
    if (entity.getAdElementId() != null && (template == null || !template.isSetGroup())) {
        model.setUser(new User());
        model.getUser().setId(entity.getAdElementId().toString());
    }
    if (entity.getObjectId() != null) {
        setObjectId(model, entity);
    }
    return model;
}
Also used : Role(org.ovirt.engine.api.model.Role) User(org.ovirt.engine.api.model.User) Permission(org.ovirt.engine.api.model.Permission)

Example 12 with Role

use of org.ovirt.engine.api.model.Role in project ovirt-engine by oVirt.

the class RoleMapper method map.

@Mapping(from = org.ovirt.engine.core.common.businessentities.Role.class, to = Role.class)
public static Role map(org.ovirt.engine.core.common.businessentities.Role entity, Role template) {
    Role model = template != null ? template : new Role();
    model.setName(entity.getName());
    model.setDescription(entity.getDescription());
    model.setId(entity.getId().toString());
    model.setMutable(!entity.isReadonly());
    model.setAdministrative(RoleType.ADMIN.equals(entity.getType()));
    return model;
}
Also used : Role(org.ovirt.engine.api.model.Role)

Example 13 with Role

use of org.ovirt.engine.api.model.Role in project ovirt-engine by oVirt.

the class CompletenessAssertorTest method testCompleteListSubFieldAlternatives.

@Test
public void testCompleteListSubFieldAlternatives() throws Exception {
    User user = new User();
    user.setRoles(new Roles());
    user.getRoles().getRoles().add(new Role());
    user.getRoles().getRoles().get(0).setId("0");
    user.getRoles().getRoles().add(new Role());
    user.getRoles().getRoles().get(1).setName("0");
    CompletenessAssertor.validateParameters(user, "roles.id|name");
}
Also used : Role(org.ovirt.engine.api.model.Role) User(org.ovirt.engine.api.model.User) Roles(org.ovirt.engine.api.model.Roles) Test(org.junit.Test)

Example 14 with Role

use of org.ovirt.engine.api.model.Role in project ovirt-engine by oVirt.

the class CompletenessAssertorTest method testCompleteListSubField.

@Test
public void testCompleteListSubField() throws Exception {
    User user = new User();
    user.setRoles(new Roles());
    user.getRoles().getRoles().add(new Role());
    user.getRoles().getRoles().get(0).setId("0");
    user.getRoles().getRoles().add(new Role());
    user.getRoles().getRoles().get(1).setId("0");
    CompletenessAssertor.validateParameters(user, "roles.id");
}
Also used : Role(org.ovirt.engine.api.model.Role) User(org.ovirt.engine.api.model.User) Roles(org.ovirt.engine.api.model.Roles) Test(org.junit.Test)

Example 15 with Role

use of org.ovirt.engine.api.model.Role in project ovirt-engine by oVirt.

the class CompletenessAssertorTest method testMissingListSubField.

@Test
public void testMissingListSubField() throws Exception {
    User user = new User();
    user.setRoles(new Roles());
    user.getRoles().getRoles().add(new Role());
    user.getRoles().getRoles().get(0).setId("0");
    user.getRoles().getRoles().add(new Role());
    user.getRoles().getRoles().get(1).setName("0");
    try {
        CompletenessAssertor.validateParameters(user, "roles.id");
        fail("expected WebApplicationException on incomplete model");
    } catch (WebApplicationException wae) {
        verifyIncompleteException(wae, "User", "roles.id");
    }
}
Also used : Role(org.ovirt.engine.api.model.Role) User(org.ovirt.engine.api.model.User) WebApplicationException(javax.ws.rs.WebApplicationException) Roles(org.ovirt.engine.api.model.Roles) Test(org.junit.Test)

Aggregations

Role (org.ovirt.engine.api.model.Role)22 Test (org.junit.Test)12 WebApplicationException (javax.ws.rs.WebApplicationException)8 Permission (org.ovirt.engine.api.model.Permission)8 User (org.ovirt.engine.api.model.User)7 Permits (org.ovirt.engine.api.model.Permits)4 Roles (org.ovirt.engine.api.model.Roles)4 Response (javax.ws.rs.core.Response)3 DataCenter (org.ovirt.engine.api.model.DataCenter)3 Permit (org.ovirt.engine.api.model.Permit)3 Group (org.ovirt.engine.api.model.Group)2 V3Role (org.ovirt.engine.api.v3.types.V3Role)1