Search in sources :

Example 6 with StepSubjectEntity

use of org.ovirt.engine.core.common.job.StepSubjectEntity in project ovirt-engine by oVirt.

the class StepDaoTest method prepareStartedStepsByStepSubjectEntityTest.

private StepSubjectEntity prepareStartedStepsByStepSubjectEntityTest() {
    Guid entityId = Guid.newGuid();
    VdcObjectType entityType = VdcObjectType.EXECUTION_HOST;
    StepSubjectEntity subjectEntity = new StepSubjectEntity(FixturesTool.STEP_ID, entityType, entityId);
    getStepSubjectEntityDao().saveAll(Arrays.asList(subjectEntity));
    Step s = dao.get(FixturesTool.STEP_ID);
    s.setStatus(JobExecutionStatus.STARTED);
    dao.update(s);
    return subjectEntity;
}
Also used : Guid(org.ovirt.engine.core.compat.Guid) Step(org.ovirt.engine.core.common.job.Step) VdcObjectType(org.ovirt.engine.core.common.VdcObjectType) StepSubjectEntity(org.ovirt.engine.core.common.job.StepSubjectEntity)

Example 7 with StepSubjectEntity

use of org.ovirt.engine.core.common.job.StepSubjectEntity in project ovirt-engine by oVirt.

the class StepDaoTest method prepareProgressTest.

private void prepareProgressTest(Guid entityId) {
    VdcObjectType type = VdcObjectType.Disk;
    BaseDisk diskImage = getDiskDao().get(entityId);
    assertProgress(null, diskImage);
    getStepSubjectEntityDao().saveAll(Arrays.asList(new StepSubjectEntity(FixturesTool.STEP_ID, type, entityId, 30), new StepSubjectEntity(FixturesTool.STEP_ID_2, type, entityId, 50)));
}
Also used : BaseDisk(org.ovirt.engine.core.common.businessentities.storage.BaseDisk) VdcObjectType(org.ovirt.engine.core.common.VdcObjectType) StepSubjectEntity(org.ovirt.engine.core.common.job.StepSubjectEntity)

Example 8 with StepSubjectEntity

use of org.ovirt.engine.core.common.job.StepSubjectEntity in project ovirt-engine by oVirt.

the class StepDaoTest method startedStepsByStepSubjectEntityOtherStatuses.

@Test
public void startedStepsByStepSubjectEntityOtherStatuses() {
    StepSubjectEntity subjectEntity = prepareStartedStepsByStepSubjectEntityTest();
    Step step = dao.get(FixturesTool.STEP_ID);
    Arrays.stream(JobExecutionStatus.values()).filter(status -> status != JobExecutionStatus.STARTED).forEach(status -> {
        step.setStatus(status);
        dao.update(step);
        assertNoStartedStepsForSubjectEntity(subjectEntity);
    });
}
Also used : BaseDisk(org.ovirt.engine.core.common.businessentities.storage.BaseDisk) StepSubjectEntity(org.ovirt.engine.core.common.job.StepSubjectEntity) JobExecutionStatus(org.ovirt.engine.core.common.job.JobExecutionStatus) Arrays(java.util.Arrays) StepEnum(org.ovirt.engine.core.common.job.StepEnum) Assert.assertNotNull(org.junit.Assert.assertNotNull) Date(java.util.Date) Guid(org.ovirt.engine.core.compat.Guid) Assert.assertTrue(org.junit.Assert.assertTrue) Test(org.junit.Test) ExternalSystemType(org.ovirt.engine.core.common.job.ExternalSystemType) Assert.assertNotEquals(org.junit.Assert.assertNotEquals) Assert.assertThat(org.junit.Assert.assertThat) List(java.util.List) Assert.assertFalse(org.junit.Assert.assertFalse) Matchers.emptyCollectionOf(org.hamcrest.Matchers.emptyCollectionOf) VdcObjectType(org.ovirt.engine.core.common.VdcObjectType) SubjectEntity(org.ovirt.engine.core.common.businessentities.SubjectEntity) Assert.assertEquals(org.junit.Assert.assertEquals) Before(org.junit.Before) Step(org.ovirt.engine.core.common.job.Step) Step(org.ovirt.engine.core.common.job.Step) StepSubjectEntity(org.ovirt.engine.core.common.job.StepSubjectEntity) Test(org.junit.Test)

Example 9 with StepSubjectEntity

use of org.ovirt.engine.core.common.job.StepSubjectEntity in project ovirt-engine by oVirt.

the class StepSubjectEntityDaoTest method getStepSubjectEntityByStepId.

@Test
public void getStepSubjectEntityByStepId() {
    List<StepSubjectEntity> entities = dao.getStepSubjectEntitiesByStepId(FixturesTool.STEP_ID);
    assertEquals("StepSubjectEntity list not in the expected size", 2, entities.size());
    StepSubjectEntity stepSubjectEntity = new StepSubjectEntity(FixturesTool.STEP_ID, VdcObjectType.Storage, FixturesTool.IMAGE_GROUP_ID, 50);
    assertSubjectEntityPresence(stepSubjectEntity, entities, true);
}
Also used : StepSubjectEntity(org.ovirt.engine.core.common.job.StepSubjectEntity) Test(org.junit.Test)

Example 10 with StepSubjectEntity

use of org.ovirt.engine.core.common.job.StepSubjectEntity in project ovirt-engine by oVirt.

the class StepSubjectEntityDaoTest method remove.

@Test
public void remove() {
    List<StepSubjectEntity> entities = dao.getStepSubjectEntitiesByStepId(FixturesTool.STEP_ID);
    assertEquals("StepSubjectEntity list not in the expected size", 2, entities.size());
    assertNotEquals("StepSubjectEntity list elements should be different", entities.get(0), entities.get(1));
    StepSubjectEntity toRemove = entities.remove(0);
    dao.remove(toRemove.getEntityId(), toRemove.getStepId());
    entities = dao.getStepSubjectEntitiesByStepId(FixturesTool.STEP_ID);
    assertEquals("StepSubjectEntity list not in the expected size", 1, entities.size());
    assertSubjectEntityPresence(toRemove, entities, false);
}
Also used : StepSubjectEntity(org.ovirt.engine.core.common.job.StepSubjectEntity) Test(org.junit.Test)

Aggregations

StepSubjectEntity (org.ovirt.engine.core.common.job.StepSubjectEntity)11 Test (org.junit.Test)8 Guid (org.ovirt.engine.core.compat.Guid)5 VdcObjectType (org.ovirt.engine.core.common.VdcObjectType)4 Step (org.ovirt.engine.core.common.job.Step)3 BaseDisk (org.ovirt.engine.core.common.businessentities.storage.BaseDisk)2 Arrays (java.util.Arrays)1 Date (java.util.Date)1 List (java.util.List)1 Matchers.emptyCollectionOf (org.hamcrest.Matchers.emptyCollectionOf)1 Assert.assertEquals (org.junit.Assert.assertEquals)1 Assert.assertFalse (org.junit.Assert.assertFalse)1 Assert.assertNotEquals (org.junit.Assert.assertNotEquals)1 Assert.assertNotNull (org.junit.Assert.assertNotNull)1 Assert.assertThat (org.junit.Assert.assertThat)1 Assert.assertTrue (org.junit.Assert.assertTrue)1 Before (org.junit.Before)1 Step (org.ovirt.engine.api.model.Step)1 SubjectEntity (org.ovirt.engine.core.common.businessentities.SubjectEntity)1 ExternalSystemType (org.ovirt.engine.core.common.job.ExternalSystemType)1