use of org.ovirt.engine.api.model.Bonding in project ovirt-engine by oVirt.
the class CompletenessAssertorTest method testCompleteListSubFields.
@Test
public void testCompleteListSubFields() throws Exception {
HostNic bond = new HostNic();
bond.setName("joe");
bond.setNetwork(new Network());
bond.getNetwork().setId("0");
bond.setBonding(new Bonding());
bond.getBonding().setSlaves(new HostNics());
HostNic slave = new HostNic();
slave.setId("0");
bond.getBonding().getSlaves().getHostNics().add(slave);
slave = new HostNic();
slave.setId("0");
bond.getBonding().getSlaves().getHostNics().add(slave);
CompletenessAssertor.validateParameters(bond, "name", "network.id|name", "bonding.slaves.id|name");
}
use of org.ovirt.engine.api.model.Bonding in project ovirt-engine by oVirt.
the class V3BondingInAdapter method adapt.
@Override
public Bonding adapt(V3Bonding from) {
Bonding to = new Bonding();
if (from.isSetOptions()) {
to.setOptions(new Options());
to.getOptions().getOptions().addAll(adaptIn(from.getOptions().getOptions()));
}
if (from.isSetSlaves()) {
to.setSlaves(new HostNics());
to.getSlaves().getHostNics().addAll(adaptIn(from.getSlaves().getSlaves()));
}
return to;
}
use of org.ovirt.engine.api.model.Bonding in project ovirt-engine by oVirt.
the class HostNicMapperTest method testBondMapping.
@Test
public void testBondMapping() {
HostNic model = new HostNic();
model.setId(Guid.newGuid().toString());
model.setName(RandomUtils.instance().nextString(10));
model.setBonding(new Bonding());
model.getBonding().setSlaves(new HostNics());
HostNic slaveA = new HostNic();
slaveA.setName(RandomUtils.instance().nextString(10));
model.getBonding().getSlaves().getHostNics().add(slaveA);
Bond entity = HostNicMapper.map(model, null);
assertNotNull(entity);
assertEquals(model.getId(), entity.getId().toString());
assertEquals(model.getName(), entity.getName());
assertEquals(model.getBonding().getSlaves().getHostNics().size(), entity.getSlaves().size());
for (HostNic slave : model.getBonding().getSlaves().getHostNics()) {
assertTrue(entity.getSlaves().contains(slave.getName()));
}
}
Aggregations