@Test public void testGetPropertyNameOfBridgeMethod() throws NoSuchMethodException, SecurityException { Method bridgeSetter = GenericObject.class.getMethod("setT", Object.class); assertNull(BeanJsonConverter.getPropertyName(bridgeSetter)); Method realSetter = GenericObject.class.getMethod("setT", String.class);; assertEquals("t", BeanJsonConverter.getPropertyName(realSetter)); } }
@Test public void testGetPropertyNameOfBridgeMethod() throws NoSuchMethodException, SecurityException { Method bridgeSetter = GenericObject.class.getMethod("setT", Object.class); assertNull(BeanJsonConverter.getPropertyName(bridgeSetter)); Method realSetter = GenericObject.class.getMethod("setT", String.class);; assertEquals("t", BeanJsonConverter.getPropertyName(realSetter)); } }
@Test public void testGetPropertyNameOfBridgeMethod() throws NoSuchMethodException, SecurityException { Method bridgeSetter = GenericObject.class.getMethod("setT", Object.class); assertNull(BeanJsonConverter.getPropertyName(bridgeSetter)); Method realSetter = GenericObject.class.getMethod("setT", String.class);; assertEquals("t", BeanJsonConverter.getPropertyName(realSetter)); } }
@Test public void testJsonToObject() throws Exception { String json = '{' + "hello:'world'," + "count:10," + "someStatic:'foo'," + "testEnum:'bar'," + "children:[{hello:'world-2',count:11},{hello:'world-3',count:12}]}"; TestObject object = beanJsonConverter.convertToObject(json, TestObject.class); assertEquals("world", object.hello); assertEquals(10, object.count); assertEquals("world-2", object.children.get(0).hello); assertEquals(11, object.children.get(0).count); assertEquals("world-3", object.children.get(1).hello); assertEquals(12, object.children.get(1).count); assertNull("Should not set static values", TestObject.staticValue); assertEquals(TestObject.TestEnum.bar, object.testEnum); }
@Test public void testJsonToObject() throws Exception { String json = '{' + "hello:'world'," + "count:10," + "someStatic:'foo'," + "testEnum:'bar'," + "children:[{hello:'world-2',count:11},{hello:'world-3',count:12}]}"; TestObject object = beanJsonConverter.convertToObject(json, TestObject.class); assertEquals("world", object.hello); assertEquals(10, object.count); assertEquals("world-2", object.children.get(0).hello); assertEquals(11, object.children.get(0).count); assertEquals("world-3", object.children.get(1).hello); assertEquals(12, object.children.get(1).count); assertNull("Should not set static values", TestObject.staticValue); assertEquals(TestObject.TestEnum.bar, object.testEnum); }
@Test public void testJsonToObject() throws Exception { String json = '{' + "hello:'world'," + "count:10," + "someStatic:'foo'," + "testEnum:'bar'," + "children:[{hello:'world-2',count:11},{hello:'world-3',count:12}]}"; TestObject object = beanJsonConverter.convertToObject(json, TestObject.class); assertEquals("world", object.hello); assertEquals(10, object.count); assertEquals("world-2", object.children.get(0).hello); assertEquals(11, object.children.get(0).count); assertEquals("world-3", object.children.get(1).hello); assertEquals(12, object.children.get(1).count); assertNull("Should not set static values", TestObject.staticValue); assertEquals(TestObject.TestEnum.bar, object.testEnum); }
@Test public void testJsonToObject() throws Exception { String json = '{' + "hello:'world'," + "count:10," + "someStatic:'foo'," + "testEnum:'bar'," + "children:[{hello:'world-2',count:11},{hello:'world-3',count:12}]}"; TestObject object = beanJsonConverter.convertToObject(json, TestObject.class); assertEquals("world", object.hello); assertEquals(10, object.count); assertEquals("world-2", object.children.get(0).hello); assertEquals(11, object.children.get(0).count); assertEquals("world-3", object.children.get(1).hello); assertEquals(12, object.children.get(1).count); assertNull("Should not set static values", TestObject.staticValue); assertEquals(TestObject.TestEnum.bar, object.testEnum); }
@Test public void testJsonToObject() throws Exception { String json = '{' + "hello:'world'," + "count:10," + "someStatic:'foo'," + "testEnum:'bar'," + "children:[{hello:'world-2',count:11},{hello:'world-3',count:12}]}"; TestObject object = beanJsonConverter.convertToObject(json, TestObject.class); assertEquals("world", object.hello); assertEquals(10, object.count); assertEquals("world-2", object.children.get(0).hello); assertEquals(11, object.children.get(0).count); assertEquals("world-3", object.children.get(1).hello); assertEquals(12, object.children.get(1).count); assertNull("Should not set static values", TestObject.staticValue); assertEquals(TestObject.TestEnum.bar, object.testEnum); }