|
62 | 62 | import java.util.List; |
63 | 63 | import java.util.Map; |
64 | 64 | import java.util.Properties; |
| 65 | +import java.util.TreeMap; |
65 | 66 | import java.util.concurrent.TimeUnit; |
66 | 67 |
|
67 | 68 | import static org.mockito.Mockito.when; |
@@ -330,7 +331,7 @@ public void persistVirtualMachineStatsTestPersistsSuccessfully() { |
330 | 331 | VmStatsVO actual = vmStatsVOCaptor.getAllValues().get(0); |
331 | 332 | Assert.assertEquals(Long.valueOf(2L), actual.getVmId()); |
332 | 333 | Assert.assertEquals(Long.valueOf(1L), actual.getMgmtServerId()); |
333 | | - Assert.assertEquals(expectedVmStatsStr, actual.getVmStatsData()); |
| 334 | + Assert.assertEquals(convertJsonToOrderedMap(expectedVmStatsStr), convertJsonToOrderedMap(actual.getVmStatsData())); |
334 | 335 | Assert.assertEquals(timestamp, actual.getTimestamp()); |
335 | 336 | } |
336 | 337 |
|
@@ -511,4 +512,14 @@ public void testPersistVolumeStatsKVM() { |
511 | 512 | public void testPersistVolumeStatsVmware() { |
512 | 513 | performPersistVolumeStatsTest(Hypervisor.HypervisorType.VMware); |
513 | 514 | } |
| 515 | + |
| 516 | + private Map<String, String> convertJsonToOrderedMap(String json) { |
| 517 | + Map<String, String> jsonMap = new TreeMap<String, String>(); |
| 518 | + String[] keyValuePairs = json.replace("{", "").replace("}","").split(","); |
| 519 | + for (String pair: keyValuePairs) { |
| 520 | + String[] keyValue = pair.split(":"); |
| 521 | + jsonMap.put(keyValue[0], keyValue[1]); |
| 522 | + } |
| 523 | + return jsonMap; |
| 524 | + } |
514 | 525 | } |
0 commit comments