### Question:
CloneHelper { public static boolean needsCloning(Object object) { if (object == null) { return false; } if (object instanceof Message) { return needsCloning((Message) object); } return !isObjectConsideredImmutable(object); }  static boolean needsCloning(Object object);  }### Answer:
@Test public void testImmutableClasses() throws Exception { assertFalse(CloneHelper.needsCloning("string")); assertFalse(CloneHelper.needsCloning(1337L)); assertFalse(CloneHelper.needsCloning(new ImmutableClass("huuhaa"))); }
@Test public void testMutableClasses() throws Exception { assertTrue(CloneHelper.needsCloning(new MutableClass())); assertFalse(CloneHelper.needsCloning(ImmutableEnum.TEST)); assertFalse(CloneHelper.needsCloning(null)); }
@Test public void testMessageWithObjectArrayPayload() throws Exception { assertFalse(CloneHelper.needsCloning(new Message().withPayload(new Object[]{ 1337L, "string" }))); assertTrue(CloneHelper.needsCloning(new Message().withPayload(new Object[]{ new ImmutableClass("huuhaa"), new MutableClass() }))); assertFalse(CloneHelper.needsCloning(new Message().withPayload(new Object[]{ new ImmutableClass("huuhaa"), new ImmutableClass("huuhaa") }))); assertFalse(CloneHelper.needsCloning(new Message().withPayload(new Object[]{ CloneHelperTest.ImmutableEnum.TEST }))); }