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;
}
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);
}
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());
}
Aggregations