mirror of https://github.com/apache/cloudstack.git
Fix HostMetricsResponse unit test (#5713)
Co-authored-by: José Flauzino <jose@scclouds.com.br>
This commit is contained in:
parent
9c9de74966
commit
6e04f8711b
|
|
@ -17,6 +17,8 @@
|
|||
|
||||
package org.apache.cloudstack.response;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
|
|
@ -24,11 +26,13 @@ import com.cloud.utils.exception.CloudRuntimeException;
|
|||
|
||||
public class HostMetricsResponseTest {
|
||||
|
||||
final char decimalSeparator = ((DecimalFormat) DecimalFormat.getInstance()).getDecimalFormatSymbols().getDecimalSeparator();
|
||||
|
||||
@Test
|
||||
public void testSetCpuAllocatedWithZeroCpu() {
|
||||
final HostMetricsResponse hostResponse = new HostMetricsResponse();
|
||||
hostResponse.setCpuAllocated("50.25%", 0, 1000L);
|
||||
Assert.assertEquals("0.00 Ghz", hostResponse.getCpuAllocatedGhz());
|
||||
hostResponse.setCpuAllocated(String.format("50%s25%%", decimalSeparator), 0, 1000L);
|
||||
Assert.assertEquals(String.format("0%s00 Ghz", decimalSeparator), hostResponse.getCpuAllocatedGhz());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -46,9 +50,10 @@ public class HostMetricsResponseTest {
|
|||
|
||||
@Test
|
||||
public void testSetCpuAllocatedWithValidCpu() {
|
||||
String expected = String.format("5%s03 Ghz", decimalSeparator);
|
||||
final HostMetricsResponse hostResponse = new HostMetricsResponse();
|
||||
hostResponse.setCpuAllocated("50.25%", 10, 1000L);
|
||||
Assert.assertEquals("5.03 Ghz", hostResponse.getCpuAllocatedGhz());
|
||||
hostResponse.setCpuAllocated(String.format("50%s25%%", decimalSeparator), 10, 1000L);
|
||||
Assert.assertEquals(expected, hostResponse.getCpuAllocatedGhz());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue