@Mapping(from = InstanceType.class, to = org.ovirt.engine.core.common.businessentities.InstanceType.class) public static org.ovirt.engine.core.common.businessentities.InstanceType map( InstanceType model, org.ovirt.engine.core.common.businessentities.InstanceType incoming) { VmTemplate entity = incoming != null ? (VmTemplate) incoming : new VmTemplate(); mapCommonModelToEntity(entity, model); return entity; }
protected org.ovirt.engine.core.common.businessentities.VmTemplate getTemplateEntity(int index) { org.ovirt.engine.core.common.businessentities.VmTemplate template = new org.ovirt.engine.core.common.businessentities.VmTemplate(); return setUpEntityExpectations(template, index); }
private VmTemplate getTemplate() { VmTemplate template = new VmTemplate(); template.setId(TEMPLATE_ID); template.setIsoPath(ISO_PATH); return template; }
private VmTemplate getTemplate() { VmTemplate template = new VmTemplate(); template.setId(TEMPLATE_ID); template.setIsoPath(ISO_PATH); return template; }
@Override public VmTemplate mapRow(ResultSet rs, int rowNum) throws SQLException { final VmTemplate entity = new VmTemplate(); map(rs, entity); entity.setId(getGuidDefaultEmpty(rs, "vmt_guid")); entity.setChildCount(rs.getInt("child_count")); entity.setName(rs.getString("name")); entity.setClusterId(getGuid(rs, "cluster_id")); entity.setStatus(VmTemplateStatus.forValue(rs.getInt("status"))); entity.setClusterName(rs.getString("cluster_name")); entity.setClusterCompatibilityVersion(new VersionRowMapper("cluster_compatibility_version").mapRow(rs, rowNum)); entity.setStoragePoolId(getGuid(rs, "storage_pool_id")); entity.setStoragePoolName(rs.getString("storage_pool_name")); entity.setQuotaName(rs.getString("quota_name")); entity.setQuotaEnforcementType(QuotaEnforcementTypeEnum.forValue(rs.getInt("quota_enforcement_type"))); entity.setDisabled(rs.getBoolean("is_disabled")); entity.setTrustedService(rs.getBoolean("trusted_service")); entity.setTemplateType(VmEntityType.valueOf(rs.getString("entity_type"))); entity.setClusterArch(ArchitectureType.forValue(rs.getInt("architecture"))); entity.setBaseTemplateId(getGuidDefaultEmpty(rs, "base_template_id")); entity.setTemplateVersionNumber(rs.getInt("template_version_number")); entity.setTemplateVersionName(rs.getString("template_version_name")); return entity; } }
@Test public void testBuildTemplateOnSave() { VmTemplate template = new VmTemplate(); TemplateListModel.buildTemplateOnSave(model, template); verifyBuiltTemplate(template); }
when(storageDomainDao.getAllForStorageDomain(GUID2)).thenReturn(storageDomainList); final VmTemplate t = new VmTemplate(); t.setId(GUID); t.setName(NAME); when(vmTemplateDao.get(Guid.Empty)).thenReturn(t); when(vmTemplateDao.get(GUID)).thenReturn(new VmTemplate());
protected void setUpUnitVmModelExpectations(UnitVmModel model) { when(model.getVmType().getSelectedItem()).thenReturn(VM_TYPE); VmTemplate template = new VmTemplate(); template.setId(TEMPLATE_GUID); TemplateWithVersion templateWithVersion = mock(TemplateWithVersion.class); when(model.getTemplateWithVersion().getSelectedItem()).thenReturn(templateWithVersion); when(model.getName().getEntity()).thenReturn(VM_NAME); InstanceType instanceType = new VmTemplate(); instanceType.setId(INSTANCE_TYPE_ID); when(model.getInstanceTypes().getSelectedItem()).thenReturn(instanceType);
@Override protected VmTemplate generateNewEntity() { VmTemplate newVmTemplate = new VmTemplate(); newVmTemplate.setId(Guid.newGuid()); newVmTemplate.setName("NewVmTemplate"); newVmTemplate.setClusterId(FixturesTool.CLUSTER); newVmTemplate.setClusterArch(ArchitectureType.x86_64); newVmTemplate.setCpuProfileId(FixturesTool.CPU_PROFILE_2); newVmTemplate.setSmallIconId(FixturesTool.SMALL_ICON_ID); newVmTemplate.setLargeIconId(FixturesTool.LARGE_ICON_ID); return newVmTemplate; }
@Mapping(from = Template.class, to = VmTemplate.class) public static VmTemplate map(Template model, VmTemplate incoming) { VmTemplate entity = incoming != null ? incoming : new VmTemplate(); mapVmBaseModelToEntity(entity, model); if (model.isSetInitialization()) { entity.setVmInit(InitializationMapper.map(model.getInitialization(), entity.getVmInit())); } if (model.isSetCpu() && model.getCpu().isSetArchitecture()) { entity.setClusterArch(CPUMapper.map(model.getCpu().getArchitecture(), null)); } if (model.isSetDomain() && model.getDomain().isSetName()) { if (entity.getVmInit() == null) { entity.setVmInit(new VmInit()); } entity.getVmInit().setDomain(model.getDomain().getName()); } if (model.getVersion() != null) { if (model.getVersion().getBaseTemplate() != null && StringUtils.isNotEmpty(model.getVersion().getBaseTemplate().getId())) { entity.setBaseTemplateId(Guid.createGuidFromString(model.getVersion().getBaseTemplate().getId())); } if (model.getVersion().isSetVersionName()) { entity.setTemplateVersionName(model.getVersion().getVersionName()); } // numbering is generated in the backend, hence even if user specified version number, we ignore it. } return entity; }
private static VmTemplate cloneVmTemplate(VmTemplate instance) { VmTemplate obj = new VmTemplate(); obj.setStoragePoolId(instance.getStoragePoolId()); obj.setStoragePoolName(instance.getStoragePoolName());