Search in sources :

Example 6 with RoleGroupMap

use of org.ovirt.engine.core.common.businessentities.RoleGroupMap in project ovirt-engine by oVirt.

the class RoleGroupMapDaoTest method testGetAllRoleGroupMaps.

/**
 * Ensures the right mappings are returned.
 */
@Test
public void testGetAllRoleGroupMaps() {
    List<RoleGroupMap> result = dao.getAllForRole(FixturesTool.ROLE_ID);
    assertNotNull(result);
    assertFalse(result.isEmpty());
    for (RoleGroupMap map : result) {
        assertEquals(FixturesTool.ROLE_ID, map.getRoleId());
    }
}
Also used : RoleGroupMap(org.ovirt.engine.core.common.businessentities.RoleGroupMap) Test(org.junit.Test)

Example 7 with RoleGroupMap

use of org.ovirt.engine.core.common.businessentities.RoleGroupMap in project ovirt-engine by oVirt.

the class AttachActionGroupsToRoleCommandTest method testCheckGroupsCanBeAttachedAlreadyExists.

/* validate related tests */
@Test
public void testCheckGroupsCanBeAttachedAlreadyExists() {
    RoleGroupMap map = new RoleGroupMap(getParams().getActionGroups().get(0), getParams().getRoleId());
    mockGetAllForRole(Collections.singletonList(map));
    List<String> messages = new ArrayList<>(1);
    assertTrue("validate should fail", getCommand().checkIfGroupsCanBeAttached(messages));
    assertEquals("wrong messages", EngineMessage.ERROR_CANNOT_ATTACH_ACTION_GROUP_TO_ROLE_ATTACHED.toString(), messages.get(0));
}
Also used : RoleGroupMap(org.ovirt.engine.core.common.businessentities.RoleGroupMap) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 8 with RoleGroupMap

use of org.ovirt.engine.core.common.businessentities.RoleGroupMap in project ovirt-engine by oVirt.

the class RoleGroupMapDaoTest method testGetByActionGroupAndRole.

@Test
public void testGetByActionGroupAndRole() {
    RoleGroupMap result = dao.getByActionGroupAndRole(existingRoleGroupMap.getActionGroup(), existingRoleGroupMap.getRoleId());
    assertNotNull(result);
    assertEquals(existingRoleGroupMap, result);
}
Also used : RoleGroupMap(org.ovirt.engine.core.common.businessentities.RoleGroupMap) Test(org.junit.Test)

Example 9 with RoleGroupMap

use of org.ovirt.engine.core.common.businessentities.RoleGroupMap in project ovirt-engine by oVirt.

the class RoleGroupMapDaoTest method testRemoveRoleGroupMap.

/**
 * Ensures deleting a mapping works as expected.
 */
@Test
public void testRemoveRoleGroupMap() {
    List<RoleGroupMap> before = dao.getAllForRole(FixturesTool.ROLE_ID);
    // make sure we have things to delete first
    assertFalse(before.isEmpty());
    for (RoleGroupMap map : before) {
        dao.remove(map.getActionGroup(), map.getRoleId());
    }
    List<RoleGroupMap> after = dao.getAllForRole(FixturesTool.ROLE_ID);
    assertTrue(after.isEmpty());
}
Also used : RoleGroupMap(org.ovirt.engine.core.common.businessentities.RoleGroupMap) Test(org.junit.Test)

Example 10 with RoleGroupMap

use of org.ovirt.engine.core.common.businessentities.RoleGroupMap in project ovirt-engine by oVirt.

the class RoleGroupMapDaoTest method setUp.

@Override
public void setUp() throws Exception {
    super.setUp();
    dao = dbFacade.getRoleGroupMapDao();
    existingRoleGroupMap = dao.getByActionGroupAndRole(ActionGroup.RUN_VM, FixturesTool.ROLE_ID);
    actionGroup = ActionGroup.CONNECT_TO_VM;
    newRoleGroupMap = new RoleGroupMap(actionGroup, FixturesTool.ROLE_ID);
}
Also used : RoleGroupMap(org.ovirt.engine.core.common.businessentities.RoleGroupMap)

Aggregations

RoleGroupMap (org.ovirt.engine.core.common.businessentities.RoleGroupMap)11 Test (org.junit.Test)7 ArrayList (java.util.ArrayList)5 ActionGroup (org.ovirt.engine.core.common.businessentities.ActionGroup)3 Role (org.ovirt.engine.core.common.businessentities.Role)1