So I did not mock HazelcastInstance because my code needs the data from the cache in order to test their functionality. If I mock HazelcastInstance, I will not be able to mock getMap() method which returns the cached data. In case I do mock it, I cannot make it return a dummy object because IMap<> cannot be initialized as far I know. So this is not possible in kotlin code
myDummyMap : IMap<Object, Object> = (instance of IMap) when(instance.getmap).thenReturn(myDummyMap)
Now the problem is that after unit test, instances of hazel persist and not only that but join the main application cluster
You can easily mock the IMap instead of mocking an HZ instance. This is much easier than starting an HZ instance for unit testing.