Package org.springmodules.prevayler.test.domain

Examples of org.springmodules.prevayler.test.domain.OfficeImpl


        assertSame(emp1, empA);
        assertSame(empA, empB);
    }
   
    public void testSaveEntityClassNotConfigured() {
        OfficeImpl o1 = new OfficeImpl("o1", "Office 1");
       
        try {
            // Save an object whose class is not configured as prevalent:
            this.prevalentSystem.save(o1);
            fail("Save must fail!");
View Full Code Here


    }
   
    public void testObjectReferenceIntegrity() {
        // Create an employee, assign it an office and save:
        EmployeeImpl emp1 = new EmployeeImpl("a1");
        OfficeImpl o1 = new OfficeImpl("o1", "Office 1");
        emp1.setOffice(o1);
        this.template.save(emp1);
        // Verify:
        o1 = (OfficeImpl) emp1.getOffice();
        assertNotNull(emp1.getId());
        assertNotNull(o1.getId());
       
        // Change the office name and DIRECTLY update it:
        o1.setName("New name");
        this.template.update(o1);
       
        // If we directly get the office, we see its name has been changed:
        o1 = (OfficeImpl) this.template.get(Office.class, o1.getId());
        assertEquals("New name", o1.getName());
       
        // If we get the office from the employee, the name is changed too:
        emp1 = (EmployeeImpl) this.template.get(Employee.class, emp1.getId());
        OfficeImpl o2 = (OfficeImpl) emp1.getOffice();
        assertNotNull("Value: " + o2.getName(), o2.getName());
        // What's most important, the office directly retrieved from the template,
        // and the one retrieved from the employee, are the same:
        assertSame(o1, o2);
    }
View Full Code Here

        info.setIdResolutionStrategy(new DefaultIdResolver());
        this.merger = new DefaultIdMerger(info);
    }

    public void testMergeObjects() throws Exception {
        OfficeImpl o1 = new OfficeImpl("o1", "Office 1");
        ManagerImpl m1 = new ManagerImpl("m1");
        EmployeeImpl e1 = new EmployeeImpl("e1");
        o1.setId(new Long(1));
        e1.setId(new Long(2));
        e1.setOffice(o1);
        m1.setId(new Long(1));
        m1.addManagedEmployee(e1);
        m1.setOffice(o1);
       
        OfficeImpl o2 = new OfficeImpl("o1", "Office 1");
        ManagerImpl m2 = new ManagerImpl("m1");
        EmployeeImpl e2 = new EmployeeImpl("e1");
        e2.setOffice(o2);
        m2.addManagedEmployee(e2);
        m2.setOffice(o2);
       
        assertNull(o2.getId());
        assertNull(m2.getId());
        assertNull(e2.getId());
       
        this.merger.merge(m1, m2);
       
        assertNotNull(o2.getId());
        assertEquals(o1.getId(), o2.getId());
        assertNotNull(m2.getId());
        assertEquals(m1.getId(), m2.getId());
        assertNotNull(e2.getId());
        assertEquals(e1.getId(), e2.getId());
    }
View Full Code Here

        assertNotNull(e2.getId());
        assertEquals(e1.getId(), e2.getId());
    }
   
    public void testMergeArrays() throws Exception {
        OfficeImpl o1 = new OfficeImpl("o1", "Office 1");
        ManagerImpl m1 = new ManagerImpl("m1");
        EmployeeImpl e1 = new EmployeeImpl("e1");
        o1.setId(new Long(1));
        e1.setId(new Long(2));
        e1.setOffice(o1);
        m1.setId(new Long(1));
        m1.addManagedEmployee(e1);
        m1.setOffice(o1);
       
        OfficeImpl o2 = new OfficeImpl("o1", "Office 1");
        ManagerImpl m2 = new ManagerImpl("m1");
        EmployeeImpl e2 = new EmployeeImpl("e1");
        e2.setOffice(o2);
        m2.addManagedEmployee(e2);
        m2.setOffice(o2);
       
        assertNull(o2.getId());
        assertNull(m2.getId());
        assertNull(e2.getId());
       
        Employee[] emps1 = {e1, m1};
        Employee[] emps2 = {e2, m2};
       
        this.merger.merge(emps1, emps2);
       
        assertNotNull(o2.getId());
        assertEquals(o1.getId(), o2.getId());
        assertNotNull(m2.getId());
        assertEquals(m1.getId(), m2.getId());
        assertNotNull(e2.getId());
        assertEquals(e1.getId(), e2.getId());
    }
View Full Code Here

        assertNotNull(e2.getId());
        assertEquals(e1.getId(), e2.getId());
    }
   
    public void testMergeCollections() throws Exception {
        OfficeImpl o1 = new OfficeImpl("o1", "Office 1");
        ManagerImpl m1 = new ManagerImpl("m1");
        EmployeeImpl e1 = new EmployeeImpl("e1");
        o1.setId(new Long(1));
        e1.setId(new Long(2));
        e1.setOffice(o1);
        m1.setId(new Long(1));
        m1.addManagedEmployee(e1);
        m1.setOffice(o1);
       
        OfficeImpl o2 = new OfficeImpl("o1", "Office 1");
        ManagerImpl m2 = new ManagerImpl("m1");
        EmployeeImpl e2 = new EmployeeImpl("e1");
        e2.setOffice(o2);
        m2.addManagedEmployee(e2);
        m2.setOffice(o2);
       
        assertNull(o2.getId());
        assertNull(m2.getId());
        assertNull(e2.getId());
       
        Set emps1 = new HashSet(Arrays.asList(new Employee[]{e1, m1}));
        Set emps2 = new HashSet(Arrays.asList(new Employee[]{e2, m2}));
       
        this.merger.merge(emps1, emps2);
       
        assertNotNull(o2.getId());
        assertEquals(o1.getId(), o2.getId());
        assertNotNull(m2.getId());
        assertEquals(m1.getId(), m2.getId());
        assertNotNull(e2.getId());
        assertEquals(e1.getId(), e2.getId());
    }
View Full Code Here

        assertNotNull(e2.getId());
        assertEquals(e1.getId(), e2.getId());
    }
   
    public void testMergeMaps() throws Exception {
        OfficeImpl o1 = new OfficeImpl("o1", "Office 1");
        ManagerImpl m1 = new ManagerImpl("m1");
        EmployeeImpl e1 = new EmployeeImpl("e1");
        o1.setId(new Long(1));
        e1.setId(new Long(2));
        e1.setOffice(o1);
        m1.setId(new Long(1));
        m1.addManagedEmployee(e1);
        m1.setOffice(o1);
       
        OfficeImpl o2 = new OfficeImpl("o1", "Office 1");
        ManagerImpl m2 = new ManagerImpl("m1");
        EmployeeImpl e2 = new EmployeeImpl("e1");
        e2.setOffice(o2);
        m2.addManagedEmployee(e2);
        m2.setOffice(o2);
       
        assertNull(o2.getId());
        assertNull(m2.getId());
        assertNull(e2.getId());
       
        Map emps1 = new HashMap();
        Map emps2 = new HashMap();
        emps1.put(e1.getMatriculationCode(), e1);
        emps1.put(m1.getMatriculationCode(), m1);
        emps2.put(e2.getMatriculationCode(), e2);
        emps2.put(m2.getMatriculationCode(), m2);
       
        this.merger.merge(emps1, emps2);
       
        assertNotNull(o2.getId());
        assertNotNull(m2.getId());
        assertNotNull(e2.getId());
    }
View Full Code Here

TOP

Related Classes of org.springmodules.prevayler.test.domain.OfficeImpl

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.