use of org.ovirt.engine.core.common.businessentities.aaa.DbGroup in project ovirt-engine by oVirt.
the class DbGroupDaoTest method testGetByName.
/**
* Ensures that finding by name works as expected.
*/
@Test
public void testGetByName() {
DbGroup result = dao.getByName(existingGroup.getName());
assertNotNull(result);
assertEquals(existingGroup, result);
}
use of org.ovirt.engine.core.common.businessentities.aaa.DbGroup in project ovirt-engine by oVirt.
the class BackendGroupResourceTest method getEntity.
@Override
protected DbGroup getEntity(int index) {
DbGroup entity = new DbGroup();
entity.setId(GUIDS[index]);
entity.setExternalId(EXTERNAL_IDS[index]);
entity.setName(NAMES[index]);
entity.setDomain(DOMAIN);
return entity;
}
use of org.ovirt.engine.core.common.businessentities.aaa.DbGroup in project ovirt-engine by oVirt.
the class BackendGroupsResourceTest method testAddGroupWithImplicitDirectoryName.
/**
* Test that a group can be added when the user doesn't explicitly provide the name of the directory, but provides
* it as part of the group name.
*/
@Test
public void testAddGroupWithImplicitDirectoryName() throws Exception {
setUriInfo(setUpBasicUriExpectations());
setUpEntityQueryExpectations(QueryType.GetDomainList, QueryParametersBase.class, new String[] {}, new Object[] {}, setUpDomains());
setUpGetEntityExpectations("ADGROUP@" + DOMAIN + ":: name=" + GROUP_NAMES_WITH_NO_DOMAIN[0], SearchType.DirectoryGroup, getDirectoryGroup(0));
setUpCreationExpectations(ActionType.AddGroup, AddGroupParameters.class, new String[] { "GroupToAdd" }, new Object[] { new DbGroup(getDirectoryGroup(0)) }, true, true, GUIDS[0], QueryType.GetDbGroupById, IdQueryParameters.class, new String[] { "Id" }, new Object[] { GUIDS[0] }, getEntity(0));
Group model = new Group();
model.setName(GROUP_NAMES[0]);
Response response = collection.add(model);
assertEquals(201, response.getStatus());
assertTrue(response.getEntity() instanceof Group);
verifyModel((Group) response.getEntity(), 0);
}
use of org.ovirt.engine.core.common.businessentities.aaa.DbGroup in project ovirt-engine by oVirt.
the class BackendGroupsResourceTest method testAddGroupWithExplicitDirectoryName.
/**
* Test that a group can be added when the user provides explicitly the name of the directory, so there is no need
* to extract it from the name of the group.
*/
@Test
public void testAddGroupWithExplicitDirectoryName() throws Exception {
setUriInfo(setUpBasicUriExpectations());
setUpEntityQueryExpectations(QueryType.GetDomainList, QueryParametersBase.class, new String[] {}, new Object[] {}, setUpDomains());
setUpGetEntityExpectations("ADGROUP@" + DOMAIN + ":: name=" + GROUP_NAMES_WITH_NO_DOMAIN[0], SearchType.DirectoryGroup, getDirectoryGroup(0));
DbGroup dbGroup = new DbGroup(getDirectoryGroup(0));
setUpCreationExpectations(ActionType.AddGroup, AddGroupParameters.class, new String[] { "GroupToAdd" }, new Object[] { dbGroup }, true, true, dbGroup.getId(), QueryType.GetDbGroupById, IdQueryParameters.class, new String[] { "Id" }, new Object[] { dbGroup.getId() }, getEntity(0));
Domain domain = new Domain();
domain.setName(DOMAIN);
domain.setId(DirectoryEntryIdUtils.encode(domain.getName()));
Group model = new Group();
model.setName(GROUP_NAMES_WITH_NO_DOMAIN[0]);
model.setDomain(domain);
Response response = collection.add(model);
assertEquals(201, response.getStatus());
assertTrue(response.getEntity() instanceof Group);
verifyModel((Group) response.getEntity(), 0);
}
use of org.ovirt.engine.core.common.businessentities.aaa.DbGroup in project ovirt-engine by oVirt.
the class AddGroupCommand method executeCommand.
@Override
protected void executeCommand() {
// First check if the group is already in the database, if it is we
// need to update, if not we need to insert:
DbGroup groupToAdd = getParameters().getGroupToAdd();
DbGroup dbGroup = dbGroupDao.getByExternalId(groupToAdd.getDomain(), groupToAdd.getExternalId());
if (dbGroup == null) {
dbGroupDao.save(groupToAdd);
} else {
dbGroupDao.update(dbGroup);
groupToAdd = dbGroup;
}
// Return the identifier of the created group:
setActionReturnValue(groupToAdd.getId());
setSucceeded(true);
}
Aggregations