use of org.ovirt.engine.api.model.Permits 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.Permits in project ovirt-engine by oVirt.
the class V3PermitsInAdapter method adapt.
@Override
public Permits adapt(V3Permits from) {
Permits to = new Permits();
if (from.isSetActions()) {
to.setActions(adaptIn(from.getActions()));
}
if (from.isSetActive()) {
to.setActive(from.getActive());
}
if (from.isSetSize()) {
to.setSize(from.getSize());
}
if (from.isSetTotal()) {
to.setTotal(from.getTotal());
}
to.getPermits().addAll(adaptIn(from.getPermits()));
return to;
}
use of org.ovirt.engine.api.model.Permits in project ovirt-engine by oVirt.
the class V3RoleInAdapter method adapt.
@Override
public Role adapt(V3Role from) {
Role to = new Role();
if (from.isSetLinks()) {
to.getLinks().addAll(adaptIn(from.getLinks()));
}
if (from.isSetActions()) {
to.setActions(adaptIn(from.getActions()));
}
if (from.isSetAdministrative()) {
to.setAdministrative(from.isAdministrative());
}
if (from.isSetComment()) {
to.setComment(from.getComment());
}
if (from.isSetDescription()) {
to.setDescription(from.getDescription());
}
if (from.isSetId()) {
to.setId(from.getId());
}
if (from.isSetHref()) {
to.setHref(from.getHref());
}
if (from.isSetMutable()) {
to.setMutable(from.isMutable());
}
if (from.isSetName()) {
to.setName(from.getName());
}
if (from.isSetPermits()) {
to.setPermits(new Permits());
to.getPermits().getPermits().addAll(adaptIn(from.getPermits().getPermits()));
}
if (from.isSetUser()) {
to.setUser(adaptIn(from.getUser()));
}
return to;
}
use of org.ovirt.engine.api.model.Permits 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.Permits 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