model.getHosts().getHosts().stream() .filter(Host::isSetId) .map(Host::getId)
@Test public void testHostIdsReplacement() { AffinityGroup model = new AffinityGroup(); Host host = new Host(); final Guid hostGuid = Guid.newGuid(); host.setId(hostGuid.toString()); model.setHosts(new Hosts()); model.getHosts().getHosts().add(host); org.ovirt.engine.core.common.scheduling.AffinityGroup entity = new org.ovirt.engine.core.common.scheduling.AffinityGroup(); entity.getVdsIds().add(Guid.newGuid()); AffinityGroupMapper.map(model, entity); assertEquals(1, entity.getVdsIds().size()); assertEquals(hostGuid, entity.getVdsIds().get(0)); } }
@Test public void testHostIds() { AffinityGroup model = new AffinityGroup(); Host host = new Host(); final Guid hostGuid = Guid.newGuid(); host.setId(hostGuid.toString()); model.setHosts(new Hosts()); model.getHosts().getHosts().add(host); org.ovirt.engine.core.common.scheduling.AffinityGroup entity = new org.ovirt.engine.core.common.scheduling.AffinityGroup(); AffinityGroupMapper.map(model, entity); assertEquals(hostGuid, entity.getVdsIds().get(0)); }