@Test public void shouldShallowCopyFieldValuesIntoMock() throws Exception { // given from.defaultField = "foo"; from.instancePublicField = new SomeOtherObject(); from.privateField = 1; from.privateTransientField = 2; from.protectedField = 3; assertNotEquals(from.defaultField, to.defaultField); assertNotEquals(from.instancePublicField, to.instancePublicField); assertNotEquals(from.privateField, to.privateField); assertNotEquals(from.privateTransientField, to.privateTransientField); assertNotEquals(from.protectedField, to.protectedField); // when tool.copyToMock(from, to); // then assertEquals(from.defaultField, to.defaultField); assertEquals(from.instancePublicField, to.instancePublicField); assertEquals(from.privateField, to.privateField); assertEquals(from.privateTransientField, to.privateTransientField); assertEquals(from.protectedField, to.protectedField); }
public void testSomeObject() { SomeObject so = new SomeObject("nene"); so.toString(); Object outcome = ObjectMapConverter.convert(so); System.out.println(outcome); // assertTrue(!SomeOtherObject.class.equals(outcome.get("soo").getClass())); }
@GET @Produces("text/plain") public String getInstance() { assertEquals("test/singleton-scope", ui.getPath()); assertEquals("singleton", param); return someObject.toString(); }
@Test public void shouldShallowCopyTransientPrivateFields() throws Exception { // given from.privateTransientField = 1000; assertNotEquals(1000, to.privateTransientField); // when tool.copyToMock(from, to); // then assertEquals(1000, to.privateTransientField); }
@Test public void shouldBeAbleToCopyFromRealObjectToRealObject() throws Exception { // given from.defaultField = "defaultField"; from.instancePublicField = new SomeOtherObject(); from.privateField = 1; from.privateTransientField = 2; from.protectedField = "protectedField"; from.protectedInherited = "protectedInherited"; to = new SomeObject(0); // when tool.copyToRealObject(from, to); // then assertEquals(from.defaultField, to.defaultField); assertEquals(from.instancePublicField, to.instancePublicField); assertEquals(from.privateField, to.privateField); assertEquals(from.privateTransientField, to.privateTransientField); assertEquals(from.protectedField, to.protectedField); assertEquals(from.protectedInherited, to.protectedInherited); }