@Override public CpuProfile addParents(CpuProfile cpuProfile) { cpuProfile.setCluster(new Cluster()); cpuProfile.getCluster().setId(clusterId); return cpuProfile; }
@Override public Response add(CpuProfile cpuProfile) { if (!cpuProfile.isSetCluster() || !cpuProfile.getCluster().isSetId()) { cpuProfile.setCluster(new Cluster()); cpuProfile.getCluster().setId(clusterId); } return super.add(cpuProfile); }
@Test public void testRegisterAsNewEntity() { org.ovirt.engine.api.model.Cluster cluster = new org.ovirt.engine.api.model.Cluster(); cluster.setId(GUIDS[1].toString()); doTestRegister(cluster, true); }
@Test public void testRegisterTemplate() { org.ovirt.engine.api.model.Cluster cluster = new org.ovirt.engine.api.model.Cluster(); cluster.setId(GUIDS[1].toString()); doTestRegister(cluster, false); }
@Test public void testBadGuidValidation() { setUpGetEntityExpectations(false); Host host = new Host(); host.setCluster(new Cluster()); host.getCluster().setId("!!!"); assertThrows(MalformedIdException.class, () -> resource.update(host)); }
@Test public void testImport() { StorageDomain storageDomain = new StorageDomain(); storageDomain.setId(GUIDS[2].toString()); org.ovirt.engine.api.model.Cluster cluster = new org.ovirt.engine.api.model.Cluster(); cluster.setId(GUIDS[1].toString()); setUpGetDataCenterByStorageDomainExpectations(STORAGE_DOMAIN_ID); doTestImport(storageDomain, cluster, false); }
@Test public void testImportCollapseSnapshots() { StorageDomain storageDomain = new StorageDomain(); storageDomain.setId(GUIDS[2].toString()); org.ovirt.engine.api.model.Cluster cluster = new org.ovirt.engine.api.model.Cluster(); cluster.setId(GUIDS[1].toString()); setUpGetDataCenterByStorageDomainExpectations(STORAGE_DOMAIN_ID); doTestImport(storageDomain, cluster, true, false); }
@Test public void testImportAsNewEntity() { StorageDomain storageDomain = new StorageDomain(); storageDomain.setId(GUIDS[2].toString()); org.ovirt.engine.api.model.Cluster cluster = new org.ovirt.engine.api.model.Cluster(); cluster.setId(GUIDS[1].toString()); setUpGetDataCenterByStorageDomainExpectations(STORAGE_DOMAIN_ID); doTestImport(storageDomain, cluster, false, true); }
private GlusterBrick clone(GlusterBrick brick) { //Needed to avoid NPE in LinkHelper due to unsetting of grandparent in LinkHelper#addLinks. GlusterBrick cloned = new GlusterBrick(); cloned.setId(brick.getId()); cloned.setGlusterVolume(new GlusterVolume()); cloned.getGlusterVolume().setId(brick.getGlusterVolume().getId()); cloned.getGlusterVolume().setCluster(new Cluster()); cloned.getGlusterVolume().getCluster().setId(brick.getGlusterVolume().getCluster().getId()); return cloned; }
@Test public void testImport() { StorageDomain storageDomain = new StorageDomain(); storageDomain.setId(GUIDS[2].toString()); org.ovirt.engine.api.model.Cluster cluster = new org.ovirt.engine.api.model.Cluster(); cluster.setId(GUIDS[1].toString()); setUpGetDataCenterByStorageDomainExpectations(STORAGE_DOMAIN_ID); doTestImport(storageDomain, cluster, false, false); }
@Test public void testImportAsNewEntity() { StorageDomain storageDomain = new StorageDomain(); storageDomain.setId(GUIDS[2].toString()); org.ovirt.engine.api.model.Cluster cluster = new org.ovirt.engine.api.model.Cluster(); cluster.setId(GUIDS[1].toString()); setUpGetDataCenterByStorageDomainExpectations(STORAGE_DOMAIN_ID); doTestImport(storageDomain, cluster, true); }
@Test public void testMigrateWithClusterId() { setUriInfo(setUpActionExpectations(ActionType.MigrateVm, MigrateVmParameters.class, new String[] { "VmId", "ForceMigrationForNonMigratableVm", "TargetClusterId"}, new Object[] { GUIDS[0], Boolean.FALSE, GUIDS[1]})); Action action = new Action(); org.ovirt.engine.api.model.Cluster cluster = new org.ovirt.engine.api.model.Cluster(); cluster.setId(GUIDS[1].toString()); action.setCluster(cluster); verifyActionResponse(resource.migrate(action)); }
@Test public void testClusterNetworkLinks() { Network network = new Network(); network.setId(NETWORK_ID); network.setCluster(new Cluster()); network.getCluster().setId(CLUSTER_ID); LinkHelper.addLinks(network); assertEquals(CLUSTER_NETWORK_HREF, network.getHref()); }
static Vm getModel(int index) { Vm model = new Vm(); model.setName(NAMES[index]); model.setDescription(DESCRIPTIONS[index]); model.setId(GUIDS[index].toString()); model.setCluster(new org.ovirt.engine.api.model.Cluster()); model.getCluster().setId(GUIDS[2].toString()); return model; }
private Vm createModel(DiskAttachments diskAttachments) { Vm model = getModel(2); model.setTemplate(new Template()); model.getTemplate().setId(GUIDS[1].toString()); model.setCluster(new org.ovirt.engine.api.model.Cluster()); model.getCluster().setId(GUIDS[2].toString()); if (diskAttachments != null){ model.setDiskAttachments(diskAttachments); } return model; }
@Test public void testClusterLinks() { Cluster cluster = new Cluster(); cluster.setId(CLUSTER_ID); cluster.setDataCenter(new DataCenter()); cluster.getDataCenter().setId(DATA_CENTER_ID); LinkHelper.addLinks(cluster, LinkHelper.NO_PARENT); assertEquals(CLUSTER_HREF, cluster.getHref()); assertEquals(DATA_CENTER_HREF, cluster.getDataCenter().getHref()); }
static AffinityGroup getModel(int index) { AffinityGroup model = new AffinityGroup(); model.setId(GUIDS[0].toString()); model.setName(NAMES[index]); model.setDescription(DESCRIPTIONS[index]); model.setCluster(new Cluster()); model.getCluster().setId(CLUSTER_ID.toString()); model.setEnforcing((GUIDS[index].hashCode() & 1) == 0); model.setPositive((GUIDS[index].hashCode() & 1) == 1); return model; } }
private VmPool getModel(int index) { VmPool model = new VmPool(); model.setName(NAMES[index]); model.setDescription(DESCRIPTIONS[index]); model.setId(GUIDS[index].toString()); model.setCluster(new Cluster()); model.getCluster().setId(GUIDS[2].toString()); model.setTemplate(new Template()); model.getTemplate().setId(GUIDS[1].toString()); return model; }
@Test public void testImportNotFound() { Action action = new Action(); action.setStorageDomain(new StorageDomain()); action.getStorageDomain().setId(GUIDS[2].toString()); action.setCluster(new org.ovirt.engine.api.model.Cluster()); action.getCluster().setId(GUIDS[1].toString()); setUpGetEntityExpectations(StorageDomainType.ImportExport, STORAGE_DOMAIN_ID, true); verifyNotFoundException(assertThrows(WebApplicationException.class, () -> resource.doImport(action))); }
@Test public void testImportNotFound() { Action action = new Action(); action.setStorageDomain(new StorageDomain()); action.getStorageDomain().setId(GUIDS[2].toString()); action.setCluster(new org.ovirt.engine.api.model.Cluster()); action.getCluster().setId(GUIDS[1].toString()); setUpGetEntityExpectations(StorageDomainType.ImportExport, GUIDS[2], true); setUpGetDataCenterByStorageDomainExpectations(STORAGE_DOMAIN_ID); verifyNotFoundException(assertThrows(WebApplicationException.class, () -> resource.doImport(action))); }