/** * Checks that a null version string results in a null version object. */ @Test public void testNullStringProducesNullVersion() { Version version = VersionMapper.fromVersionString(null); assertNull(version); }
private Version getVersion() { QueryReturnValue result = runQuery(QueryType.GetProductVersion, new QueryParametersBase()); return VersionMapper.map((org.ovirt.engine.core.compat.Version) result.getReturnValue()); }
/** * Asserts that the major version number extracted from the given version text is the expected. * * @param expected the expected major version number * @param text the complete version string */ private void assertMajor(Integer expected, String text) { Version version = VersionMapper.fromVersionString(text); assertNotNull(version); Integer actual = version.getMajor(); assertEquals(expected, actual, "Incorrect major version number"); }
@Mapping(from = org.ovirt.engine.core.common.businessentities.network.NetworkFilter.class, to = NetworkFilter.class) public static NetworkFilter map(org.ovirt.engine.core.common.businessentities.network.NetworkFilter entity, NetworkFilter template) { NetworkFilter networkFilter = (template != null) ? template : new NetworkFilter(); networkFilter.setVersion(VersionMapper.map(entity.getVersion())); networkFilter.setName(entity.getName()); networkFilter.setId(entity.getId().toString()); return networkFilter; } }
/** * Asserts that the build version number extracted from the given version text is the expected. * * @param expected the expected build version number * @param text the complete version string */ private void assertBuild(Integer expected, String text) { Version version = VersionMapper.fromVersionString(text); assertNotNull(version); Integer actual = version.getBuild(); assertEquals(expected, actual, "Incorrect build version number"); }
model.setVersion(VersionMapper.map(entity.getCompatibilityVersion()));
/** * Asserts that the revision version number extracted from the given version text is the expected. * * @param expected the expected revision version number * @param text the complete version string */ private void assertRevision(Integer expected, String text) { Version version = VersionMapper.fromVersionString(text); assertNotNull(version); Integer actual = version.getRevision(); assertEquals(expected, actual, "Incorrect revision version number"); } }
entity.setCompatibilityVersion(VersionMapper.map(model.getVersion()));
/** * Asserts that the minor version number extracted from the given version text is the expected. * * @param expected the expected minor version number * @param text the complete version string */ private void assertMinor(Integer expected, String text) { Version version = VersionMapper.fromVersionString(text); assertNotNull(version); Integer actual = version.getMinor(); assertEquals(expected, actual, "Incorrect minor version number"); }
Version entityMappedVersion = VersionMapper.map(model.getCustomCompatibilityVersion()); entity.setCustomCompatibilityVersion(entityMappedVersion.isNotValid() ? null : entityMappedVersion);
/** * Checks that an empty version string results in a version object, containing an empty string in the * {@code full_version} attribute. */ @Test public void testEmptyStringProducesEmptyVersion() { Version version = VersionMapper.fromVersionString(""); assertNotNull(version); assertEquals("", version.getFullVersion()); }
entity.setCompatibilityVersion(VersionMapper.map(model.getVersion()));
/** * Checks that a version string that doesn't match the version number pattern doesn't generate an exception, and * that the complete version string is reported in the {@code full_version} property. */ @Test public void testNoMatchDoesntCrash() { Version version = VersionMapper.fromVersionString("ugly"); assertNotNull(version); assertEquals("ugly", version.getFullVersion()); }
model.setVersion(VersionMapper.map(entity.getCompatibilityVersion()));
String kernelVersionString = entity.getGuestOsKernelVersion(); if(StringUtils.isNotEmpty(kernelVersionString)) { org.ovirt.engine.api.model.Version kernelVersion = VersionMapper.fromVersionString(kernelVersionString); if(kernelVersion != null) { if(os.getKernel() == null) { os.setVersion(VersionMapper.fromVersionString(osVersionString)); if(os.getVersion() != null) { os.getVersion().setFullVersion(entity.getGuestOsVersion());
model.setCustomCompatibilityVersion(VersionMapper.map(entity.getCustomCompatibilityVersion()));