You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by gu...@apache.org on 2021/11/25 13:42:56 UTC
[cloudstack] branch main updated: Fix HostMetricsResponse unit test (#5713)
This is an automated email from the ASF dual-hosted git repository.
gutoveronezi pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/cloudstack.git
The following commit(s) were added to refs/heads/main by this push:
new 6e04f87 Fix HostMetricsResponse unit test (#5713)
6e04f87 is described below
commit 6e04f8711b5378829383b350c8133a3bd89a429f
Author: José Flauzino <jo...@gmail.com>
AuthorDate: Thu Nov 25 10:42:31 2021 -0300
Fix HostMetricsResponse unit test (#5713)
Co-authored-by: José Flauzino <jo...@scclouds.com.br>
---
.../apache/cloudstack/response/HostMetricsResponseTest.java | 13 +++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)
diff --git a/plugins/metrics/src/test/java/org/apache/cloudstack/response/HostMetricsResponseTest.java b/plugins/metrics/src/test/java/org/apache/cloudstack/response/HostMetricsResponseTest.java
index 6955ec6..98c8cd3 100644
--- a/plugins/metrics/src/test/java/org/apache/cloudstack/response/HostMetricsResponseTest.java
+++ b/plugins/metrics/src/test/java/org/apache/cloudstack/response/HostMetricsResponseTest.java
@@ -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());
}
}