⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 testworktypeservice.java

📁 一个很好的开源项目管理系统源代码
💻 JAVA
字号:
package net.java.workeffort.service;import java.util.ArrayList;import java.util.List;import junit.framework.Test;import junit.framework.TestSuite;import net.java.workeffort.data.DataFileUtil;import net.java.workeffort.params.WorkTypeParams;import net.java.workeffort.service.domain.FixedAssetStandard;import net.java.workeffort.service.domain.PageResult;import net.java.workeffort.service.domain.PartStandard;import net.java.workeffort.service.domain.SkillStandard;import net.java.workeffort.service.domain.WorkType;import net.java.workeffort.service.domain.WorkTypeQuery;import net.java.workeffort.service.support.OptimisticLockingException;/** * Test for Work Type service. * @author Antony Joseph */public class TestWorkTypeService extends BaseServiceTestCase {    private IWorkTypeService service;    private WorkTypeParams params;    public static Test suite() {        TestSuite suite = new TestSuite();        suite.addTestSuite(TestWorkTypeService.class);        List list = new ArrayList();        list.add(DataFileUtil.WORK_TYPE);        return new ServiceTestSetup(suite, list);    }    protected void setUp() throws Exception {        super.setUp();        service = (IWorkTypeService) ServiceTestSetup.getApplicationContext()                .getBean("workTypeService");        params = new WorkTypeParams();    }    public void testWorkTypePageResult() throws Exception {        WorkTypeQuery query = params.testGetPageResultWorkType();        PageResult result = service.getPageResultWorkType(query);        assertNotNull("Should not return null object", result.getRows());        assertEquals("Should return 1 row", 1, result.getRows().size());    }    public void testGetWorkType() throws Exception {        String pk = params.testGetWorkType();        WorkType result = service.getWorkType(pk);        assertNotNull("Should not return null object", result);    }    public void testInsertWorkType() throws Exception {        WorkType input = params.testInsertWorkType();        service.insertWorkType(input);        assertEquals("version should be set to 1.", new Integer(1), input                .getVersion());    }    public void testUpdateWorkType() throws Exception {        WorkType input = params.testUpdateWorkType();        service.updateWorkType(input);        assertEquals("version should be incremented to 2.", new Integer(2),                input.getVersion());    }    public void testDeleteWorkType() throws Exception {        WorkType input = params.testDeleteWorkType();        service.deleteWorkType(input);        WorkType result = service.getWorkType(input.getWorkTypeCd());        assertNull("Should return null object", result);    }    public void testUpdateWorkTypeOptLck() throws Exception {        WorkType input = params.testUpdateWorkTypeOptLck();        try {            service.updateWorkType(input);            fail("An OptimisticLockingException should be raised");        }        catch (OptimisticLockingException expected) {            assertTrue(true);        }    }    //=================== Fixed asset standard ==============================    public void testGetWorkTypeWithFixedAssetStd() throws Exception {        String pk = params.testGetWorkTypeWithFixedAssetStd();        WorkType result = service.getWorkTypeWithFixedAssetStd(pk);        assertNotNull("Should not return null object", result);        if (result.getFixedAssetStandards().size() == 0) {            fail("property 'fixedAssetStandards' should be an list with size > 0");        }    }    public void testSaveWorkTypeWithFixedAssetStdInsert() throws Exception {        WorkType input = params.testSaveWorkTypeWithFixedAssetStdInsert();        service.saveWorkTypeWithFixedAssetStd(input);        WorkType result = service.getWorkTypeWithFixedAssetStd(input                .getWorkTypeCd());        assertNotNull("Should not return null object", result);        if (result.getFixedAssetStandards().size() == 0) {            fail("property 'fixedAssetStandards' should be an list with size > 0");        }    }    public void testSaveWorkTypeWithFixedAssetStdUpdate() throws Exception {        WorkType input = params.testSaveWorkTypeWithFixedAssetStdUpdate();        service.saveWorkTypeWithFixedAssetStd(input);        WorkType result = service.getWorkTypeWithFixedAssetStd(input                .getWorkTypeCd());        assertNotNull("Should not return null object", result);        FixedAssetStandard row = (FixedAssetStandard) result                .getFixedAssetStandards().get(0);        assertEquals("version should be incremented to 2.", new Integer(2), row                .getVersion());    }    public void testSaveWorkTypeWithFixedAssetStdDelete() throws Exception {        WorkType input = params.testSaveWorkTypeWithFixedAssetStdDelete();        service.saveWorkTypeWithFixedAssetStd(input);        WorkType result = service.getWorkTypeWithFixedAssetStd(input                .getWorkTypeCd());        if (result.getFixedAssetStandards().size() > 0) {            fail("property 'fixedAssetStandards' should be an list with size 0");        }    }    //=========================Part standard============================    public void testGetWorkTypeWithPartStd() throws Exception {        String pk = params.testGetWorkTypeWithPartStd();        WorkType result = service.getWorkTypeWithPartStd(pk);        assertNotNull("Should not return null object", result);        if (result.getPartStandards().size() == 0) {            fail("property 'partStandards' should be an list with size > 0");        }    }    public void testSaveWorkTypeWithPartStdInsert() throws Exception {        WorkType input = params.testSaveWorkTypeWithPartStdInsert();        service.saveWorkTypeWithPartStd(input);        WorkType result = service.getWorkTypeWithPartStd(input.getWorkTypeCd());        assertNotNull("Should not return null object", result);        if (result.getPartStandards().size() == 0) {            fail("property 'partStandards' should be an list with size > 0");        }    }    public void testSaveWorkTypeWithPartStdUpdate() throws Exception {        WorkType input = params.testSaveWorkTypeWithPartStdUpdate();        service.saveWorkTypeWithPartStd(input);        WorkType result = service.getWorkTypeWithPartStd(input.getWorkTypeCd());        assertNotNull("Should not return null object", result);        PartStandard row = (PartStandard) result.getPartStandards().get(0);        assertEquals("version should be incremented to 2.", new Integer(2), row                .getVersion());    }    public void testSaveWorkTypeWithPartStdDelete() throws Exception {        WorkType input = params.testSaveWorkTypeWithPartStdDelete();        service.saveWorkTypeWithPartStd(input);        WorkType result = service.getWorkTypeWithPartStd(input.getWorkTypeCd());        if (result.getPartStandards().size() > 0) {            fail("property 'partStandards' should be an list with size 0");        }    }    // =========================Skill standard============================    public void testGetWorkTypeWithSkillStd() throws Exception {        String pk = params.testGetWorkTypeWithSkillStd();        WorkType result = service.getWorkTypeWithSkillStd(pk);        assertNotNull("Should not return null object", result);        if (result.getSkillStandards().size() == 0) {            fail("property 'skillStandards' should be an list with size > 0");        }    }    public void testSaveWorkTypeWithSkillStdInsert() throws Exception {        WorkType input = params.testSaveWorkTypeWithSkillStdInsert();        service.saveWorkTypeWithSkillStd(input);        WorkType result = service                .getWorkTypeWithSkillStd(input.getWorkTypeCd());        assertNotNull("Should not return null object", result);        if (result.getSkillStandards().size() == 0) {            fail("property 'skillStandards' should be an list with size > 0");        }    }    public void testSaveWorkTypeWithSkillStdUpdate() throws Exception {        WorkType input = params.testSaveWorkTypeWithSkillStdUpdate();        service.saveWorkTypeWithSkillStd(input);        WorkType result = service                .getWorkTypeWithSkillStd(input.getWorkTypeCd());        assertNotNull("Should not return null object", result);        SkillStandard row = (SkillStandard) result.getSkillStandards().get(0);        assertEquals("version should be incremented to 2.", new Integer(2), row                .getVersion());    }    public void testSaveWorkTypeWithSkillStdDelete() throws Exception {        WorkType input = params.testSaveWorkTypeWithSkillStdDelete();        service.saveWorkTypeWithSkillStd(input);        WorkType result = service                .getWorkTypeWithSkillStd(input.getWorkTypeCd());        if (result.getSkillStandards().size() > 0) {            fail("property 'skillStandards' should be an list with size 0");        }    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -