mirror of https://github.com/apache/jclouds.git
added test for allowing ',' decimal separator
This commit is contained in:
parent
dfbdc02ea4
commit
256ba24dd0
|
@ -667,7 +667,7 @@ public class VirtualMachine {
|
|||
* @return the amount of the vm's CPU currently used
|
||||
*/
|
||||
public float getCpuUsed() {
|
||||
return cpuUsed != null ? Float.parseFloat(cpuUsed.substring(0, cpuUsed.length() - 1)) : 0.0f;
|
||||
return cpuUsed != null ? Float.parseFloat(cpuUsed.substring(0, cpuUsed.length() - 1).replace(',', '.')) : 0.0f;
|
||||
}
|
||||
|
||||
private String getCpuUsedAsString() {
|
||||
|
|
|
@ -47,6 +47,10 @@ public class VirtualMachineTest {
|
|||
// Retrieving CpuUsed should just give us a straightforward float
|
||||
vm = VirtualMachine.builder().id("3").cpuUsed("23.4%").build();
|
||||
assertEquals(vm.getCpuUsed(), 23.4, 0.01);
|
||||
|
||||
//Allow ',' as decimal separator
|
||||
vm = VirtualMachine.builder().id("4").cpuUsed("23,4%").build();
|
||||
assertEquals(vm.getCpuUsed(), 23.4, 0.01);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue