Examples of EmployeeImpl


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

        // 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

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

        catch(PrevaylerConfigurationException ex) { 
        }
    }

    public void testUpdate() {
        EmployeeImpl emp = new EmployeeImpl("a1");
       
        // Add an employee:
        emp = (EmployeeImpl) this.prevalentSystem.save(emp);
        // Firstname is null:
        assertNull(emp.getFirstname());
       
        // Set firstname:
        emp.setFirstname("Sergio");
        // Update the employee:
        this.prevalentSystem.update(emp);
        // Read and verify:
        emp = (EmployeeImpl) this.prevalentSystem.get(emp.getClass(), emp.getId());
        assertEquals("Sergio", emp.getFirstname());
    }
View Full Code Here

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

        // 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:
        emp1 = (EmployeeImpl) this.prevalentSystem.get(Employee.class, emp1.getId());
        assertEquals("Sergio", emp1.getFirstname());
    }
View Full Code Here

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

        }
    }
   
    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

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

        emp1 = (EmployeeImpl) this.prevalentSystem.get(Employee.class, emp1.getId());
        assertEquals("Sergio", emp1.getFirstname());
    }
   
    public void testUpdateUnsavedObject() {
        EmployeeImpl emp = new EmployeeImpl("a1");
       
        try {
            // Update the transient employee:
            this.prevalentSystem.update(emp);
            fail("Update must fail!");
View Full Code Here

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

        // and the one retrieved from the employee, are the same:
        assertSame(o1, o2);
    }
   
    public void testSimpleSave() {
        EmployeeImpl emp = new EmployeeImpl("a1");
       
        // Id null before adding:
        assertNull(emp.getId());
       
        this.template.save(emp);
       
        // Id not null after adding:
        assertNotNull(emp.getId());
    }
View Full Code Here

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

        catch(PrevaylerUnsavedObjectException ex) { 
        }
    }

    public void testDeleteByEntity() {
        EmployeeImpl emp = new EmployeeImpl("a1");
       
        // Add an employee:
        this.prevalentSystem.save(emp);
       
        // Delete it:
        this.prevalentSystem.delete(emp);
        // Try to get it by id and verify null is returned:
        emp = (EmployeeImpl) this.prevalentSystem.get(emp.getClass(), emp.getId());
        assertNull(emp);
    }
View Full Code Here

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

   
    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

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

        emp = (EmployeeImpl) this.prevalentSystem.get(emp.getClass(), emp.getId());
        assertNull(emp);
    }
   
    public void testDeleteByEntityClass() {
        EmployeeImpl emp = new EmployeeImpl("a1");
       
        // Add an employee:
        this.prevalentSystem.save(emp);
        // Verify:
        List result = this.prevalentSystem.get(emp.getClass());
        assertFalse(result.isEmpty());
       
        // Delete all:
        this.prevalentSystem.delete(emp.getClass());
        // Try to get all employees and verify that an empty list is returned:
        result = this.prevalentSystem.get(emp.getClass());
        assertTrue(result.isEmpty());
    }
View Full Code Here

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

        // But the two employees got from the prevalent system, one by id, one from the manager, are the same:
        assertSame(empA, empB);
    }
   
    public void testUpdate() {
        EmployeeImpl emp = new EmployeeImpl("a1");
       
        // Add an employee:
        this.template.save(emp);
        // Firstname is null:
        assertNull(emp.getFirstname());
       
        // Set firstname:
        emp.setFirstname("Sergio");
        // Update the employee:
        this.template.update(emp);
        // Read and verify:
        emp = (EmployeeImpl) this.template.get(emp.getClass(), emp.getId());
        assertEquals("Sergio", emp.getFirstname());
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.