/** * Test method for * {@link com.impetus.kundera.property.accessor.BooleanAccessor#getCopy(java.lang.Object)} * . */ @Test public void testGetCopy() { Assert.assertNull(accessor.getCopy(null)); Assert.assertTrue(accessor.getCopy(new Boolean(true))); Assert.assertFalse(accessor.getCopy(new Boolean(false))); }
/** * Test method for * {@link com.impetus.kundera.property.accessor.CalendarAccessor#getCopy(java.lang.Object)} * . */ @Test public void testGetCopy() { Assert.assertNull(accessor.getCopy(null)); Calendar v1 = Calendar.getInstance(); Calendar v2 = accessor.getCopy(v1); Assert.assertEquals(v1, v2); }
/** * Test method for {@link com.impetus.kundera.property.accessor.BigIntegerAccessor#getCopy(java.lang.Object)}. */ @Test public void testGetCopy() { Assert.assertNull(accessor.getCopy(null)); BigInteger v1 = new BigInteger("1111111111"); BigInteger v2 = accessor.getCopy(v1); Assert.assertEquals(v1, v2); }
/** * Test method for {@link com.impetus.kundera.property.accessor.BigDecimalAccessor#getCopy(java.lang.Object)}. */ @Test public void testGetCopy() { Assert.assertNull(accessor.getCopy(null)); BigDecimal v1 = new BigDecimal(1111111111); BigDecimal v2 = accessor.getCopy(v1); Assert.assertEquals(v1, v2); }
/** * Test method for {@link com.impetus.kundera.property.accessor.DoubleAccessor#getCopy(java.lang.Object)}. */ @Test public void testGetCopy() { Double d1 = new Double(4.555); Double d2 = accessor.getCopy(d1); Assert.assertEquals(d1, d2); }
/** * Test method for {@link com.impetus.kundera.property.accessor.SQLTimestampAccessor#getCopy(java.lang.Object)}. */ @Test public void testGetCopy() { Assert.assertNull(accessor.getCopy(null)); long currTime = System.currentTimeMillis(); Timestamp t1 = new Timestamp(currTime); Timestamp t2 = accessor.getCopy(t1); Assert.assertNotNull(t2); Assert.assertEquals(currTime, t2.getTime()); }
/** * Test method for {@link com.impetus.kundera.property.accessor.StringAccessor#getCopy(java.lang.Object)}. */ @Test public void testGetCopy() { String d1 = new String("AAA"); String d2 = accessor.getCopy(d1); Assert.assertEquals(d1, d2); }
/** * Retutrns copy of object * * @param from * @param field * @return */ public static Object getObjectCopy(Object from, Field field) { if (!field.isAccessible()) { field.setAccessible(true); } try { PropertyAccessor<?> accessor = PropertyAccessorFactory.getPropertyAccessor(field); return accessor.getCopy(field.get(from)); } catch (IllegalArgumentException iarg) { throw new PropertyAccessException(iarg); } catch (IllegalAccessException iacc) { throw new PropertyAccessException(iacc); } }
/** * Test method for {@link com.impetus.kundera.property.accessor.FloatAccessor#getCopy(java.lang.Object)}. */ @Test public void testGetCopy() { Float f1 = new Float(4.555); Float f2 = accessor.getCopy(f1); Assert.assertEquals(f1, f2); }
/** * Test method for {@link com.impetus.kundera.property.accessor.UUIDAccessor#getCopy(java.lang.Object)}. */ @Test public void testGetCopy() { UUID uuid = UUID.randomUUID(); UUID uuid2 = accessor.getCopy(uuid); Assert.assertEquals(uuid, uuid2); }
@Test public void testGetCopy() { Long d1 = new Long(4); Long d2 = accessor.getCopy(d1); Assert.assertEquals(d1, d2); }
/** * Test method for {@link com.impetus.kundera.property.accessor.IntegerAccessor#getCopy(java.lang.Object)}. */ @Test public void testGetCopy() { Integer d1 = new Integer(4); Integer d2 = accessor.getCopy(d1); Assert.assertEquals(d1, d2); }
/** * Test method for {@link com.impetus.kundera.property.accessor.SQLDateAccessor#getCopy(java.lang.Object)}. */ @Test public void testGetCopy() { long l = System.currentTimeMillis(); Date d = new Date(l); Date d2 = accessor.getCopy(d); Assert.assertNotNull(d2); Assert.assertTrue(d.equals(d2)); }
/** * Test method for * {@link com.impetus.kundera.property.accessor.SQLTimeAccessor#getCopy(java.lang.Object)} * . */ @Test public void testGetCopy() { long l = System.currentTimeMillis(); Time d = new Time(l); Time d2 = accessor.getCopy(d); Assert.assertNotNull(d2); Assert.assertTrue(d.equals(d2)); }
/** * Test method for {@link com.impetus.kundera.property.accessor.ObjectAccessor#getCopy(java.lang.Object)}. */ @Test public void testGetCopy() { Assert.assertNull(accessor.getCopy(null)); PersonalDetail pd = new PersonalDetail("Amresh", "password", "single"); Object pdCopy = accessor.getCopy(pd); Assert.assertNotNull(pdCopy); Assert.assertTrue(pdCopy instanceof PersonalDetail); Assert.assertTrue(pd == pdCopy); Assert.assertTrue(pd.getPersonalDetailId() == ((PersonalDetail)pdCopy).getPersonalDetailId()); Assert.assertTrue(pd.getName() == ((PersonalDetail)pdCopy).getName()); Assert.assertTrue(pd.getPassword() == ((PersonalDetail)pdCopy).getPassword()); Assert.assertTrue(pd.getRelationshipStatus() == ((PersonalDetail)pdCopy).getRelationshipStatus()); byte[] b = "Hello".getBytes(); Object bCopy = accessor.getCopy(b); Assert.assertNotNull(bCopy); Assert.assertTrue(bCopy instanceof byte[]); }