# HG changeset patch # User Simon Tooke # Date 1502299570 14400 # Node ID 4a55900090e4811abb1afc7271f395d140dd533f # Parent bfd9802cd49472d10dc0b38edb2f3efea3ec17ad Compare JSON strings as JSON, not strings This patch adds a assertJsonEquals() method to common-test (bringing in Gson at test time), and modifies many of the JUnit tests to use it instead of string compare. Doing a proper JSON compare means whitespace and member order no longer needs to be exact. Member order doesn't matter in JSON objects; only arrays. Reviewed-by: jkang Review-thread: http://icedtea.classpath.org/pipermail/thermostat/2017-August/024424.html diff -r bfd9802cd494 -r 4a55900090e4 common/test/pom.xml --- a/common/test/pom.xml Tue Aug 08 17:12:26 2017 +0200 +++ b/common/test/pom.xml Wed Aug 09 13:26:10 2017 -0400 @@ -65,6 +65,10 @@ mockito-core test + + com.google.code.gson + gson + diff -r bfd9802cd494 -r 4a55900090e4 common/test/src/main/java/com/redhat/thermostat/testutils/JsonUtils.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/common/test/src/main/java/com/redhat/thermostat/testutils/JsonUtils.java Wed Aug 09 13:26:10 2017 -0400 @@ -0,0 +1,52 @@ +/* + * Copyright 2012-2017 Red Hat, Inc. + * + * This file is part of Thermostat. + * + * Thermostat is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published + * by the Free Software Foundation; either version 2, or (at your + * option) any later version. + * + * Thermostat is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Thermostat; see the file COPYING. If not see + * . + * + * Linking this code with other modules is making a combined work + * based on this code. Thus, the terms and conditions of the GNU + * General Public License cover the whole combination. + * + * As a special exception, the copyright holders of this code give + * you permission to link this code with independent modules to + * produce an executable, regardless of the license terms of these + * independent modules, and to copy and distribute the resulting + * executable under terms of your choice, provided that you also + * meet, for each linked independent module, the terms and conditions + * of the license of that module. An independent module is a module + * which is not derived from or based on this code. If you modify + * this code, you may extend this exception to your version of the + * library, but you are not obligated to do so. If you do not wish + * to do so, delete this exception statement from your version. + */ + +package com.redhat.thermostat.testutils; + +import com.google.gson.JsonElement; +import com.google.gson.JsonParser; + +import static org.junit.Assert.assertEquals; + +public class JsonUtils { + + public static void assertJsonEquals(final String expected, final String actual) { + JsonParser parser = new JsonParser(); + JsonElement expel = parser.parse(expected); + JsonElement actel = parser.parse(actual); + assertEquals(expel, actel); + } +} diff -r bfd9802cd494 -r 4a55900090e4 plugins/host-cpu/agent/src/test/java/com/redhat/thermostat/host/cpu/agent/internal/HostCpuBackendTest.java --- a/plugins/host-cpu/agent/src/test/java/com/redhat/thermostat/host/cpu/agent/internal/HostCpuBackendTest.java Tue Aug 08 17:12:26 2017 +0200 +++ b/plugins/host-cpu/agent/src/test/java/com/redhat/thermostat/host/cpu/agent/internal/HostCpuBackendTest.java Wed Aug 09 13:26:10 2017 -0400 @@ -39,8 +39,6 @@ import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import static org.mockito.Matchers.any; -import static org.mockito.Matchers.anyString; -import static org.mockito.Matchers.matches; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.never; import static org.mockito.Mockito.verify; diff -r bfd9802cd494 -r 4a55900090e4 plugins/host-cpu/agent/src/test/java/com/redhat/thermostat/host/cpu/model/CpuStatTypeAdapterTest.java --- a/plugins/host-cpu/agent/src/test/java/com/redhat/thermostat/host/cpu/model/CpuStatTypeAdapterTest.java Tue Aug 08 17:12:26 2017 +0200 +++ b/plugins/host-cpu/agent/src/test/java/com/redhat/thermostat/host/cpu/model/CpuStatTypeAdapterTest.java Wed Aug 09 13:26:10 2017 -0400 @@ -40,6 +40,8 @@ import com.google.gson.Gson; import com.google.gson.reflect.TypeToken; import org.junit.Test; + +import static com.redhat.thermostat.testutils.JsonUtils.assertJsonEquals; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertArrayEquals; @@ -58,7 +60,7 @@ List stats = new ArrayList<>(); stats.add(new CpuStat("1", 1234567890l, new double[]{9.99, 8.88, 3.1415, 7.777})); String result = gson.toJson(stats, cpuStatListType); - assertEquals("[{\"perProcessorUsage\":[9.99,8.88,3.1415,7.777],\"timeStamp\":{\"$numberLong\":\"1234567890\"},\"agentId\":\"1\"}]", result); + assertJsonEquals("[{\"perProcessorUsage\":[9.99,8.88,3.1415,7.777],\"timeStamp\":{\"$numberLong\":\"1234567890\"},\"agentId\":\"1\"}]", result); } @Test @@ -73,7 +75,7 @@ stats.add(new CpuStat("3", 10002320101l, new double[]{1.234, 4.567, 7.8910, 10.111213})); stats.add(new CpuStat("4", 100023313101l, new double[]{1.3235, 4.4567, 7.78911, 10.10111241})); String result = gson.toJson(stats, cpuStatListType); - assertEquals("[{\"perProcessorUsage\":[1.23,4.56,7.89,10.1112],\"timeStamp\":{\"$numberLong\":\"1000230101\"},\"agentId\":\"1\"}," + + assertJsonEquals("[{\"perProcessorUsage\":[1.23,4.56,7.89,10.1112],\"timeStamp\":{\"$numberLong\":\"1000230101\"},\"agentId\":\"1\"}," + "{\"perProcessorUsage\":[1.323,4.456,7.789,10.101112],\"timeStamp\":{\"$numberLong\":\"10002333101\"},\"agentId\":\"2\"}," + "{\"perProcessorUsage\":[1.234,4.567,7.891,10.111213],\"timeStamp\":{\"$numberLong\":\"10002320101\"},\"agentId\":\"3\"}," + "{\"perProcessorUsage\":[1.3235,4.4567,7.78911,10.10111241],\"timeStamp\":{\"$numberLong\":\"100023313101\"},\"agentId\":\"4\"}]", result); diff -r bfd9802cd494 -r 4a55900090e4 plugins/host-memory/agent/src/test/java/com/redhat/thermostat/host/memory/agent/internal/HostMemoryBackendTest.java --- a/plugins/host-memory/agent/src/test/java/com/redhat/thermostat/host/memory/agent/internal/HostMemoryBackendTest.java Tue Aug 08 17:12:26 2017 +0200 +++ b/plugins/host-memory/agent/src/test/java/com/redhat/thermostat/host/memory/agent/internal/HostMemoryBackendTest.java Wed Aug 09 13:26:10 2017 -0400 @@ -40,7 +40,6 @@ import static org.junit.Assert.assertTrue; import static org.mockito.Matchers.any; import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.never; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; diff -r bfd9802cd494 -r 4a55900090e4 plugins/host-memory/agent/src/test/java/com/redhat/thermostat/host/memory/model/MemoryStatTypeAdapterTest.java --- a/plugins/host-memory/agent/src/test/java/com/redhat/thermostat/host/memory/model/MemoryStatTypeAdapterTest.java Tue Aug 08 17:12:26 2017 +0200 +++ b/plugins/host-memory/agent/src/test/java/com/redhat/thermostat/host/memory/model/MemoryStatTypeAdapterTest.java Wed Aug 09 13:26:10 2017 -0400 @@ -45,7 +45,7 @@ import java.util.ArrayList; import java.util.List; -import static org.junit.Assert.assertEquals; +import static com.redhat.thermostat.testutils.JsonUtils.assertJsonEquals; public class MemoryStatTypeAdapterTest { @@ -59,7 +59,7 @@ stats.add(new MemoryStat("1", 123l, 456l, 789l, 101112l, 131415l, 161718l, 192021l, 222324l)); System.out.println(gson.toJson(stats, memoryStatListType)); - assertEquals("[{\"timeStamp\":{\"$numberLong\":\"123\"}," + + assertJsonEquals("[{\"timeStamp\":{\"$numberLong\":\"123\"}," + "\"total\":{\"$numberLong\":\"456\"}," + "\"free\":{\"$numberLong\":\"789\"}," + "\"buffers\":{\"$numberLong\":\"101112\"}," + @@ -85,7 +85,7 @@ 689821l, 786711l, 823542l)); stats.add(new MemoryStat("4", 13332l, 24441l, 37721l, 4321345l, 542131l, 64522l, 71232l, 8231321l)); - assertEquals("[{\"timeStamp\":{\"$numberLong\":\"123\"},\"total\":{\"$numberLong\":\"456\"},\"free\":{\"$numberLong\":\"789\"},\"buffers\":{\"$numberLong\":\"101112\"},\"cached\":{\"$numberLong\":\"131415\"},\"swapTotal\":{\"$numberLong\":\"161718\"},\"swapFree\":{\"$numberLong\":\"192021\"},\"commitLimit\":{\"$numberLong\":\"222324\"},\"agentId\":\"1\"}," + + assertJsonEquals("[{\"timeStamp\":{\"$numberLong\":\"123\"},\"total\":{\"$numberLong\":\"456\"},\"free\":{\"$numberLong\":\"789\"},\"buffers\":{\"$numberLong\":\"101112\"},\"cached\":{\"$numberLong\":\"131415\"},\"swapTotal\":{\"$numberLong\":\"161718\"},\"swapFree\":{\"$numberLong\":\"192021\"},\"commitLimit\":{\"$numberLong\":\"222324\"},\"agentId\":\"1\"}," + "{\"timeStamp\":{\"$numberLong\":\"1\"},\"total\":{\"$numberLong\":\"2\"},\"free\":{\"$numberLong\":\"3\"},\"buffers\":{\"$numberLong\":\"4\"},\"cached\":{\"$numberLong\":\"5\"},\"swapTotal\":{\"$numberLong\":\"6\"},\"swapFree\":{\"$numberLong\":\"7\"},\"commitLimit\":{\"$numberLong\":\"8\"},\"agentId\":\"2\"}," + "{\"timeStamp\":{\"$numberLong\":\"17756\"},\"total\":{\"$numberLong\":\"25365323\"},\"free\":{\"$numberLong\":\"3124213\"},\"buffers\":{\"$numberLong\":\"4465434\"},\"cached\":{\"$numberLong\":\"578687\"},\"swapTotal\":{\"$numberLong\":\"689821\"},\"swapFree\":{\"$numberLong\":\"786711\"},\"commitLimit\":{\"$numberLong\":\"823542\"},\"agentId\":\"3\"}," + "{\"timeStamp\":{\"$numberLong\":\"13332\"},\"total\":{\"$numberLong\":\"24441\"},\"free\":{\"$numberLong\":\"37721\"},\"buffers\":{\"$numberLong\":\"4321345\"},\"cached\":{\"$numberLong\":\"542131\"},\"swapTotal\":{\"$numberLong\":\"64522\"},\"swapFree\":{\"$numberLong\":\"71232\"},\"commitLimit\":{\"$numberLong\":\"8231321\"},\"agentId\":\"4\"}]", diff -r bfd9802cd494 -r 4a55900090e4 plugins/host-network/agent/src/test/java/com/redhat/thermostat/host/network/model/NetworkInfoListTypeAdapterTest.java --- a/plugins/host-network/agent/src/test/java/com/redhat/thermostat/host/network/model/NetworkInfoListTypeAdapterTest.java Tue Aug 08 17:12:26 2017 +0200 +++ b/plugins/host-network/agent/src/test/java/com/redhat/thermostat/host/network/model/NetworkInfoListTypeAdapterTest.java Wed Aug 09 13:26:10 2017 -0400 @@ -36,7 +36,7 @@ package com.redhat.thermostat.host.network.model; -import static org.junit.Assert.assertEquals; +import static com.redhat.thermostat.testutils.JsonUtils.assertJsonEquals; import java.util.ArrayList; import java.util.Arrays; @@ -60,7 +60,7 @@ NetworkInfoList infos = createNetworkInfoList(first, second); String json = adapter.toJson(Arrays.asList(infos)); - assertEquals(expected, json); + assertJsonEquals(expected, json); } private NetworkInfoList createNetworkInfoList(String iFace, String ip4Addr, String ip6Addr) { diff -r bfd9802cd494 -r 4a55900090e4 plugins/host-network/agent/src/test/java/com/redhat/thermostat/host/network/model/NetworkInterfaceInfoTypeAdapterTest.java --- a/plugins/host-network/agent/src/test/java/com/redhat/thermostat/host/network/model/NetworkInterfaceInfoTypeAdapterTest.java Tue Aug 08 17:12:26 2017 +0200 +++ b/plugins/host-network/agent/src/test/java/com/redhat/thermostat/host/network/model/NetworkInterfaceInfoTypeAdapterTest.java Wed Aug 09 13:26:10 2017 -0400 @@ -36,6 +36,7 @@ package com.redhat.thermostat.host.network.model; +import static com.redhat.thermostat.testutils.JsonUtils.assertJsonEquals; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNull; @@ -58,7 +59,7 @@ List infos = Arrays.asList(first, second); String json = adapter.toJson(infos); - assertEquals(expected, json); + assertJsonEquals(expected, json); } @Test diff -r bfd9802cd494 -r 4a55900090e4 plugins/host-overview/agent/src/test/java/com/redhat/thermostat/host/overview/model/HostInfoTypeAdapterTest.java --- a/plugins/host-overview/agent/src/test/java/com/redhat/thermostat/host/overview/model/HostInfoTypeAdapterTest.java Tue Aug 08 17:12:26 2017 +0200 +++ b/plugins/host-overview/agent/src/test/java/com/redhat/thermostat/host/overview/model/HostInfoTypeAdapterTest.java Wed Aug 09 13:26:10 2017 -0400 @@ -36,7 +36,7 @@ package com.redhat.thermostat.host.overview.model; -import static org.junit.Assert.assertEquals; +import static com.redhat.thermostat.testutils.JsonUtils.assertJsonEquals; import java.util.Arrays; import java.util.List; @@ -69,7 +69,7 @@ List infos = Arrays.asList(first, second); String json = adapter.toJson(infos); - assertEquals(expected, json); + assertJsonEquals(expected, json); } } diff -r bfd9802cd494 -r 4a55900090e4 plugins/jvm-overview/agent/pom.xml --- a/plugins/jvm-overview/agent/pom.xml Tue Aug 08 17:12:26 2017 +0200 +++ b/plugins/jvm-overview/agent/pom.xml Wed Aug 09 13:26:10 2017 -0400 @@ -182,5 +182,10 @@ org.apache.felix org.apache.felix.scr.annotations + + com.redhat.thermostat + thermostat-common-plugin + 1.99.12-SNAPSHOT + diff -r bfd9802cd494 -r 4a55900090e4 plugins/jvm-overview/agent/src/test/java/com/redhat/thermostat/jvm/overview/agent/internal/model/VmInfoTypeAdapterTest.java --- a/plugins/jvm-overview/agent/src/test/java/com/redhat/thermostat/jvm/overview/agent/internal/model/VmInfoTypeAdapterTest.java Tue Aug 08 17:12:26 2017 +0200 +++ b/plugins/jvm-overview/agent/src/test/java/com/redhat/thermostat/jvm/overview/agent/internal/model/VmInfoTypeAdapterTest.java Wed Aug 09 13:26:10 2017 -0400 @@ -36,7 +36,7 @@ package com.redhat.thermostat.jvm.overview.agent.internal.model; -import static org.junit.Assert.assertEquals; +import static com.redhat.thermostat.testutils.JsonUtils.assertJsonEquals; import java.util.Arrays; import java.util.HashMap; @@ -88,7 +88,7 @@ List infos = Arrays.asList(first, second); String json = adapter.toJson(infos); - assertEquals(expected, json); + assertJsonEquals(expected, json); } @Test @@ -98,7 +98,7 @@ VmInfoUpdate update = new VmInfoUpdate(5000L); String json = adapter.toJson(update); - assertEquals(expected, json); + assertJsonEquals(expected, json); } } diff -r bfd9802cd494 -r 4a55900090e4 plugins/numa/common/src/test/java/com/redhat/thermostat/numa/common/internal/NumaHostInfoTypeAdapterTest.java --- a/plugins/numa/common/src/test/java/com/redhat/thermostat/numa/common/internal/NumaHostInfoTypeAdapterTest.java Tue Aug 08 17:12:26 2017 +0200 +++ b/plugins/numa/common/src/test/java/com/redhat/thermostat/numa/common/internal/NumaHostInfoTypeAdapterTest.java Wed Aug 09 13:26:10 2017 -0400 @@ -41,7 +41,7 @@ import com.redhat.thermostat.numa.common.NumaHostInfo; import org.junit.Test; -import static org.junit.Assert.assertEquals; +import static com.redhat.thermostat.testutils.JsonUtils.assertJsonEquals; public class NumaHostInfoTypeAdapterTest { @@ -52,7 +52,7 @@ Gson gson = builder.create(); NumaHostInfo info = new NumaHostInfo("1"); info.setNumNumaNodes(4); - assertEquals("{" + + assertJsonEquals("{" + "\"numNumaNodes\":4," + "\"agentId\":\"1\"" + "}", gson.toJson(info)); diff -r bfd9802cd494 -r 4a55900090e4 plugins/numa/common/src/test/java/com/redhat/thermostat/numa/common/internal/NumaNodeStatTypeAdapterTest.java --- a/plugins/numa/common/src/test/java/com/redhat/thermostat/numa/common/internal/NumaNodeStatTypeAdapterTest.java Tue Aug 08 17:12:26 2017 +0200 +++ b/plugins/numa/common/src/test/java/com/redhat/thermostat/numa/common/internal/NumaNodeStatTypeAdapterTest.java Wed Aug 09 13:26:10 2017 -0400 @@ -37,7 +37,8 @@ package com.redhat.thermostat.numa.common.internal; import org.junit.Test; -import static org.junit.Assert.assertEquals; + +import static com.redhat.thermostat.testutils.JsonUtils.assertJsonEquals; import com.redhat.thermostat.numa.common.NumaNodeStat; @@ -67,7 +68,7 @@ s.setOtherNode(6l); s.setNodeId(7); stats.add(s); - assertEquals("{" + + assertJsonEquals("{" + "\"numaHit\":{\"$numberLong\":\"1\"}," + "\"numaMiss\":{\"$numberLong\":\"2\"}," + "\"numaForeign\":{\"$numberLong\":\"3\"}," + diff -r bfd9802cd494 -r 4a55900090e4 plugins/numa/common/src/test/java/com/redhat/thermostat/numa/common/internal/NumaStatTypeAdapterTest.java --- a/plugins/numa/common/src/test/java/com/redhat/thermostat/numa/common/internal/NumaStatTypeAdapterTest.java Tue Aug 08 17:12:26 2017 +0200 +++ b/plugins/numa/common/src/test/java/com/redhat/thermostat/numa/common/internal/NumaStatTypeAdapterTest.java Wed Aug 09 13:26:10 2017 -0400 @@ -38,7 +38,8 @@ import com.google.gson.reflect.TypeToken; import org.junit.Test; -import static org.junit.Assert.assertEquals; + +import static com.redhat.thermostat.testutils.JsonUtils.assertJsonEquals; import com.redhat.thermostat.numa.common.NumaNodeStat; import com.redhat.thermostat.numa.common.NumaStat; @@ -73,7 +74,7 @@ stats[0] = s; stat.setNodeStats(stats); testStats.add(stat); - assertEquals("[{\"timeStamp\":{\"$numberLong\":\"2\"}," + + assertJsonEquals("[{\"timeStamp\":{\"$numberLong\":\"2\"}," + "\"nodeStats\":[{\"numaHit\":{\"$numberLong\":\"1\"}," + "\"numaMiss\":{\"$numberLong\":\"2\"}," + "\"numaForeign\":{\"$numberLong\":\"3\"}," + @@ -118,6 +119,6 @@ stat2.setNodeStats(stats2); testStats.add(stat); testStats.add(stat2); - assertEquals("[{\"timeStamp\":{\"$numberLong\":\"2\"},\"nodeStats\":[{\"numaHit\":{\"$numberLong\":\"1\"},\"numaMiss\":{\"$numberLong\":\"2\"},\"numaForeign\":{\"$numberLong\":\"3\"},\"interleaveHit\":{\"$numberLong\":\"4\"},\"localNode\":{\"$numberLong\":\"5\"},\"otherNode\":{\"$numberLong\":\"6\"},\"nodeId\":7}],\"agentId\":\"1\"},{\"timeStamp\":{\"$numberLong\":\"-1\"},\"nodeStats\":[{\"numaHit\":{\"$numberLong\":\"10\"},\"numaMiss\":{\"$numberLong\":\"20\"},\"numaForeign\":{\"$numberLong\":\"30\"},\"interleaveHit\":{\"$numberLong\":\"40\"},\"localNode\":{\"$numberLong\":\"50\"},\"otherNode\":{\"$numberLong\":\"60\"},\"nodeId\":70}],\"agentId\":\"2\"}]", gson.toJson(testStats, list_type)); + assertJsonEquals("[{\"timeStamp\":{\"$numberLong\":\"2\"},\"nodeStats\":[{\"numaHit\":{\"$numberLong\":\"1\"},\"numaMiss\":{\"$numberLong\":\"2\"},\"numaForeign\":{\"$numberLong\":\"3\"},\"interleaveHit\":{\"$numberLong\":\"4\"},\"localNode\":{\"$numberLong\":\"5\"},\"otherNode\":{\"$numberLong\":\"6\"},\"nodeId\":7}],\"agentId\":\"1\"},{\"timeStamp\":{\"$numberLong\":\"-1\"},\"nodeStats\":[{\"numaHit\":{\"$numberLong\":\"10\"},\"numaMiss\":{\"$numberLong\":\"20\"},\"numaForeign\":{\"$numberLong\":\"30\"},\"interleaveHit\":{\"$numberLong\":\"40\"},\"localNode\":{\"$numberLong\":\"50\"},\"otherNode\":{\"$numberLong\":\"60\"},\"nodeId\":70}],\"agentId\":\"2\"}]", gson.toJson(testStats, list_type)); } } \ No newline at end of file diff -r bfd9802cd494 -r 4a55900090e4 plugins/thread/collector/src/test/java/com/redhat/thermostat/thread/dao/internal/LockInfoTypeAdapterTest.java --- a/plugins/thread/collector/src/test/java/com/redhat/thermostat/thread/dao/internal/LockInfoTypeAdapterTest.java Tue Aug 08 17:12:26 2017 +0200 +++ b/plugins/thread/collector/src/test/java/com/redhat/thermostat/thread/dao/internal/LockInfoTypeAdapterTest.java Wed Aug 09 13:26:10 2017 -0400 @@ -39,9 +39,10 @@ import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.redhat.thermostat.thread.model.LockInfo; -import org.junit.Assert; import org.junit.Test; +import static com.redhat.thermostat.testutils.JsonUtils.assertJsonEquals; + public class LockInfoTypeAdapterTest { @Test @@ -51,6 +52,6 @@ Gson gson = builder.create(); LockInfo info = new LockInfo(100l, "Agent-1", "Vm-1", 123l, 321l, 432l, 5454l, 578l, 678574l, 21349l, 0l, 2342342l, 12311l, 13211l, 934l, 8911l, 305934l, 2194l, 892l, 100l, 2321l); - Assert.assertEquals("{\"agentId\":\"Agent-1\",\"vmId\":\"Vm-1\",\"timeStamp\":{\"$numberLong\":\"100\"},\"contendedLockAttempts\":{\"$numberLong\":\"123\"},\"deflations\":{\"$numberLong\":\"321\"},\"emptyNotifications\":{\"$numberLong\":\"432\"},\"failedSpins\":{\"$numberLong\":\"5454\"},\"futileWakeups\":{\"$numberLong\":\"578\"},\"inflations\":{\"$numberLong\":\"678574\"},\"monExtant\":{\"$numberLong\":\"21349\"},\"monInCirculation\":{\"$numberLong\":\"0\"},\"monScavenged\":{\"$numberLong\":\"2342342\"},\"notifications\":{\"$numberLong\":\"12311\"},\"parks\":{\"$numberLong\":\"13211\"},\"privateA\":{\"$numberLong\":\"934\"},\"privateB\":{\"$numberLong\":\"8911\"},\"slowEnter\":{\"$numberLong\":\"305934\"},\"slowExit\":{\"$numberLong\":\"2194\"},\"slowNotify\":{\"$numberLong\":\"892\"},\"slowNotifyAll\":{\"$numberLong\":\"100\"},\"successfulSpins\":{\"$numberLong\":\"2321\"}}", gson.toJson(info)); + assertJsonEquals("{\"agentId\":\"Agent-1\",\"vmId\":\"Vm-1\",\"timeStamp\":{\"$numberLong\":\"100\"},\"contendedLockAttempts\":{\"$numberLong\":\"123\"},\"deflations\":{\"$numberLong\":\"321\"},\"emptyNotifications\":{\"$numberLong\":\"432\"},\"failedSpins\":{\"$numberLong\":\"5454\"},\"futileWakeups\":{\"$numberLong\":\"578\"},\"inflations\":{\"$numberLong\":\"678574\"},\"monExtant\":{\"$numberLong\":\"21349\"},\"monInCirculation\":{\"$numberLong\":\"0\"},\"monScavenged\":{\"$numberLong\":\"2342342\"},\"notifications\":{\"$numberLong\":\"12311\"},\"parks\":{\"$numberLong\":\"13211\"},\"privateA\":{\"$numberLong\":\"934\"},\"privateB\":{\"$numberLong\":\"8911\"},\"slowEnter\":{\"$numberLong\":\"305934\"},\"slowExit\":{\"$numberLong\":\"2194\"},\"slowNotify\":{\"$numberLong\":\"892\"},\"slowNotifyAll\":{\"$numberLong\":\"100\"},\"successfulSpins\":{\"$numberLong\":\"2321\"}}", gson.toJson(info)); } } diff -r bfd9802cd494 -r 4a55900090e4 plugins/thread/collector/src/test/java/com/redhat/thermostat/thread/dao/internal/ThreadHarvestingStatusTypeAdapterTest.java --- a/plugins/thread/collector/src/test/java/com/redhat/thermostat/thread/dao/internal/ThreadHarvestingStatusTypeAdapterTest.java Tue Aug 08 17:12:26 2017 +0200 +++ b/plugins/thread/collector/src/test/java/com/redhat/thermostat/thread/dao/internal/ThreadHarvestingStatusTypeAdapterTest.java Wed Aug 09 13:26:10 2017 -0400 @@ -41,7 +41,7 @@ import com.redhat.thermostat.thread.model.ThreadHarvestingStatus; import org.junit.Test; -import static org.junit.Assert.assertEquals; +import static com.redhat.thermostat.testutils.JsonUtils.assertJsonEquals; public class ThreadHarvestingStatusTypeAdapterTest { @@ -55,7 +55,7 @@ status.setVmId("Vm-1"); status.setHarvesting(true); status.setTimeStamp(100l); - assertEquals("{\"agentId\":\"Agent-1\",\"vmId\":\"Vm-1\",\"timeStamp\":{\"$numberLong\":\"100\"},\"collecting\":true}", gson.toJson(status)); + assertJsonEquals("{\"agentId\":\"Agent-1\",\"vmId\":\"Vm-1\",\"timeStamp\":{\"$numberLong\":\"100\"},\"collecting\":true}", gson.toJson(status)); } } diff -r bfd9802cd494 -r 4a55900090e4 plugins/thread/collector/src/test/java/com/redhat/thermostat/thread/dao/internal/ThreadSessionTypeAdapterTest.java --- a/plugins/thread/collector/src/test/java/com/redhat/thermostat/thread/dao/internal/ThreadSessionTypeAdapterTest.java Tue Aug 08 17:12:26 2017 +0200 +++ b/plugins/thread/collector/src/test/java/com/redhat/thermostat/thread/dao/internal/ThreadSessionTypeAdapterTest.java Wed Aug 09 13:26:10 2017 -0400 @@ -41,7 +41,7 @@ import com.redhat.thermostat.thread.model.ThreadSession; import org.junit.Test; -import static org.junit.Assert.assertEquals; +import static com.redhat.thermostat.testutils.JsonUtils.assertJsonEquals; public class ThreadSessionTypeAdapterTest { @@ -55,6 +55,6 @@ session.setVmId("Vm-1"); session.setTimeStamp(100l); session.setSession("Session"); - assertEquals("{\"agentId\":\"Agent-1\",\"vmId\":\"Vm-1\",\"timeStamp\":{\"$numberLong\":\"100\"},\"session\":\"Session\",\"sessionID\":{\"id\":\"Session\"}}", gson.toJson(session)); + assertJsonEquals("{\"agentId\":\"Agent-1\",\"vmId\":\"Vm-1\",\"timeStamp\":{\"$numberLong\":\"100\"},\"session\":\"Session\",\"sessionID\":{\"id\":\"Session\"}}", gson.toJson(session)); } } diff -r bfd9802cd494 -r 4a55900090e4 plugins/thread/collector/src/test/java/com/redhat/thermostat/thread/dao/internal/ThreadStateTypeAdapterTest.java --- a/plugins/thread/collector/src/test/java/com/redhat/thermostat/thread/dao/internal/ThreadStateTypeAdapterTest.java Tue Aug 08 17:12:26 2017 +0200 +++ b/plugins/thread/collector/src/test/java/com/redhat/thermostat/thread/dao/internal/ThreadStateTypeAdapterTest.java Wed Aug 09 13:26:10 2017 -0400 @@ -41,7 +41,7 @@ import com.redhat.thermostat.thread.model.ThreadState; import org.junit.Test; -import static org.junit.Assert.assertEquals; +import static com.redhat.thermostat.testutils.JsonUtils.assertJsonEquals; public class ThreadStateTypeAdapterTest { @@ -64,6 +64,6 @@ state.setName("Thread-1"); state.setWaitedCount(30l); state.setWaitedTime(1003l); - assertEquals("{\"agentId\":\"Agent-1\",\"vmId\":\"Vm-1\",\"name\":\"Thread-1\",\"session\":\"Session\",\"id\":{\"$numberLong\":\"1\"},\"suspended\":true,\"inNative\":true,\"blockedCount\":{\"$numberLong\":\"100\"},\"blockedTime\":{\"$numberLong\":\"200\"},\"waitedCount\":{\"$numberLong\":\"30\"},\"waitedTime\":{\"$numberLong\":\"1003\"},\"stackTrace\":\"foo.bar.baz\"}", gson.toJson(state)); + assertJsonEquals("{\"agentId\":\"Agent-1\",\"vmId\":\"Vm-1\",\"name\":\"Thread-1\",\"session\":\"Session\",\"id\":{\"$numberLong\":\"1\"},\"suspended\":true,\"inNative\":true,\"blockedCount\":{\"$numberLong\":\"100\"},\"blockedTime\":{\"$numberLong\":\"200\"},\"waitedCount\":{\"$numberLong\":\"30\"},\"waitedTime\":{\"$numberLong\":\"1003\"},\"stackTrace\":\"foo.bar.baz\"}", gson.toJson(state)); } } diff -r bfd9802cd494 -r 4a55900090e4 plugins/thread/collector/src/test/java/com/redhat/thermostat/thread/dao/internal/ThreadSummaryTypeAdapterTest.java --- a/plugins/thread/collector/src/test/java/com/redhat/thermostat/thread/dao/internal/ThreadSummaryTypeAdapterTest.java Tue Aug 08 17:12:26 2017 +0200 +++ b/plugins/thread/collector/src/test/java/com/redhat/thermostat/thread/dao/internal/ThreadSummaryTypeAdapterTest.java Wed Aug 09 13:26:10 2017 -0400 @@ -41,7 +41,7 @@ import com.redhat.thermostat.thread.model.ThreadSummary; import org.junit.Test; -import static junit.framework.Assert.assertEquals; +import static com.redhat.thermostat.testutils.JsonUtils.assertJsonEquals; public class ThreadSummaryTypeAdapterTest { @@ -56,7 +56,7 @@ summary.setVmId("VM-1"); summary.setCurrentDaemonThreads(3232l); summary.setCurrentLiveThreads(2222l); - assertEquals("{\"agentId\":\"Agent-1\",\"vmId\":\"VM-1\",\"timeStamp\":{\"$numberLong\":\"10\"},\"currentLiveThreads\":{\"$numberLong\":\"2222\"},\"daemonThreads\":{\"$numberLong\":\"3232\"}}", gson.toJson(summary)); + assertJsonEquals("{\"agentId\":\"Agent-1\",\"vmId\":\"VM-1\",\"timeStamp\":{\"$numberLong\":\"10\"},\"currentLiveThreads\":{\"$numberLong\":\"2222\"},\"daemonThreads\":{\"$numberLong\":\"3232\"}}", gson.toJson(summary)); } } diff -r bfd9802cd494 -r 4a55900090e4 plugins/thread/collector/src/test/java/com/redhat/thermostat/thread/dao/internal/VmDeadLockDataTypeAdapterTest.java --- a/plugins/thread/collector/src/test/java/com/redhat/thermostat/thread/dao/internal/VmDeadLockDataTypeAdapterTest.java Tue Aug 08 17:12:26 2017 +0200 +++ b/plugins/thread/collector/src/test/java/com/redhat/thermostat/thread/dao/internal/VmDeadLockDataTypeAdapterTest.java Wed Aug 09 13:26:10 2017 -0400 @@ -42,6 +42,8 @@ import org.junit.Assert; import org.junit.Test; +import static com.redhat.thermostat.testutils.JsonUtils.assertJsonEquals; + public class VmDeadLockDataTypeAdapterTest { @Test @@ -54,6 +56,6 @@ data.setAgentId("Agent-1"); data.setVmId("Vm-1"); data.setDeadLockDescription("This is a description"); - Assert.assertEquals("{\"agentId\":\"Agent-1\",\"vmId\":\"Vm-1\",\"timeStamp\":{\"$numberLong\":\"100\"},\"description\":\"This is a description\"}", gson.toJson(data)); + assertJsonEquals("{\"agentId\":\"Agent-1\",\"vmId\":\"Vm-1\",\"timeStamp\":{\"$numberLong\":\"100\"},\"description\":\"This is a description\"}", gson.toJson(data)); } } diff -r bfd9802cd494 -r 4a55900090e4 plugins/vm-byteman/common/src/test/java/com/redhat/thermostat/vm/byteman/common/internal/BytemanMetricTypeAdapterTest.java --- a/plugins/vm-byteman/common/src/test/java/com/redhat/thermostat/vm/byteman/common/internal/BytemanMetricTypeAdapterTest.java Tue Aug 08 17:12:26 2017 +0200 +++ b/plugins/vm-byteman/common/src/test/java/com/redhat/thermostat/vm/byteman/common/internal/BytemanMetricTypeAdapterTest.java Wed Aug 09 13:26:10 2017 -0400 @@ -36,6 +36,7 @@ package com.redhat.thermostat.vm.byteman.common.internal; +import static com.redhat.thermostat.testutils.JsonUtils.assertJsonEquals; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNull; @@ -114,7 +115,7 @@ " }\n" + "}"; BytemanMetric metric = gson.fromJson(json, BytemanMetric.class); - assertEquals("{\"key\":\"value = 'foo', 'bar', 'baz'\"}", metric.getData()); + assertJsonEquals("{\"key\":\"value = 'foo', 'bar', 'baz'\"}", metric.getData()); Map dataAsMap = metric.getDataAsMap(); assertEquals("value = 'foo', 'bar', 'baz'", dataAsMap.get("key")); } diff -r bfd9802cd494 -r 4a55900090e4 plugins/vm-byteman/common/src/test/java/com/redhat/thermostat/vm/byteman/common/internal/BytemanMetricWebTypeAdapterTest.java --- a/plugins/vm-byteman/common/src/test/java/com/redhat/thermostat/vm/byteman/common/internal/BytemanMetricWebTypeAdapterTest.java Tue Aug 08 17:12:26 2017 +0200 +++ b/plugins/vm-byteman/common/src/test/java/com/redhat/thermostat/vm/byteman/common/internal/BytemanMetricWebTypeAdapterTest.java Wed Aug 09 13:26:10 2017 -0400 @@ -41,7 +41,7 @@ import com.redhat.thermostat.vm.byteman.common.BytemanMetric; import org.junit.Test; -import static org.junit.Assert.assertEquals; +import static com.redhat.thermostat.testutils.JsonUtils.assertJsonEquals; public class BytemanMetricWebTypeAdapterTest { @@ -56,6 +56,6 @@ metric.setAgentId("Agent-1"); metric.setMarker("Marker"); metric.setData("{\"data\":\"This is data\"}"); - assertEquals("{\"agentId\":\"Agent-1\",\"vmId\":\"Vm-1\",\"marker\":\"Marker\",\"jsonPayload\":\"{\\\"data\\\":\\\"This is data\\\"}\",\"timeStamp\":{\"$numberLong\":\"100\"}}", gson.toJson(metric)); + assertJsonEquals("{\"agentId\":\"Agent-1\",\"vmId\":\"Vm-1\",\"marker\":\"Marker\",\"jsonPayload\":\"{\\\"data\\\":\\\"This is data\\\"}\",\"timeStamp\":{\"$numberLong\":\"100\"}}", gson.toJson(metric)); } } diff -r bfd9802cd494 -r 4a55900090e4 plugins/vm-byteman/common/src/test/java/com/redhat/thermostat/vm/byteman/common/internal/VmBytemanStatusTypeAdapterTest.java --- a/plugins/vm-byteman/common/src/test/java/com/redhat/thermostat/vm/byteman/common/internal/VmBytemanStatusTypeAdapterTest.java Tue Aug 08 17:12:26 2017 +0200 +++ b/plugins/vm-byteman/common/src/test/java/com/redhat/thermostat/vm/byteman/common/internal/VmBytemanStatusTypeAdapterTest.java Wed Aug 09 13:26:10 2017 -0400 @@ -41,7 +41,7 @@ import com.redhat.thermostat.vm.byteman.common.VmBytemanStatus; import org.junit.Test; -import static org.junit.Assert.assertEquals; +import static com.redhat.thermostat.testutils.JsonUtils.assertJsonEquals; public class VmBytemanStatusTypeAdapterTest { @@ -56,7 +56,7 @@ status.setVmId("Vm-1"); status.setListenPort(27518); status.setRule("Rule"); - assertEquals("{\"agentId\":\"Agent-1\",\"vmId\":\"Vm-1\",\"timeStamp\":{\"$numberLong\":\"100\"},\"rule\":\"Rule\",\"listenPort\":27518}", gson.toJson(status)); + assertJsonEquals("{\"agentId\":\"Agent-1\",\"vmId\":\"Vm-1\",\"timeStamp\":{\"$numberLong\":\"100\"},\"rule\":\"Rule\",\"listenPort\":27518}", gson.toJson(status)); } } diff -r bfd9802cd494 -r 4a55900090e4 plugins/vm-classstat/common/src/test/java/com/redhat/thermostat/vm/classstat/common/internal/VmClassStatTypeAdapterTest.java --- a/plugins/vm-classstat/common/src/test/java/com/redhat/thermostat/vm/classstat/common/internal/VmClassStatTypeAdapterTest.java Tue Aug 08 17:12:26 2017 +0200 +++ b/plugins/vm-classstat/common/src/test/java/com/redhat/thermostat/vm/classstat/common/internal/VmClassStatTypeAdapterTest.java Wed Aug 09 13:26:10 2017 -0400 @@ -42,7 +42,7 @@ import com.redhat.thermostat.vm.classstat.common.model.VmClassStat; -import static org.junit.Assert.assertEquals; +import static com.redhat.thermostat.testutils.JsonUtils.assertJsonEquals; public class VmClassStatTypeAdapterTest { @@ -60,6 +60,6 @@ stat.setLoadedClasses(1l); stat.setUnloadedBytes(10l); stat.setUnloadedClasses(1l); - assertEquals("{\"vmId\":\"1\",\"agentId\":\"2\",\"loadedClasses\":{\"$numberLong\":\"1\"},\"loadedBytes\":{\"$numberLong\":\"10\"},\"unloadedClasses\":{\"$numberLong\":\"1\"},\"unloadedBytes\":{\"$numberLong\":\"10\"},\"classLoadTime\":{\"$numberLong\":\"2000\"},\"timeStamp\":{\"$numberLong\":\"100\"}}", gson.toJson(stat)); + assertJsonEquals("{\"vmId\":\"1\",\"agentId\":\"2\",\"loadedClasses\":{\"$numberLong\":\"1\"},\"loadedBytes\":{\"$numberLong\":\"10\"},\"unloadedClasses\":{\"$numberLong\":\"1\"},\"unloadedBytes\":{\"$numberLong\":\"10\"},\"classLoadTime\":{\"$numberLong\":\"2000\"},\"timeStamp\":{\"$numberLong\":\"100\"}}", gson.toJson(stat)); } } diff -r bfd9802cd494 -r 4a55900090e4 plugins/vm-compiler/common/src/test/java/com/redhat/thermostat/vm/compiler/common/internal/VmCompilerStatTypeAdapterTest.java --- a/plugins/vm-compiler/common/src/test/java/com/redhat/thermostat/vm/compiler/common/internal/VmCompilerStatTypeAdapterTest.java Tue Aug 08 17:12:26 2017 +0200 +++ b/plugins/vm-compiler/common/src/test/java/com/redhat/thermostat/vm/compiler/common/internal/VmCompilerStatTypeAdapterTest.java Wed Aug 09 13:26:10 2017 -0400 @@ -40,7 +40,8 @@ import com.google.gson.Gson; import com.redhat.thermostat.vm.compiler.common.VmCompilerStat; import org.junit.Test; -import static org.junit.Assert.assertEquals; + +import static com.redhat.thermostat.testutils.JsonUtils.assertJsonEquals; public class VmCompilerStatTypeAdapterTest { @@ -63,6 +64,6 @@ stat.setTotalBailouts(30l); stat.setTotalCompiles(40l); System.out.println(gson.toJson(stat)); - assertEquals("{\"agentId\":\"1\",\"vmId\":\"1\",\"timeStamp\":{\"$numberLong\":\"100\"},\"totalCompiles\":{\"$numberLong\":\"40\"},\"totalBailouts\":{\"$numberLong\":\"30\"},\"totalInvalidates\":{\"$numberLong\":\"10\"},\"compilationTime\":{\"$numberLong\":\"20\"},\"lastSize\":{\"$numberLong\":\"300\"},\"lastType\":{\"$numberLong\":\"2\"},\"lastMethod\":\"successfulMethod()\",\"lastFailedType\":{\"$numberLong\":\"1\"},\"lastFailedMethod\":\"methodFail()\"}", gson.toJson(stat)); + assertJsonEquals("{\"agentId\":\"1\",\"vmId\":\"1\",\"timeStamp\":{\"$numberLong\":\"100\"},\"totalCompiles\":{\"$numberLong\":\"40\"},\"totalBailouts\":{\"$numberLong\":\"30\"},\"totalInvalidates\":{\"$numberLong\":\"10\"},\"compilationTime\":{\"$numberLong\":\"20\"},\"lastSize\":{\"$numberLong\":\"300\"},\"lastType\":{\"$numberLong\":\"2\"},\"lastMethod\":\"successfulMethod()\",\"lastFailedType\":{\"$numberLong\":\"1\"},\"lastFailedMethod\":\"methodFail()\"}", gson.toJson(stat)); } } diff -r bfd9802cd494 -r 4a55900090e4 plugins/vm-gc/agent/src/test/java/com/redhat/thermostat/vm/gc/agent/internal/models/VmGcStatTypeAdapterTest.java --- a/plugins/vm-gc/agent/src/test/java/com/redhat/thermostat/vm/gc/agent/internal/models/VmGcStatTypeAdapterTest.java Tue Aug 08 17:12:26 2017 +0200 +++ b/plugins/vm-gc/agent/src/test/java/com/redhat/thermostat/vm/gc/agent/internal/models/VmGcStatTypeAdapterTest.java Wed Aug 09 13:26:10 2017 -0400 @@ -36,7 +36,7 @@ package com.redhat.thermostat.vm.gc.agent.internal.models; -import static org.junit.Assert.assertEquals; +import static com.redhat.thermostat.testutils.JsonUtils.assertJsonEquals; import java.util.Arrays; @@ -56,7 +56,7 @@ stat.setCollectorName("Collector"); stat.setRunCount(10l); stat.setWallTime(200l); - assertEquals("[{\"agentId\":\"1\",\"jvmId\":\"2\",\"timeStamp\":{\"$numberLong\":\"100\"},\"collectorName\":\"Collector\",\"runCount\":{\"$numberLong\":\"10\"},\"wallTimeInMicros\":{\"$numberLong\":\"200\"}}]", + assertJsonEquals("[{\"agentId\":\"1\",\"jvmId\":\"2\",\"timeStamp\":{\"$numberLong\":\"100\"},\"collectorName\":\"Collector\",\"runCount\":{\"$numberLong\":\"10\"},\"wallTimeInMicros\":{\"$numberLong\":\"200\"}}]", typeAdapter.toJson(Arrays.asList(stat))); } } diff -r bfd9802cd494 -r 4a55900090e4 plugins/vm-heap-analysis/common/src/test/java/com/redhat/thermostat/vm/heap/analysis/common/internal/HeapInfoTypeAdapterTest.java --- a/plugins/vm-heap-analysis/common/src/test/java/com/redhat/thermostat/vm/heap/analysis/common/internal/HeapInfoTypeAdapterTest.java Tue Aug 08 17:12:26 2017 +0200 +++ b/plugins/vm-heap-analysis/common/src/test/java/com/redhat/thermostat/vm/heap/analysis/common/internal/HeapInfoTypeAdapterTest.java Wed Aug 09 13:26:10 2017 -0400 @@ -41,6 +41,8 @@ import com.google.gson.reflect.TypeToken; import com.redhat.thermostat.vm.heap.analysis.common.model.HeapInfo; import org.junit.Test; + +import static com.redhat.thermostat.testutils.JsonUtils.assertJsonEquals; import static org.junit.Assert.assertEquals; import java.lang.reflect.Type; @@ -61,7 +63,7 @@ info.setHeapId("2432a"); info.setHistogramId("5675n"); infos.add(info); - assertEquals("[{\"agentId\":\"1\",\"vmId\":\"1\",\"timeStamp\":{\"$numberLong\":\"100\"},\"heapId\":\"2432a\",\"heapDumpId\":\"1234f\",\"histogramId\":\"5675n\"}]", gson.toJson(infos, list_type)); + assertJsonEquals("[{\"agentId\":\"1\",\"vmId\":\"1\",\"timeStamp\":{\"$numberLong\":\"100\"},\"heapId\":\"2432a\",\"heapDumpId\":\"1234f\",\"histogramId\":\"5675n\"}]", gson.toJson(infos, list_type)); } @Test diff -r bfd9802cd494 -r 4a55900090e4 plugins/vm-io/common/src/test/java/com/redhat/thermostat/vm/io/common/internal/VmIoStatTypeAdapterTest.java --- a/plugins/vm-io/common/src/test/java/com/redhat/thermostat/vm/io/common/internal/VmIoStatTypeAdapterTest.java Tue Aug 08 17:12:26 2017 +0200 +++ b/plugins/vm-io/common/src/test/java/com/redhat/thermostat/vm/io/common/internal/VmIoStatTypeAdapterTest.java Wed Aug 09 13:26:10 2017 -0400 @@ -40,7 +40,8 @@ import com.google.gson.Gson; import com.redhat.thermostat.vm.io.common.VmIoStat; import org.junit.Test; -import static org.junit.Assert.assertEquals; + +import static com.redhat.thermostat.testutils.JsonUtils.assertJsonEquals; public class VmIoStatTypeAdapterTest { @@ -57,7 +58,7 @@ stat.setCharactersWritten(1000l); stat.setReadSyscalls(30l); stat.setWriteSyscalls(40l); - assertEquals("{\"timeStamp\":{\"$numberLong\":\"100\"},\"vmId\":\"VM-1\",\"agentId\":\"AGENT-1\",\"charactersRead\":{\"$numberLong\":\"2000\"},\"charactersWritten\":{\"$numberLong\":\"1000\"},\"readSyscalls\":{\"$numberLong\":\"30\"},\"writeSyscalls\":{\"$numberLong\":\"40\"}}", gson.toJson(stat)); + assertJsonEquals("{\"timeStamp\":{\"$numberLong\":\"100\"},\"vmId\":\"VM-1\",\"agentId\":\"AGENT-1\",\"charactersRead\":{\"$numberLong\":\"2000\"},\"charactersWritten\":{\"$numberLong\":\"1000\"},\"readSyscalls\":{\"$numberLong\":\"30\"},\"writeSyscalls\":{\"$numberLong\":\"40\"}}", gson.toJson(stat)); } } diff -r bfd9802cd494 -r 4a55900090e4 plugins/vm-jmx/common/src/test/java/com/redhat/thermostat/vm/jmx/common/internal/JmxNotificationTypeAdapterTest.java --- a/plugins/vm-jmx/common/src/test/java/com/redhat/thermostat/vm/jmx/common/internal/JmxNotificationTypeAdapterTest.java Tue Aug 08 17:12:26 2017 +0200 +++ b/plugins/vm-jmx/common/src/test/java/com/redhat/thermostat/vm/jmx/common/internal/JmxNotificationTypeAdapterTest.java Wed Aug 09 13:26:10 2017 -0400 @@ -41,7 +41,7 @@ import com.redhat.thermostat.vm.jmx.common.JmxNotification; import org.junit.Test; -import static org.junit.Assert.assertEquals; +import static com.redhat.thermostat.testutils.JsonUtils.assertJsonEquals; public class JmxNotificationTypeAdapterTest { @@ -57,7 +57,7 @@ notification.setSourceDetails("Non existent details"); notification.setVmId("0"); notification.setAgentId("0"); - assertEquals("{\"timeStamp\":{\"$numberLong\":\"123456789\"},\"vmId\":\"0\",\"agentId\":\"0\",\"sourceBackend\":\"Non existent Backend\",\"sourceDetails\":\"Non existent details\",\"contents\":\"This is a notification\"}", gson.toJson(notification)); + assertJsonEquals("{\"timeStamp\":{\"$numberLong\":\"123456789\"},\"vmId\":\"0\",\"agentId\":\"0\",\"sourceBackend\":\"Non existent Backend\",\"sourceDetails\":\"Non existent details\",\"contents\":\"This is a notification\"}", gson.toJson(notification)); } } diff -r bfd9802cd494 -r 4a55900090e4 plugins/vm-memory/agent/src/test/java/com/redhat/thermostat/vm/memory/agent/internal/models/VmMemoryStatTypeAdapterTest.java --- a/plugins/vm-memory/agent/src/test/java/com/redhat/thermostat/vm/memory/agent/internal/models/VmMemoryStatTypeAdapterTest.java Tue Aug 08 17:12:26 2017 +0200 +++ b/plugins/vm-memory/agent/src/test/java/com/redhat/thermostat/vm/memory/agent/internal/models/VmMemoryStatTypeAdapterTest.java Wed Aug 09 13:26:10 2017 -0400 @@ -42,9 +42,9 @@ import java.io.IOException; import java.util.Arrays; +import static com.redhat.thermostat.testutils.JsonUtils.assertJsonEquals; import static com.redhat.thermostat.vm.memory.agent.model.VmMemoryStat.Generation; import static com.redhat.thermostat.vm.memory.agent.model.VmMemoryStat.Space; -import static org.junit.Assert.assertEquals; public class VmMemoryStatTypeAdapterTest { @@ -76,6 +76,6 @@ gen1.setSpaces(spaces); gens[0] = gen1; stat.setGenerations(gens); - assertEquals("[{\"agentId\":\"AGENT-1\",\"jvmId\":\"VM-1\",\"timeStamp\":{\"$numberLong\":\"100\"},\"metaspaceMaxCapacity\":{\"$numberLong\":\"4096\"},\"metaspaceMinCapacity\":{\"$numberLong\":\"2048\"},\"metaspaceCapacity\":{\"$numberLong\":\"2000\"},\"metaspaceUsed\":{\"$numberLong\":\"3000\"},\"generations\":[{\"name\":\"Name\",\"capacity\":{\"$numberLong\":\"1002\"},\"maxCapacity\":{\"$numberLong\":\"2048\"},\"collector\":\"Collector 1\",\"spaces\":[{\"index\":1,\"name\":\"Space Name\",\"capacity\":{\"$numberLong\":\"500\"},\"maxCapacity\":{\"$numberLong\":\"1024\"},\"used\":{\"$numberLong\":\"400\"}}]}]}]", typeAdapter.toJson(Arrays.asList(stat))); + assertJsonEquals("[{\"agentId\":\"AGENT-1\",\"jvmId\":\"VM-1\",\"timeStamp\":{\"$numberLong\":\"100\"},\"metaspaceMaxCapacity\":{\"$numberLong\":\"4096\"},\"metaspaceMinCapacity\":{\"$numberLong\":\"2048\"},\"metaspaceCapacity\":{\"$numberLong\":\"2000\"},\"metaspaceUsed\":{\"$numberLong\":\"3000\"},\"generations\":[{\"name\":\"Name\",\"capacity\":{\"$numberLong\":\"1002\"},\"maxCapacity\":{\"$numberLong\":\"2048\"},\"collector\":\"Collector 1\",\"spaces\":[{\"index\":1,\"name\":\"Space Name\",\"capacity\":{\"$numberLong\":\"500\"},\"maxCapacity\":{\"$numberLong\":\"1024\"},\"used\":{\"$numberLong\":\"400\"}}]}]}]", typeAdapter.toJson(Arrays.asList(stat))); } } \ No newline at end of file diff -r bfd9802cd494 -r 4a55900090e4 plugins/vm-memory/agent/src/test/java/com/redhat/thermostat/vm/memory/agent/internal/models/VmTlabStatTypeAdapterTest.java --- a/plugins/vm-memory/agent/src/test/java/com/redhat/thermostat/vm/memory/agent/internal/models/VmTlabStatTypeAdapterTest.java Tue Aug 08 17:12:26 2017 +0200 +++ b/plugins/vm-memory/agent/src/test/java/com/redhat/thermostat/vm/memory/agent/internal/models/VmTlabStatTypeAdapterTest.java Wed Aug 09 13:26:10 2017 -0400 @@ -42,7 +42,7 @@ import java.io.IOException; import java.util.Arrays; -import static org.junit.Assert.assertEquals; +import static com.redhat.thermostat.testutils.JsonUtils.assertJsonEquals; public class VmTlabStatTypeAdapterTest { @@ -65,7 +65,7 @@ stat.setMaxSlowWaste(634l); stat.setTotalFastWaste(678l); stat.setMaxFastWaste(333l); - assertEquals("[{\"vmId\":\"VM-1\",\"agentId\":\"AGENT-1\",\"timeStamp\":{\"$numberLong\":\"1000\"},\"allocThreads\":{\"$numberLong\":\"10\"},\"totalAllocations\":{\"$numberLong\":\"1342\"},\"refills\":{\"$numberLong\":\"58\"},\"maxRefills\":{\"$numberLong\":\"90\"},\"slowAllocations\":{\"$numberLong\":\"343\"},\"maxSlowAllocations\":{\"$numberLong\":\"989\"},\"gcWaste\":{\"$numberLong\":\"788\"},\"maxGcWaste\":{\"$numberLong\":\"992\"},\"slowWaste\":{\"$numberLong\":\"899\"},\"maxSlowWaste\":{\"$numberLong\":\"634\"},\"fastWaste\":{\"$numberLong\":\"678\"},\"maxFastWaste\":{\"$numberLong\":\"333\"}}]", typeAdapter.toJson(Arrays.asList(stat))); + assertJsonEquals("[{\"vmId\":\"VM-1\",\"agentId\":\"AGENT-1\",\"timeStamp\":{\"$numberLong\":\"1000\"},\"allocThreads\":{\"$numberLong\":\"10\"},\"totalAllocations\":{\"$numberLong\":\"1342\"},\"refills\":{\"$numberLong\":\"58\"},\"maxRefills\":{\"$numberLong\":\"90\"},\"slowAllocations\":{\"$numberLong\":\"343\"},\"maxSlowAllocations\":{\"$numberLong\":\"989\"},\"gcWaste\":{\"$numberLong\":\"788\"},\"maxGcWaste\":{\"$numberLong\":\"992\"},\"slowWaste\":{\"$numberLong\":\"899\"},\"maxSlowWaste\":{\"$numberLong\":\"634\"},\"fastWaste\":{\"$numberLong\":\"678\"},\"maxFastWaste\":{\"$numberLong\":\"333\"}}]", typeAdapter.toJson(Arrays.asList(stat))); } } diff -r bfd9802cd494 -r 4a55900090e4 plugins/vm-numa/common/src/test/java/com/redhat/thermostat/vm/numa/common/internal/VmNumaNodeStatTypeAdapterTest.java --- a/plugins/vm-numa/common/src/test/java/com/redhat/thermostat/vm/numa/common/internal/VmNumaNodeStatTypeAdapterTest.java Tue Aug 08 17:12:26 2017 +0200 +++ b/plugins/vm-numa/common/src/test/java/com/redhat/thermostat/vm/numa/common/internal/VmNumaNodeStatTypeAdapterTest.java Wed Aug 09 13:26:10 2017 -0400 @@ -40,7 +40,8 @@ import com.google.gson.Gson; import com.redhat.thermostat.vm.numa.common.VmNumaNodeStat; import org.junit.Test; -import static org.junit.Assert.assertEquals; + +import static com.redhat.thermostat.testutils.JsonUtils.assertJsonEquals; public class VmNumaNodeStatTypeAdapterTest { @@ -55,7 +56,7 @@ node.setHeapMemory(1234.55); node.setHugeMemory(2423.5555); node.setStackMemory(896.1545); - assertEquals("{\"node\":1,\"hugeMemory\":2423.5555,\"heapMemory\":1234.55,\"stackMemory\":896.1545,\"privateMemory\":234.5}", gson.toJson(node)); + assertJsonEquals("{\"node\":1,\"hugeMemory\":2423.5555,\"heapMemory\":1234.55,\"stackMemory\":896.1545,\"privateMemory\":234.5}", gson.toJson(node)); } } diff -r bfd9802cd494 -r 4a55900090e4 plugins/vm-numa/common/src/test/java/com/redhat/thermostat/vm/numa/common/internal/VmNumaStatTypeAdapterTest.java --- a/plugins/vm-numa/common/src/test/java/com/redhat/thermostat/vm/numa/common/internal/VmNumaStatTypeAdapterTest.java Tue Aug 08 17:12:26 2017 +0200 +++ b/plugins/vm-numa/common/src/test/java/com/redhat/thermostat/vm/numa/common/internal/VmNumaStatTypeAdapterTest.java Wed Aug 09 13:26:10 2017 -0400 @@ -42,7 +42,7 @@ import com.redhat.thermostat.vm.numa.common.VmNumaStat; import org.junit.Test; -import static org.junit.Assert.assertEquals; +import static com.redhat.thermostat.testutils.JsonUtils.assertJsonEquals; public class VmNumaStatTypeAdapterTest { @@ -68,7 +68,7 @@ stat.setVmId("VM-1"); stat.setAgentId("AGENT-1"); stat.setVmNodeStats(new VmNumaNodeStat[]{node, node2}); - assertEquals("{\"vmId\":\"VM-1\",\"agentId\":\"AGENT-1\",\"vmNodeStats\":[{\"node\":2,\"hugeMemory\":52423.5555,\"heapMemory\":31234.55,\"stackMemory\":4896.1545,\"privateMemory\":1234.5},{\"node\":0,\"hugeMemory\":0.0,\"heapMemory\":0.0,\"stackMemory\":0.0,\"privateMemory\":0.0}],\"timeStamp\":{\"$numberLong\":\"100\"}}", gson.toJson(stat)); + assertJsonEquals("{\"vmId\":\"VM-1\",\"agentId\":\"AGENT-1\",\"vmNodeStats\":[{\"node\":2,\"hugeMemory\":52423.5555,\"heapMemory\":31234.55,\"stackMemory\":4896.1545,\"privateMemory\":1234.5},{\"node\":0,\"hugeMemory\":0.0,\"heapMemory\":0.0,\"stackMemory\":0.0,\"privateMemory\":0.0}],\"timeStamp\":{\"$numberLong\":\"100\"}}", gson.toJson(stat)); } } diff -r bfd9802cd494 -r 4a55900090e4 plugins/vm-profiler/common/src/test/java/com/redhat/thermostat/vm/profiler/common/internal/ProfileInfoTypeAdapterTest.java --- a/plugins/vm-profiler/common/src/test/java/com/redhat/thermostat/vm/profiler/common/internal/ProfileInfoTypeAdapterTest.java Tue Aug 08 17:12:26 2017 +0200 +++ b/plugins/vm-profiler/common/src/test/java/com/redhat/thermostat/vm/profiler/common/internal/ProfileInfoTypeAdapterTest.java Wed Aug 09 13:26:10 2017 -0400 @@ -41,7 +41,7 @@ import com.redhat.thermostat.vm.profiler.common.ProfileInfo; import org.junit.Test; -import static org.junit.Assert.assertEquals; +import static com.redhat.thermostat.testutils.JsonUtils.assertJsonEquals; public class ProfileInfoTypeAdapterTest { @@ -56,7 +56,7 @@ testInfo.setProfileId("3"); testInfo.setStartTimeStamp(100l); testInfo.setStopTimeStamp(200l); - assertEquals("{\"vmId\":\"2\",\"profileId\":\"3\",\"startTimeStamp\":{\"$numberLong\":\"100\"},\"stopTimeStamp\":{\"$numberLong\":\"200\"},\"agentId\":\"1\"}", + assertJsonEquals("{\"vmId\":\"2\",\"profileId\":\"3\",\"startTimeStamp\":{\"$numberLong\":\"100\"},\"stopTimeStamp\":{\"$numberLong\":\"200\"},\"agentId\":\"1\"}", gson.toJson(testInfo)); } } diff -r bfd9802cd494 -r 4a55900090e4 plugins/vm-profiler/common/src/test/java/com/redhat/thermostat/vm/profiler/common/internal/ProfileStatusChangeTypeAdapterTest.java --- a/plugins/vm-profiler/common/src/test/java/com/redhat/thermostat/vm/profiler/common/internal/ProfileStatusChangeTypeAdapterTest.java Tue Aug 08 17:12:26 2017 +0200 +++ b/plugins/vm-profiler/common/src/test/java/com/redhat/thermostat/vm/profiler/common/internal/ProfileStatusChangeTypeAdapterTest.java Wed Aug 09 13:26:10 2017 -0400 @@ -41,7 +41,7 @@ import com.redhat.thermostat.vm.profiler.common.ProfileStatusChange; import org.junit.Test; -import static org.junit.Assert.assertEquals; +import static com.redhat.thermostat.testutils.JsonUtils.assertJsonEquals; public class ProfileStatusChangeTypeAdapterTest { @@ -55,7 +55,7 @@ change.setVmId("1"); change.setAgentId("2"); change.setStarted(true); - assertEquals("{\"vmId\":\"1\",\"timeStamp\":{\"$numberLong\":\"100\"},\"started\":true,\"agentId\":\"2\"}", gson.toJson(change)); + assertJsonEquals("{\"vmId\":\"1\",\"timeStamp\":{\"$numberLong\":\"100\"},\"started\":true,\"agentId\":\"2\"}", gson.toJson(change)); } }