Search in sources :

Example 21 with Role

use of org.ovirt.engine.api.model.Role 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");
    }
}
Also used : Role(org.ovirt.engine.api.model.Role) Permit(org.ovirt.engine.api.model.Permit) WebApplicationException(javax.ws.rs.WebApplicationException) Permits(org.ovirt.engine.api.model.Permits) Test(org.junit.Test)

Example 22 with Role

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

the class BackendRolesResourceTest method testAddRoleInvalidPermit.

@Test
public void testAddRoleInvalidPermit() throws Exception {
    setUriInfo(setUpBasicUriExpectations());
    Role model = new Role();
    model.setName(NAMES[0]);
    model.setPermits(new Permits());
    model.getPermits().getPermits().add(new Permit());
    model.getPermits().getPermits().get(0).setId("1234");
    try {
        Response response = collection.add(model);
        fail("expected WebApplicationException");
    } catch (WebApplicationException wae) {
        assertEquals(BAD_REQUEST, wae.getResponse().getStatus());
        assertEquals("1234 is not a valid permit ID.", wae.getResponse().getEntity());
    }
}
Also used : Role(org.ovirt.engine.api.model.Role) Response(javax.ws.rs.core.Response) Permit(org.ovirt.engine.api.model.Permit) WebApplicationException(javax.ws.rs.WebApplicationException) Permits(org.ovirt.engine.api.model.Permits) 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