use of org.ovirt.engine.api.model.Permit in project ovirt-engine by oVirt.
the class BackendRolesResourceTest method testAddRole.
@Test
public void testAddRole() throws Exception {
setUriInfo(setUpBasicUriExpectations());
setUpCreationExpectations(ActionType.AddRoleWithActionGroups, RoleWithActionGroupsParameters.class, new String[] { "Role.Id", "Role.Name" }, new Object[] { GUIDS[0], NAMES[0] }, true, true, GUIDS[0], QueryType.GetRoleById, IdQueryParameters.class, new String[] { "Id" }, new Object[] { GUIDS[0] }, getEntity(0));
Role model = new Role();
model.setName(NAMES[0]);
model.setPermits(new Permits());
model.getPermits().getPermits().add(new Permit());
model.getPermits().getPermits().get(0).setId("" + ActionGroup.CREATE_VM.getId());
Response response = collection.add(model);
assertEquals(201, response.getStatus());
assertTrue(response.getEntity() instanceof Role);
verifyModel((Role) response.getEntity(), 0);
}
use of org.ovirt.engine.api.model.Permit in project ovirt-engine by oVirt.
the class PermitMapper method map.
@Mapping(from = ActionGroup.class, to = Permit.class)
public static Permit map(ActionGroup entity, Permit template) {
Permit model = template != null ? template : new Permit();
model.setId(Integer.toString(entity.getId()));
model.setName(entity.name().toLowerCase());
model.setAdministrative(entity.getRoleType() == RoleType.ADMIN);
return model;
}
use of org.ovirt.engine.api.model.Permit in project ovirt-engine by oVirt.
the class BackendClusterLevelsResource method makeClusterLevel.
public ClusterLevel makeClusterLevel(String version) {
ClusterLevel level = new ClusterLevel();
level.setId(version);
// Not exposing CPU list filtered queries:
if (!isFiltered()) {
CpuTypes cpuTypes = new CpuTypes();
for (ServerCpu serverCpu : getServerCpuList(version)) {
CpuType cpuType = new CpuType();
cpuType.setName(serverCpu.getCpuName());
cpuType.setLevel(serverCpu.getLevel());
cpuType.setArchitecture(CPUMapper.map(serverCpu.getArchitecture(), null));
cpuTypes.getCpuTypes().add(cpuType);
}
level.setCpuTypes(cpuTypes);
}
// Add permits:
Permits permits = new Permits();
for (ActionGroup actionGroup : getActionGroups()) {
Permit permit = PermitMapper.map(actionGroup, null);
permits.getPermits().add(permit);
}
level.setPermits(permits);
return LinkHelper.addLinks(level);
}
use of org.ovirt.engine.api.model.Permit in project ovirt-engine by oVirt.
the class BackendPermitsResourceTest method testAddPermit.
@Test
public void testAddPermit() throws Exception {
setUriInfo(setUpBasicUriExpectations());
setUpCreationExpectations(ActionType.AttachActionGroupsToRole, ActionGroupsToRoleParameter.class, new String[] { "RoleId" }, new Object[] { GUIDS[1] }, true, true, GUIDS[2], null, null, null, null, getEntity(1));
Permit model = new Permit();
model.setId("1");
Response response = collection.add(model);
assertEquals(201, response.getStatus());
assertTrue(response.getEntity() instanceof Permit);
verifyModel((Permit) response.getEntity(), 0);
}
use of org.ovirt.engine.api.model.Permit in project ovirt-engine by oVirt.
the class BackendRolesResourceTest method testAddIncompleteParametersNoName.
@Test
public void testAddIncompleteParametersNoName() throws Exception {
Role model = new Role();
model.setPermits(new Permits());
model.getPermits().getPermits().add(new Permit());
model.getPermits().getPermits().get(0).setId("1");
setUriInfo(setUpBasicUriExpectations());
try {
collection.add(model);
fail("expected WebApplicationException on incomplete parameters");
} catch (WebApplicationException wae) {
verifyIncompleteException(wae, "Role", "add", "name");
}
}
Aggregations