Package org.springmodules.prevayler.test.domain

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


    public void testResolveId() {
        Employee emp = new EmployeeImpl("a1");
        assertNotNull(this.resolver.resolveId(emp));
       
        Manager man = new ManagerImpl("a1");
        assertNotNull(this.resolver.resolveId(man));
    }
View Full Code Here


        assertNotNull(emp.getId());
    }
   
    public void testCascadeSave() {
        // Create the manager:
        ManagerImpl man1 = new ManagerImpl("m1");
        // Create an employee and add it to the manager:
        EmployeeImpl emp1 = new EmployeeImpl("a1");
        man1.addManagedEmployee(emp1);
        // Save the manager and the employee by cascade:
        this.template.save(man1);
       
        // The employee saved by cascade has a not null id:
        assertNotNull(emp1.getId());
       
        // Verify object identities:
        EmployeeImpl empA = (EmployeeImpl) this.template.get(Employee.class, ((EmployeeImpl) man1.getManagedEmployees().iterator().next()).getId());
        ManagerImpl manA = (ManagerImpl) this.template.get(Manager.class, man1.getId());
        EmployeeImpl empB = (EmployeeImpl) manA.getManagedEmployees().iterator().next();
        // The new employee, get from the manager, is not the same as the old one:
        assertNotSame(emp1, empA);
        // But the two employees got from the prevalent system, one by id, one from the manager, are the same:
        assertSame(empA, empB);
    }
View Full Code Here

        assertEquals("Sergio", emp.getFirstname());
    }
   
    public void testCascadeUpdate() {
        // Create and save the manager:
        ManagerImpl man1 = new ManagerImpl("m1");
        this.template.save(man1);
       
        // Create an employee and add it to the manager:
        EmployeeImpl emp1 = new EmployeeImpl("a1");
        man1.addManagedEmployee(emp1);
        // Update the manager:
        this.template.update(man1);
       
        // Get the employee from the manager and change employee firstname:
        emp1 = (EmployeeImpl) man1.getManagedEmployees().iterator().next();
        emp1.setFirstname("Sergio");
        // Update the manager and the employee by cascade:
        this.template.update(man1);
       
        // Verify:
View Full Code Here

        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

        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

        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

        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

        assertNotNull(emp.getId());
    }
   
    public void testCascadeSave() {
        // Create and save the manager:
        ManagerImpl man1 = new ManagerImpl("m1");
        man1 = (ManagerImpl) this.prevalentSystem.save(man1);
       
        // Create an employee and add it to the manager:
        EmployeeImpl emp1 = new EmployeeImpl("a1");
        man1.addManagedEmployee(emp1);
        // Update the manager and save the employee by cascade:
        man1 = (ManagerImpl) this.prevalentSystem.update(man1);
       
        // Verify that the id has been set:
        assertNotNull(emp1.getId());
       
        // Verify object identities:
        EmployeeImpl empA = (EmployeeImpl) this.prevalentSystem.get(Employee.class, emp1.getId());
        EmployeeImpl empB = (EmployeeImpl) man1.getManagedEmployees().iterator().next();
        assertSame(emp1, empA);
        assertSame(empA, empB);
    }
View Full Code Here

        assertEquals("Sergio", emp.getFirstname());
    }
   
    public void testCascadeUpdate() {
        // Create and save the manager:
        ManagerImpl man1 = new ManagerImpl("m1");
        man1 = (ManagerImpl) this.prevalentSystem.save(man1);
       
        // Create an employee and add it to the manager:
        EmployeeImpl emp1 = new EmployeeImpl("a1");
        man1.addManagedEmployee(emp1);
        // Update the manager:
        man1 = (ManagerImpl) this.prevalentSystem.update(man1);
       
        // Get the employee from the manager and change employee firstname:
        emp1 = (EmployeeImpl) man1.getManagedEmployees().iterator().next();
        emp1.setFirstname("Sergio");
        // Update the manager and the employee by cascade:
        man1 = (ManagerImpl) this.prevalentSystem.update(man1);
       
        // Verify:
View Full Code Here

TOP

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

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.