mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
Fix typos and improve javadocs on ByteScaleUtils (#6877)
Co-authored-by: GutoVeronezi <daniel@scclouds.com.br>
This commit is contained in:
parent
982450ed81
commit
b8b66b7a3d
@ -469,7 +469,7 @@ public class PresetVariableHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
value.setTags(getPresetVariableValueResourceTags(volumeId, ResourceObjectType.Volume));
|
value.setTags(getPresetVariableValueResourceTags(volumeId, ResourceObjectType.Volume));
|
||||||
value.setSize(ByteScaleUtils.bytesToMib(volumeVo.getSize()));
|
value.setSize(ByteScaleUtils.bytesToMebibytes(volumeVo.getSize()));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected GenericPresetVariable getPresetVariableValueDiskOffering(Long diskOfferingId) {
|
protected GenericPresetVariable getPresetVariableValueDiskOffering(Long diskOfferingId) {
|
||||||
@ -536,7 +536,7 @@ public class PresetVariableHelper {
|
|||||||
value.setName(vmTemplateVo.getName());
|
value.setName(vmTemplateVo.getName());
|
||||||
value.setOsName(getPresetVariableValueOsName(vmTemplateVo.getGuestOSId()));
|
value.setOsName(getPresetVariableValueOsName(vmTemplateVo.getGuestOSId()));
|
||||||
value.setTags(getPresetVariableValueResourceTags(templateOrIsoId, usageType == UsageTypes.ISO ? ResourceObjectType.ISO : ResourceObjectType.Template));
|
value.setTags(getPresetVariableValueResourceTags(templateOrIsoId, usageType == UsageTypes.ISO ? ResourceObjectType.ISO : ResourceObjectType.Template));
|
||||||
value.setSize(ByteScaleUtils.bytesToMib(vmTemplateVo.getSize()));
|
value.setSize(ByteScaleUtils.bytesToMebibytes(vmTemplateVo.getSize()));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void loadPresetVariableValueForSnapshot(UsageVO usageRecord, Value value) {
|
protected void loadPresetVariableValueForSnapshot(UsageVO usageRecord, Value value) {
|
||||||
@ -554,7 +554,7 @@ public class PresetVariableHelper {
|
|||||||
|
|
||||||
value.setId(snapshotVo.getUuid());
|
value.setId(snapshotVo.getUuid());
|
||||||
value.setName(snapshotVo.getName());
|
value.setName(snapshotVo.getName());
|
||||||
value.setSize(ByteScaleUtils.bytesToMib(snapshotVo.getSize()));
|
value.setSize(ByteScaleUtils.bytesToMebibytes(snapshotVo.getSize()));
|
||||||
value.setSnapshotType(Snapshot.Type.values()[snapshotVo.getSnapshotType()]);
|
value.setSnapshotType(Snapshot.Type.values()[snapshotVo.getSnapshotType()]);
|
||||||
value.setStorage(getPresetVariableValueStorage(getSnapshotDataStoreId(snapshotId), usageType));
|
value.setStorage(getPresetVariableValueStorage(getSnapshotDataStoreId(snapshotId), usageType));
|
||||||
value.setTags(getPresetVariableValueResourceTags(snapshotId, ResourceObjectType.Snapshot));
|
value.setTags(getPresetVariableValueResourceTags(snapshotId, ResourceObjectType.Snapshot));
|
||||||
|
|||||||
@ -657,7 +657,7 @@ public class PresetVariableHelperTest {
|
|||||||
Value result = new Value();
|
Value result = new Value();
|
||||||
presetVariableHelperSpy.loadPresetVariableValueForVolume(usageVoMock, result);
|
presetVariableHelperSpy.loadPresetVariableValueForVolume(usageVoMock, result);
|
||||||
|
|
||||||
Long expectedSize = ByteScaleUtils.bytesToMib(expected.getSize());
|
Long expectedSize = ByteScaleUtils.bytesToMebibytes(expected.getSize());
|
||||||
|
|
||||||
assertPresetVariableIdAndName(expected, result);
|
assertPresetVariableIdAndName(expected, result);
|
||||||
Assert.assertEquals(expected.getDiskOffering(), result.getDiskOffering());
|
Assert.assertEquals(expected.getDiskOffering(), result.getDiskOffering());
|
||||||
@ -693,7 +693,7 @@ public class PresetVariableHelperTest {
|
|||||||
Value result = new Value();
|
Value result = new Value();
|
||||||
presetVariableHelperSpy.loadPresetVariableValueForVolume(usageVoMock, result);
|
presetVariableHelperSpy.loadPresetVariableValueForVolume(usageVoMock, result);
|
||||||
|
|
||||||
Long expectedSize = ByteScaleUtils.bytesToMib(expected.getSize());
|
Long expectedSize = ByteScaleUtils.bytesToMebibytes(expected.getSize());
|
||||||
|
|
||||||
assertPresetVariableIdAndName(expected, result);
|
assertPresetVariableIdAndName(expected, result);
|
||||||
Assert.assertEquals(expected.getDiskOffering(), result.getDiskOffering());
|
Assert.assertEquals(expected.getDiskOffering(), result.getDiskOffering());
|
||||||
@ -824,7 +824,7 @@ public class PresetVariableHelperTest {
|
|||||||
Value result = new Value();
|
Value result = new Value();
|
||||||
presetVariableHelperSpy.loadPresetVariableValueForTemplateAndIso(usageVoMock, result);
|
presetVariableHelperSpy.loadPresetVariableValueForTemplateAndIso(usageVoMock, result);
|
||||||
|
|
||||||
Long expectedSize = ByteScaleUtils.bytesToMib(expected.getSize());
|
Long expectedSize = ByteScaleUtils.bytesToMebibytes(expected.getSize());
|
||||||
|
|
||||||
assertPresetVariableIdAndName(expected, result);
|
assertPresetVariableIdAndName(expected, result);
|
||||||
Assert.assertEquals(expected.getOsName(), result.getOsName());
|
Assert.assertEquals(expected.getOsName(), result.getOsName());
|
||||||
@ -872,7 +872,7 @@ public class PresetVariableHelperTest {
|
|||||||
Value result = new Value();
|
Value result = new Value();
|
||||||
presetVariableHelperSpy.loadPresetVariableValueForSnapshot(usageVoMock, result);
|
presetVariableHelperSpy.loadPresetVariableValueForSnapshot(usageVoMock, result);
|
||||||
|
|
||||||
Long expectedSize = ByteScaleUtils.bytesToMib(expected.getSize());
|
Long expectedSize = ByteScaleUtils.bytesToMebibytes(expected.getSize());
|
||||||
|
|
||||||
assertPresetVariableIdAndName(expected, result);
|
assertPresetVariableIdAndName(expected, result);
|
||||||
Assert.assertEquals(expected.getSnapshotType(), result.getSnapshotType());
|
Assert.assertEquals(expected.getSnapshotType(), result.getSnapshotType());
|
||||||
|
|||||||
@ -2814,7 +2814,7 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
|
|||||||
|
|
||||||
grd.setMemBalloning(!_noMemBalloon);
|
grd.setMemBalloning(!_noMemBalloon);
|
||||||
|
|
||||||
Long maxRam = ByteScaleUtils.bytesToKib(vmTO.getMaxRam());
|
Long maxRam = ByteScaleUtils.bytesToKibibytes(vmTO.getMaxRam());
|
||||||
|
|
||||||
grd.setMemorySize(maxRam);
|
grd.setMemorySize(maxRam);
|
||||||
grd.setCurrentMem(getCurrentMemAccordingToMemBallooning(vmTO, maxRam));
|
grd.setCurrentMem(getCurrentMemAccordingToMemBallooning(vmTO, maxRam));
|
||||||
@ -2833,7 +2833,7 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
|
|||||||
s_logger.warn(String.format("Setting VM's [%s] current memory as max memory [%s] due to memory ballooning is disabled. If you are using a custom service offering, verify if memory ballooning really should be disabled.", vmTO.toString(), maxRam));
|
s_logger.warn(String.format("Setting VM's [%s] current memory as max memory [%s] due to memory ballooning is disabled. If you are using a custom service offering, verify if memory ballooning really should be disabled.", vmTO.toString(), maxRam));
|
||||||
return maxRam;
|
return maxRam;
|
||||||
} else {
|
} else {
|
||||||
return ByteScaleUtils.bytesToKib(vmTO.getMinRam());
|
return ByteScaleUtils.bytesToKibibytes(vmTO.getMinRam());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -37,7 +37,7 @@ public class LibvirtScaleVmCommandWrapper extends CommandWrapper<ScaleVmCommand,
|
|||||||
String vmName = vmSpec.getName();
|
String vmName = vmSpec.getName();
|
||||||
Connect conn = null;
|
Connect conn = null;
|
||||||
|
|
||||||
long newMemory = ByteScaleUtils.bytesToKib(vmSpec.getMaxRam());
|
long newMemory = ByteScaleUtils.bytesToKibibytes(vmSpec.getMaxRam());
|
||||||
int newVcpus = vmSpec.getCpus();
|
int newVcpus = vmSpec.getCpus();
|
||||||
int newCpuSpeed = vmSpec.getMinSpeed() != null ? vmSpec.getMinSpeed() : vmSpec.getSpeed();
|
int newCpuSpeed = vmSpec.getMinSpeed() != null ? vmSpec.getMinSpeed() : vmSpec.getSpeed();
|
||||||
int newCpuShares = newVcpus * newCpuSpeed;
|
int newCpuShares = newVcpus * newCpuSpeed;
|
||||||
|
|||||||
@ -5756,13 +5756,13 @@ public class LibvirtComputingResourceTest {
|
|||||||
libvirtComputingResource._noMemBalloon = false;
|
libvirtComputingResource._noMemBalloon = false;
|
||||||
|
|
||||||
long maxMemory = 2048;
|
long maxMemory = 2048;
|
||||||
long minMemory = ByteScaleUtils.mibToBytes(64);
|
long minMemory = ByteScaleUtils.mebibytesToBytes(64);
|
||||||
|
|
||||||
VirtualMachineTO vmTo = Mockito.mock(VirtualMachineTO.class);
|
VirtualMachineTO vmTo = Mockito.mock(VirtualMachineTO.class);
|
||||||
Mockito.when(vmTo.getMinRam()).thenReturn(minMemory);
|
Mockito.when(vmTo.getMinRam()).thenReturn(minMemory);
|
||||||
|
|
||||||
long currentMemory = libvirtComputingResource.getCurrentMemAccordingToMemBallooning(vmTo, maxMemory);
|
long currentMemory = libvirtComputingResource.getCurrentMemAccordingToMemBallooning(vmTo, maxMemory);
|
||||||
Assert.assertEquals(ByteScaleUtils.bytesToKib(minMemory), currentMemory);
|
Assert.assertEquals(ByteScaleUtils.bytesToKibibytes(minMemory), currentMemory);
|
||||||
Mockito.verify(vmTo).getMinRam();
|
Mockito.verify(vmTo).getMinRam();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -76,7 +76,7 @@ public class LibvirtScaleVmCommandWrapperTest extends TestCase {
|
|||||||
|
|
||||||
vmTo = new VirtualMachineTO(1, "Test 1", VirtualMachine.Type.User, 2, 1000, 67108864, 67108864, VirtualMachineTemplate.BootloaderType.External, "Other Linux (64x)", true, true, "test123");
|
vmTo = new VirtualMachineTO(1, "Test 1", VirtualMachine.Type.User, 2, 1000, 67108864, 67108864, VirtualMachineTemplate.BootloaderType.External, "Other Linux (64x)", true, true, "test123");
|
||||||
|
|
||||||
long memory = ByteScaleUtils.bytesToKib(vmTo.getMaxRam());
|
long memory = ByteScaleUtils.bytesToKibibytes(vmTo.getMaxRam());
|
||||||
int vcpus = vmTo.getCpus();
|
int vcpus = vmTo.getCpus();
|
||||||
int cpuShares = vcpus * vmTo.getSpeed();
|
int cpuShares = vcpus * vmTo.getSpeed();
|
||||||
scalingDetails = String.format("%s memory to [%s KiB], CPU cores to [%s] and cpu_shares to [%s]", vmTo.toString(), memory, vcpus, cpuShares);
|
scalingDetails = String.format("%s memory to [%s KiB], CPU cores to [%s] and cpu_shares to [%s]", vmTo.toString(), memory, vcpus, cpuShares);
|
||||||
|
|||||||
@ -220,7 +220,7 @@ public class KVMGuru extends HypervisorGuruBase implements HypervisorGuru {
|
|||||||
Integer maxMemoryConfig = ConfigurationManagerImpl.VM_SERVICE_OFFERING_MAX_RAM_SIZE.value();
|
Integer maxMemoryConfig = ConfigurationManagerImpl.VM_SERVICE_OFFERING_MAX_RAM_SIZE.value();
|
||||||
if (customOfferingMaxMemory != null) {
|
if (customOfferingMaxMemory != null) {
|
||||||
s_logger.debug(String.format("Using 'Custom unconstrained' %s max memory value [%sMb] as %s memory.", serviceOfferingDescription, customOfferingMaxMemory, vmDescription));
|
s_logger.debug(String.format("Using 'Custom unconstrained' %s max memory value [%sMb] as %s memory.", serviceOfferingDescription, customOfferingMaxMemory, vmDescription));
|
||||||
maxMemory = ByteScaleUtils.mibToBytes(customOfferingMaxMemory);
|
maxMemory = ByteScaleUtils.mebibytesToBytes(customOfferingMaxMemory);
|
||||||
} else {
|
} else {
|
||||||
String maxMemoryConfigKey = ConfigurationManagerImpl.VM_SERVICE_OFFERING_MAX_RAM_SIZE.key();
|
String maxMemoryConfigKey = ConfigurationManagerImpl.VM_SERVICE_OFFERING_MAX_RAM_SIZE.key();
|
||||||
|
|
||||||
@ -228,7 +228,7 @@ public class KVMGuru extends HypervisorGuruBase implements HypervisorGuru {
|
|||||||
serviceOfferingDescription, maxMemoryConfigKey, maxMemoryConfig, vmDescription));
|
serviceOfferingDescription, maxMemoryConfigKey, maxMemoryConfig, vmDescription));
|
||||||
|
|
||||||
if (maxMemoryConfig > 0) {
|
if (maxMemoryConfig > 0) {
|
||||||
maxMemory = ByteScaleUtils.mibToBytes(maxMemoryConfig);
|
maxMemory = ByteScaleUtils.mebibytesToBytes(maxMemoryConfig);
|
||||||
} else {
|
} else {
|
||||||
s_logger.info(String.format("Config [%s] has value less or equal '0'. Using %s host or last host max memory [%s] as VM max memory in the hypervisor.", maxMemoryConfigKey, vmDescription, maxHostMemory));
|
s_logger.info(String.format("Config [%s] has value less or equal '0'. Using %s host or last host max memory [%s] as VM max memory in the hypervisor.", maxMemoryConfigKey, vmDescription, maxHostMemory));
|
||||||
maxMemory = maxHostMemory;
|
maxMemory = maxHostMemory;
|
||||||
|
|||||||
@ -2053,7 +2053,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir
|
|||||||
// #1 Check existing host has capacity
|
// #1 Check existing host has capacity
|
||||||
if (!excludes.shouldAvoid(ApiDBUtils.findHostById(vmInstance.getHostId()))) {
|
if (!excludes.shouldAvoid(ApiDBUtils.findHostById(vmInstance.getHostId()))) {
|
||||||
existingHostHasCapacity = _capacityMgr.checkIfHostHasCpuCapability(vmInstance.getHostId(), newCpu, newSpeed)
|
existingHostHasCapacity = _capacityMgr.checkIfHostHasCpuCapability(vmInstance.getHostId(), newCpu, newSpeed)
|
||||||
&& _capacityMgr.checkIfHostHasCapacity(vmInstance.getHostId(), cpuDiff, ByteScaleUtils.mibToBytes(memoryDiff), false,
|
&& _capacityMgr.checkIfHostHasCapacity(vmInstance.getHostId(), cpuDiff, ByteScaleUtils.mebibytesToBytes(memoryDiff), false,
|
||||||
_capacityMgr.getClusterOverProvisioningFactor(host.getClusterId(), Capacity.CAPACITY_TYPE_CPU),
|
_capacityMgr.getClusterOverProvisioningFactor(host.getClusterId(), Capacity.CAPACITY_TYPE_CPU),
|
||||||
_capacityMgr.getClusterOverProvisioningFactor(host.getClusterId(), Capacity.CAPACITY_TYPE_MEMORY), false);
|
_capacityMgr.getClusterOverProvisioningFactor(host.getClusterId(), Capacity.CAPACITY_TYPE_MEMORY), false);
|
||||||
excludes.addHost(vmInstance.getHostId());
|
excludes.addHost(vmInstance.getHostId());
|
||||||
|
|||||||
@ -176,7 +176,7 @@ public class KVMGuruTest {
|
|||||||
|
|
||||||
long result = guru.getVmMaxMemory(serviceOfferingVoMock, "Vm description", 1l);
|
long result = guru.getVmMaxMemory(serviceOfferingVoMock, "Vm description", 1l);
|
||||||
|
|
||||||
Assert.assertEquals(ByteScaleUtils.mibToBytes(maxCustomOfferingMemory), result);
|
Assert.assertEquals(ByteScaleUtils.mebibytesToBytes(maxCustomOfferingMemory), result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -190,12 +190,12 @@ public class KVMGuruTest {
|
|||||||
Mockito.when(vmServiceOfferingMaxRAMSize.value()).thenReturn(maxMemoryConfig);
|
Mockito.when(vmServiceOfferingMaxRAMSize.value()).thenReturn(maxMemoryConfig);
|
||||||
long result = guru.getVmMaxMemory(serviceOfferingVoMock, "Vm description", 1l);
|
long result = guru.getVmMaxMemory(serviceOfferingVoMock, "Vm description", 1l);
|
||||||
|
|
||||||
Assert.assertEquals(ByteScaleUtils.mibToBytes(maxMemoryConfig), result);
|
Assert.assertEquals(ByteScaleUtils.mebibytesToBytes(maxMemoryConfig), result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void validateGetVmMaxMemoryReturnMaxHostMemory(){
|
public void validateGetVmMaxMemoryReturnMaxHostMemory(){
|
||||||
long maxHostMemory = ByteScaleUtils.mibToBytes(2000);
|
long maxHostMemory = ByteScaleUtils.mebibytesToBytes(2000);
|
||||||
Mockito.when(serviceOfferingVoMock.getDetail(ApiConstants.MAX_MEMORY)).thenReturn(null);
|
Mockito.when(serviceOfferingVoMock.getDetail(ApiConstants.MAX_MEMORY)).thenReturn(null);
|
||||||
|
|
||||||
ConfigKey<Integer> vmServiceOfferingMaxRAMSize = Mockito.mock(ConfigKey.class);
|
ConfigKey<Integer> vmServiceOfferingMaxRAMSize = Mockito.mock(ConfigKey.class);
|
||||||
|
|||||||
@ -15,7 +15,7 @@
|
|||||||
package org.apache.cloudstack.utils.bytescale;
|
package org.apache.cloudstack.utils.bytescale;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class provides a facility to convert bytes through his scales (b, Kib, Kb, Mib, Mb...).
|
* This class provides a facility to convert bytes through the scales (B, KiB, KB, MiB, MB...).
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class ByteScaleUtils {
|
public class ByteScaleUtils {
|
||||||
@ -30,29 +30,29 @@ public class ByteScaleUtils {
|
|||||||
* Converts mebibytes to bytes.
|
* Converts mebibytes to bytes.
|
||||||
*
|
*
|
||||||
* @param mib The value to convert to bytes (eq: 1, 2, 3, ..., 42,...).
|
* @param mib The value to convert to bytes (eq: 1, 2, 3, ..., 42,...).
|
||||||
* @return The parameter multiplied by 1048576 (1024 * 1024, 1 MiB).
|
* @return The parameter multiplied by 2²⁰ (1048576 | 1024 * 1024 | 1 mebibyte).
|
||||||
*/
|
*/
|
||||||
public static long mibToBytes(long mib) {
|
public static long mebibytesToBytes(long mib) {
|
||||||
return mib * MiB;
|
return mib * MiB;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts bytes to kibibytes.
|
* Converts bytes to kibibyte.
|
||||||
*
|
*
|
||||||
* @param b The value in bytes to convert to kibibytes.
|
* @param bytes The value in bytes to convert to kibibyte.
|
||||||
* @return The parameter divided by 1024 (1 KiB).
|
* @return The parameter divided by 2¹⁰ (1024 | 1 kibibyte).
|
||||||
*/
|
*/
|
||||||
public static long bytesToKib(long b) {
|
public static long bytesToKibibytes(long bytes) {
|
||||||
return b / KiB;
|
return bytes / KiB;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts bytes to mebibytes.
|
* Converts bytes to mebibytes.
|
||||||
*
|
*
|
||||||
* @param b The value in bytes to convert to mebibytes.
|
* @param bytes The value in bytes to convert to mebibytes.
|
||||||
* @return The parameter divided by 1024 * 1024 (1 MiB).
|
* @return The parameter divided by 2²⁰ (1048576 | 1024 * 1024 | 1 mebibyte).
|
||||||
*/
|
*/
|
||||||
public static long bytesToMib(long b) {
|
public static long bytesToMebibytes(long bytes) {
|
||||||
return b / MiB;
|
return bytes / MiB;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -14,45 +14,45 @@
|
|||||||
|
|
||||||
package org.apache.cloudstack.utils.bytescale;
|
package org.apache.cloudstack.utils.bytescale;
|
||||||
|
|
||||||
import junit.framework.TestCase;
|
import org.junit.Assert;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.mockito.junit.MockitoJUnitRunner;
|
import org.mockito.junit.MockitoJUnitRunner;
|
||||||
|
|
||||||
@RunWith(MockitoJUnitRunner.class)
|
@RunWith(MockitoJUnitRunner.class)
|
||||||
public class ByteScaleUtilsTest extends TestCase {
|
public class ByteScaleUtilsTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void validateMibToBytes() {
|
public void validateMebibytesToBytes() {
|
||||||
long mib = 3000L;
|
long mib = 3000L;
|
||||||
long b = 1024L * 1024L * mib;
|
long bytes = 1024L * 1024L * mib;
|
||||||
assertEquals(b, ByteScaleUtils.mibToBytes(mib));
|
Assert.assertEquals(bytes, ByteScaleUtils.mebibytesToBytes(mib));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void validateBytesToKib() {
|
public void validateBytesToKibibytes() {
|
||||||
long kib = 3000L;
|
long kib = 3000L;
|
||||||
long b = 1024 * kib;
|
long bytes = 1024 * kib;
|
||||||
assertEquals(kib, ByteScaleUtils.bytesToKib(b));
|
Assert.assertEquals(kib, ByteScaleUtils.bytesToKibibytes(bytes));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void validateBytesToMib() {
|
public void validateBytesToMebibytes() {
|
||||||
long mib = 3000L;
|
long mib = 3000L;
|
||||||
long b = 1024L * 1024L * mib;
|
long bytes = 1024L * 1024L * mib;
|
||||||
assertEquals(mib, ByteScaleUtils.bytesToMib(b));
|
Assert.assertEquals(mib, ByteScaleUtils.bytesToMebibytes(bytes));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void validateMibToBytesIfIntTimesIntThenMustExtrapolateIntMaxValue() {
|
public void validateMebibytesToBytesIfIntTimesIntThenMustExtrapolateIntMaxValue() {
|
||||||
int mib = 3000;
|
int mib = 3000;
|
||||||
long b = 1024L * 1024L * mib;
|
long bytes = 1024L * 1024L * mib;
|
||||||
assertEquals(b, ByteScaleUtils.mibToBytes(mib));
|
Assert.assertEquals(bytes, ByteScaleUtils.mebibytesToBytes(mib));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void validateBytesToKibIfIntByIntThenMustExtrapolateIntMaxValue(){
|
public void validateBytesToKibibytesIfIntByIntThenMustExtrapolateIntMaxValue(){
|
||||||
int b = Integer.MAX_VALUE;
|
int bytes = Integer.MAX_VALUE;
|
||||||
assertEquals(b, ByteScaleUtils.bytesToKib(b * 1024L));
|
Assert.assertEquals(bytes, ByteScaleUtils.bytesToKibibytes(bytes * 1024L));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user