use of org.ovirt.engine.api.model.RngDevice in project ovirt-engine by oVirt.
the class RngDeviceMapper method map.
@Mapping(from = VmRngDevice.class, to = RngDevice.class)
public static RngDevice map(VmRngDevice entity, RngDevice template) {
RngDevice model = (template == null) ? new RngDevice() : template;
if (entity.getBytes() != null) {
model.setRate(new Rate());
model.getRate().setBytes(entity.getBytes());
if (entity.getPeriod() != null) {
model.getRate().setPeriod(entity.getPeriod());
}
}
RngSource restSource = map(entity.getSource(), null);
model.setSource(restSource);
return model;
}
use of org.ovirt.engine.api.model.RngDevice in project ovirt-engine by oVirt.
the class RngDeviceMapperTest method testMapFromRestToBackend.
@Test
public void testMapFromRestToBackend() throws Exception {
RngDevice model = new RngDevice();
model.setSource(RngSource.HWRNG);
model.setRate(new Rate());
model.getRate().setBytes(10);
model.getRate().setPeriod(11);
VmRngDevice expected = new VmRngDevice();
expected.setBytes(10);
expected.setPeriod(11);
expected.setSource(VmRngDevice.Source.HWRNG);
assertEquals(expected, RngDeviceMapper.map(model, null));
}
use of org.ovirt.engine.api.model.RngDevice in project ovirt-engine by oVirt.
the class RngDeviceMapperTest method testMapFromBackendToRest.
@Test
public void testMapFromBackendToRest() throws Exception {
VmRngDevice entity = new VmRngDevice();
entity.setBytes(11);
entity.setPeriod(10);
entity.setSource(VmRngDevice.Source.RANDOM);
RngDevice expected = new RngDevice();
expected.setRate(new Rate());
expected.getRate().setBytes(11);
expected.getRate().setPeriod(10);
expected.setSource(RngSource.RANDOM);
assertEquals(expected.getRate().getBytes(), RngDeviceMapper.map(entity, null).getRate().getBytes());
assertEquals(expected.getRate().getPeriod(), RngDeviceMapper.map(entity, null).getRate().getPeriod());
assertEquals(expected.getSource(), RngDeviceMapper.map(entity, null).getSource());
}
Aggregations