package com.hazelcast.management;

import com.hazelcast.core.HazelcastInstance;
import com.hazelcast.instance.HazelcastInstanceImpl;
import com.hazelcast.instance.TestUtil;
import com.hazelcast.monitor.TimedMemberState;
import com.hazelcast.nio.serialization.Data;
import com.hazelcast.nio.serialization.SerializationService;
import com.hazelcast.test.HazelcastParallelClassRunner;
import com.hazelcast.test.HazelcastTestSupport;
import com.hazelcast.test.annotation.QuickTest;
import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.junit.runner.RunWith;

import static com.hazelcast.instance.TestUtil.getHazelcastInstanceImpl;
import static org.junit.Assert.assertNotNull;

@RunWith(HazelcastParallelClassRunner.class)
@Category(QuickTest.class)
public class TimedMemberStateTest extends HazelcastTestSupport {

    @Test
    public void testSerialization() throws InterruptedException {
        HazelcastInstance hz = createHazelcastInstance();
        SerializationService serializationService = getNode(hz).getSerializationService();
        TimedMemberStateFactory timedMemberStateFactory = new TimedMemberStateFactory(getHazelcastInstanceImpl(hz));

        TimedMemberState state = timedMemberStateFactory.createTimedMemberState();

        Data data = serializationService.toData(state);
        TimedMemberState result = serializationService.toObject(data);
        assertNotNull(result);
    }
}

@@ -43,40 +43,37 @@
 com.
-hazelcast.core.HazelcastInstance
+eclipsesource.json.JsonObject
 ;%0Aim
@@ -91,23 +91,19 @@
 zelcast.
-instanc
+cor
 e.Hazelc
@@ -117,52 +117,8 @@
 ance
-Impl;%0Aimport com.hazelcast.instance.TestUtil
 ;%0Aim
@@ -166,114 +166,8 @@
 te;%0A
-import com.hazelcast.nio.serialization.Data;%0Aimport com.hazelcast.nio.serialization.SerializationService;%0A
 impo
@@ -494,16 +494,61 @@
 ceImpl;%0A
+import static org.junit.Assert.assertEquals;%0A
 import s
@@ -862,99 +862,8 @@
 ();%0A
-        SerializationService serializationService = getNode(hz).getSerializationService();%0A
     
@@ -1063,164 +1063,564 @@
 ();%0A
-%0A        Data data = serializationService.toData(state);%0A        TimedMemberState result = serializationService.toObject(data);%0A        assertNotNull(result
+        JsonObject json = state.toJson();%0A%0A        TimedMemberState deserialized = new TimedMemberState();%0A        deserialized.fromJson(json);%0A%0A        assertNotNull(deserialized);%0A        assertEquals(state.getMemberList(), deserialized.getMemberList());%0A        assertEquals(state.getClusterName(), deserialized.getClusterName());%0A        assertEquals(state.getInstanceNames(), deserialized.getInstanceNames());%0A        assertEquals(state.getMaster(), deserialized.getMaster());%0A        assertEquals(state.getMemberState(), deserialized.getMemberState()
 );%0A 

change TimedMemberStateTest to use json serialization