private void testValidCopy(TestObject src, TestObject dest) { src.setName("freddie"); src.setAge(15); src.setSpouse(new TestObject()); assertFalse(src.getAge() == dest.getAge()); ReflectionUtils.shallowCopyFieldState(src, dest); assertEquals(src.getAge(), dest.getAge()); assertEquals(src.getSpouse(), dest.getSpouse()); }
@Test(expected = IllegalArgumentException.class) public void rejectsNullDest() { TestObject src = new TestObject(); String dest = null; ReflectionUtils.shallowCopyFieldState(src, dest); }
@Test(expected = IllegalArgumentException.class) public void copySrcToDestinationOfIncorrectClass() { TestObject src = new TestObject(); String dest = new String(); ReflectionUtils.shallowCopyFieldState(src, dest); }