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
This commit is contained in:
Charles Weng 2024-06-12 04:32:49 -07:00 committed by GitHub
parent faf94387a6
commit c9a95bc22c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -56,4 +56,27 @@ public class HostMetricsResponseTest {
Assert.assertEquals(expected, hostResponse.getCpuAllocatedGhz()); 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());
}
} }