Package stubs.cglib

Examples of stubs.cglib.SimpleEntity


        SimpleCollectionEntity col = new SimpleCollectionEntity();
        SimpleCollectionEntity col2 = new SimpleCollectionEntity();
        Collection<SimpleCollectionEntity> cols = new ArrayList<SimpleCollectionEntity>();
        cols.add(col);
        cols.add(col2);
        SimpleEntity e = new SimpleEntity();
        col.setSimpleEntity(e);
        col2.setSimpleEntity(e);
        sub.setEntity(new ArrayList<SimpleEntity>());
        sub.getEntity().add(e);
        e.setName("a name");
        e.setSimpleCollection(cols);
        e.setCglibEntity(sub);
        entityManager.persist(e);
        pk = e.getId();
        entityManager.getTransaction().commit();
        entityManager.close();
    }
View Full Code Here


    }

    @Test
    public void testCopyProperties() {
        assertNull("Null is cloned as null", BeanUtils.copyProperties(null));
        SimpleEntity e = entityManager.find(SimpleEntity.class, pk);
        SimpleEntity target = new SimpleEntity();
        BeanUtils.copyProperties(e, target);
        assertEquals("String copied", "a name", target.getName());
        assertNull("Non initialized object is not copied", target.getCglibEntity());
        assertNull("Non initialized collection is not copied", target.getSimpleCollection());
        SimpleInnerEntity inner = BeanUtils.copyProperties(e.getCglibEntity());
        assertNull("Non initialized CGLIB object is not cloned", inner);
        e.getSimpleCollection().size();
        e.getCglibEntity().getName();
        target = new SimpleEntity();
        BeanUtils.copyProperties(e, target);
        assertTrue("Initialized collection is copied", target.getSimpleCollection().size() == 2);
        assertNotNull("Initialized object is copied", target.getCglibEntity().getId());
        assertEquals("Initialized object is copied", "simple inner entity", target.getCglibEntity().getName());
        inner = BeanUtils.copyProperties(e.getCglibEntity());
        assertEquals("CGLIB objects are copied", "simple inner entity", inner.getName());
        target = new SimpleEntity();
        BeanUtils.copyProperties(e, target, Arrays.asList("name"));
        assertNull("Properties are ignored", target.getName());
    }
View Full Code Here

TOP

Related Classes of stubs.cglib.SimpleEntity

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.