Search in sources :

Example 1 with CommandAssociatedEntity

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

the class CommandEntityDaoTest method testGetAllInsertAsyncTaskEntitities.

@Test
public void testGetAllInsertAsyncTaskEntitities() {
    CommandEntity cmdEntity = generateNewEntity();
    dao.save(cmdEntity);
    Set<CommandAssociatedEntity> cocoCmdEntities = new HashSet<>();
    cocoCmdEntities.add(new CommandAssociatedEntity(cmdEntity.getId(), VdcObjectType.Storage, Guid.newGuid()));
    cocoCmdEntities.add(new CommandAssociatedEntity(cmdEntity.getId(), VdcObjectType.Disk, Guid.newGuid()));
    dao.insertCommandAssociatedEntities(cocoCmdEntities);
    List<CommandAssociatedEntity> entities = dao.getAllCommandAssociatedEntities(cmdEntity.getId());
    assertNotNull(entities);
    assertEquals(2, entities.size());
    assertThat(entities, hasItems(cocoCmdEntities.toArray(new CommandAssociatedEntity[cocoCmdEntities.size()])));
}
Also used : CommandAssociatedEntity(org.ovirt.engine.core.common.businessentities.CommandAssociatedEntity) CommandEntity(org.ovirt.engine.core.common.businessentities.CommandEntity) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 2 with CommandAssociatedEntity

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

the class CommandEntityDaoTest method testGetCommandIdsByEntity.

@Test
public void testGetCommandIdsByEntity() {
    Guid storageId = Guid.newGuid();
    CommandEntity cmdEntity1 = generateNewEntity();
    dao.save(cmdEntity1);
    Set<CommandAssociatedEntity> cocoCmdEntities1 = new HashSet<>();
    cocoCmdEntities1.add(new CommandAssociatedEntity(cmdEntity1.getId(), VdcObjectType.Storage, storageId));
    cocoCmdEntities1.add(new CommandAssociatedEntity(cmdEntity1.getId(), VdcObjectType.Disk, Guid.newGuid()));
    dao.insertCommandAssociatedEntities(cocoCmdEntities1);
    CommandEntity cmdEntity2 = generateNewEntity();
    dao.save(cmdEntity2);
    Set<CommandAssociatedEntity> cocoCmdEntities2 = new HashSet<>();
    cocoCmdEntities2.add(new CommandAssociatedEntity(cmdEntity2.getId(), VdcObjectType.Storage, storageId));
    cocoCmdEntities2.add(new CommandAssociatedEntity(cmdEntity2.getId(), VdcObjectType.Disk, Guid.newGuid()));
    dao.insertCommandAssociatedEntities(cocoCmdEntities2);
    List<Guid> cmIds = dao.getCommandIdsByEntity(storageId);
    assertNotNull(cmIds);
    assertThat(cmIds, hasSize(2));
    assertThat(cmIds, hasItems(cmdEntity1.getId(), cmdEntity2.getId()));
}
Also used : CommandAssociatedEntity(org.ovirt.engine.core.common.businessentities.CommandAssociatedEntity) CommandEntity(org.ovirt.engine.core.common.businessentities.CommandEntity) Guid(org.ovirt.engine.core.compat.Guid) HashSet(java.util.HashSet) Test(org.junit.Test)

Aggregations

HashSet (java.util.HashSet)2 Test (org.junit.Test)2 CommandAssociatedEntity (org.ovirt.engine.core.common.businessentities.CommandAssociatedEntity)2 CommandEntity (org.ovirt.engine.core.common.businessentities.CommandEntity)2 Guid (org.ovirt.engine.core.compat.Guid)1