Search in sources :

Example 6 with Step

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

the class StepMapper method map.

@Mapping(from = org.ovirt.engine.core.common.job.Step.class, to = Step.class)
public static Step map(org.ovirt.engine.core.common.job.Step entity, Step step) {
    Step model = step != null ? step : new Step();
    model.setId(entity.getId().toString());
    if (entity.getParentStepId() != null) {
        Step parentStep = new Step();
        parentStep.setId(entity.getParentStepId().toString());
        model.setParentStep(parentStep);
    }
    Job job = new Job();
    job.setId(entity.getJobId().toString());
    model.setJob(job);
    model.setType(map(entity.getStepType()));
    model.setDescription(entity.getDescription());
    model.setNumber(entity.getStepNumber());
    model.setStatus(mapStepStatus(entity.getStatus()));
    model.setProgress(entity.getProgress());
    model.setStartTime(DateMapper.map(entity.getStartTime(), null));
    if (entity.getEndTime() != null) {
        model.setEndTime(TypeConversionHelper.toXMLGregorianCalendar(entity.getEndTime(), null));
    }
    model.setExternal(entity.isExternal());
    if (entity.getExternalSystem() != null && entity.getExternalSystem().getType() != null) {
        model.setExternalType(map(entity.getExternalSystem().getType()));
    }
    mapStepSubjectEntities(entity, model);
    return model;
}
Also used : Step(org.ovirt.engine.api.model.Step) Job(org.ovirt.engine.api.model.Job)

Example 7 with Step

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

the class BackendStepsResourceTest method testAddStep.

@Test
public void testAddStep() throws Exception {
    setUriInfo(setUpBasicUriExpectations());
    setUpCreationExpectations(ActionType.AddExternalStep, AddExternalStepParameters.class, new String[] { "Description", "ParentId" }, new Object[] { DESCRIPTIONS[0], GUIDS[1] }, true, true, GUIDS[0], QueryType.GetStepWithSubjectEntitiesByStepId, IdQueryParameters.class, new String[] { "Id" }, new Object[] { GUIDS[0] }, getEntity(0));
    Step model = new Step();
    Job job = new Job();
    job.setId(GUIDS[1].toString());
    job.setDescription(DESCRIPTIONS[1]);
    model.setJob(job);
    model.setDescription(DESCRIPTIONS[0]);
    model.setStatus(StepStatus.STARTED);
    model.setType(StepEnum.EXECUTING);
    Response response = collection.add(model);
    assertEquals(201, response.getStatus());
    assertTrue(response.getEntity() instanceof Step);
    verifyModel((Step) response.getEntity(), 0);
}
Also used : Response(javax.ws.rs.core.Response) Step(org.ovirt.engine.api.model.Step) Job(org.ovirt.engine.api.model.Job) Test(org.junit.Test)

Example 8 with Step

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

the class StepMapperTest method testSubjectEntities.

@Test
public void testSubjectEntities() {
    org.ovirt.engine.core.common.job.Step bllStep = createBLLStep();
    Guid executionHostId = Guid.newGuid();
    bllStep.setSubjectEntities(Arrays.asList(new StepSubjectEntity(bllStep.getId(), VdcObjectType.EXECUTION_HOST, executionHostId), new StepSubjectEntity(bllStep.getId(), VdcObjectType.Disk, Guid.Empty)));
    Step model = StepMapper.map(bllStep, null);
    assertNotNull(model.getExecutionHost());
    assertEquals(executionHostId.toString(), model.getExecutionHost().getId());
    bllStep = StepMapper.map(model, null);
    assertNull("subject entities shouldn't be mapped back to the model", bllStep.getSubjectEntities());
}
Also used : Guid(org.ovirt.engine.core.compat.Guid) Step(org.ovirt.engine.api.model.Step) StepSubjectEntity(org.ovirt.engine.core.common.job.StepSubjectEntity) Test(org.junit.Test)

Aggregations

Step (org.ovirt.engine.api.model.Step)8 Job (org.ovirt.engine.api.model.Job)4 Date (java.util.Date)2 Test (org.junit.Test)2 Response (javax.ws.rs.core.Response)1 StepSubjectEntity (org.ovirt.engine.core.common.job.StepSubjectEntity)1 IdQueryParameters (org.ovirt.engine.core.common.queries.IdQueryParameters)1 Guid (org.ovirt.engine.core.compat.Guid)1