This is an automated email from the ASF dual-hosted git repository.

rohit 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 c9a95bc22c5 Add unit tests for null cpu for null parameters for set 
allocated cpu (#9137)
c9a95bc22c5 is described below

commit c9a95bc22c57a388f3d0e5f2c9aa3e6601717251
Author: Charles Weng <[email protected]>
AuthorDate: Wed Jun 12 04:32:49 2024 -0700

    Add unit tests for null cpu for null parameters for set allocated cpu 
(#9137)
    
    * Add unit tests for null cpu for null parameters for set allocated cpu
    
    * break up tests for null cpu checks
---
 .../response/HostMetricsResponseTest.java          | 23 ++++++++++++++++++++++
 1 file changed, 23 insertions(+)

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 98c8cd3d97f..d81d6f6dadb 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
@@ -56,4 +56,27 @@ public class HostMetricsResponseTest {
         Assert.assertEquals(expected, hostResponse.getCpuAllocatedGhz());
     }
 
+    @Test
+    public void testSetCpuAllocatedWithNullCpu() {
+        String expected = null;
+        final HostMetricsResponse hostResponse = new HostMetricsResponse();
+        hostResponse.setCpuAllocated(null, 10, 1000L);
+        Assert.assertEquals(expected, hostResponse.getCpuAllocatedGhz());
+    }
+
+    @Test
+    public void testSetCpuAllocatedWithNullCpuNumber() {
+        String expected = null;
+        final HostMetricsResponse hostResponse = new HostMetricsResponse();
+        hostResponse.setCpuAllocated(String.format("50%s25%%", 
decimalSeparator), null, 1000L);
+        Assert.assertEquals(expected, hostResponse.getCpuAllocatedGhz());
+    }
+
+    @Test
+    public void testSetCpuAllocatedWithNullCpuSpeed() {
+        String expected = null;
+        final HostMetricsResponse hostResponse = new HostMetricsResponse();
+        hostResponse.setCpuAllocated(String.format("50%s25%%", 
decimalSeparator), 10, null);
+        Assert.assertEquals(expected, hostResponse.getCpuAllocatedGhz());
+    }
 }

Reply via email to