Package org.happyfaces.beans.base

Examples of org.happyfaces.beans.base.BaseBean


public class BaseBeanTest {

    @SuppressWarnings("rawtypes")
    @Test
    public void testInitEntity() {
        BaseBean backingBean = new BaseBean<TestEntity>(TestEntity.class) {
            private static final long serialVersionUID = 1L;
            @Override
            protected IService<TestEntity> getPersistenceService() {
                return new DummyPersistenceService();
            }
        };
       
        // test new instance of TestEntity is created when objectId is not set.
        IEntity initEntity = backingBean.initEntity();
        Assert.assertNotNull(initEntity);
        Assert.assertTrue(initEntity instanceof TestEntity);
        Assert.assertNull(initEntity.getId());
        backingBean.setObjectId(22L);
       
        //
        initEntity = backingBean.initEntity();
        Assert.assertNotNull(initEntity);
        Assert.assertTrue(initEntity instanceof TestEntity);
        Assert.assertEquals(Long.valueOf(22L), initEntity.getId());
       
        // not exist
        backingBean.setObjectId(23L);
        initEntity = backingBean.initEntity();
        Assert.assertNull(initEntity);
    }
View Full Code Here

TOP

Related Classes of org.happyfaces.beans.base.BaseBean

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.