Package org.apache.jdo.tck.pc.company

Examples of org.apache.jdo.tck.pc.company.Employee


     * field) to more than one one-to-many collection relationship
     */
    public void testAddToMoreThanOne() {
        testMethod = "testAddToMoreThanOne";
        if (isTestToBePerformed) {
            Employee empNew = new FullTimeEmployee(99, "Matthew", "", "Adams",
                new Date(0L), new Date(10000L), 125000);
            pm.makePersistent(empNew);
            dept1.addEmployee(empNew);
            dept2.addEmployee(empNew);
            doFlush(testMethod);
View Full Code Here


     * to a different instance
     */
    public void testAInBbutNotB2A() {
        testMethod = "testAInBbutNotB2A";
        if (isTestToBePerformed) {
            Employee empNew = new FullTimeEmployee(99, "Matthew", "", "Adams",
                new Date(0L), new Date(10000L), 125000);
            pm.makePersistent(empNew);
            dept1.addEmployee(empNew);
            empNew.setDepartment(dept2);
            doFlush(testMethod);
        }
    }
View Full Code Here

        testMethod = "testAddExistingFromMappedbySide";
        if (isTestToBePerformed) {
           
            // Set relationship
            Object emp4Oid = getOidByName("emp4");
            Employee emp4 = (Employee)pm.getObjectById(emp4Oid);
            Object dept2Oid = getOidByName("dept2");
            Department dept2 = (Department)pm.getObjectById(dept2Oid);

            dept1.addEmployee(emp4);
            pm.flush();
           
            // Postcondition
            deferredAssertTrue(emp4.getDepartment() == dept1,
                ASSERTION_FAILED + testMethod,
                "Postcondition is false; "
                + "other side of relationship not set on flush");
            deferredAssertTrue(!dept2.getEmployees().contains(emp4),
                ASSERTION_FAILED + testMethod,
                "Postcondition is false; "
                + "previous relationship not unset on flush");
            pm.currentTransaction().commit();
            cleanupPM();
            getPM();
           
            pm.currentTransaction().begin();
            emp4 = (Employee)pm.getObjectById(emp4Oid);
            dept1 = (Department)pm.getObjectById(dept1Oid);
            dept2 = (Department)pm.getObjectById(dept2Oid);
            deferredAssertTrue(emp4.getDepartment() == dept1,
                ASSERTION_FAILED + testMethod,
                "In new transaction, postcondition is false; " +
                "other side of relationship is not set.");
            deferredAssertTrue(!dept2.getEmployees().contains(emp4),
                ASSERTION_FAILED + testMethod,
View Full Code Here

        testMethod = "testReplaceFromMappedbySide";
        if (isTestToBePerformed) {
           
            // Set relationship
            Object emp4Oid = getOidByName("emp4");
            Employee emp4 = (Employee)pm.getObjectById(emp4Oid);
            Object dept2Oid = getOidByName("dept2");
            Department dept2 = (Department)pm.getObjectById(dept2Oid);

            Set emps = new HashSet();
            emps.add(emp4);
            dept1.setEmployees(emps);
            pm.flush();
           
            // Postcondition
            deferredAssertTrue(emp4.getDepartment() == dept1,
                ASSERTION_FAILED + testMethod,
                "Postcondition is false; "
                + "other side of relationship not set on flush");
            deferredAssertTrue(!dept2.getEmployees().contains(emp4),
                ASSERTION_FAILED + testMethod,
                "Postcondition is false; "
                + "previous relationship not unset on flush");
            pm.currentTransaction().commit();
            cleanupPM();
            getPM();
           
            pm.currentTransaction().begin();
            emp4 = (Employee)pm.getObjectById(emp4Oid);
            dept1 = (Department)pm.getObjectById(dept1Oid);
            dept2 = (Department)pm.getObjectById(dept2Oid);
            deferredAssertTrue(emp4.getDepartment() == dept1,
                ASSERTION_FAILED + testMethod,
                "In new transaction, postcondition is false; " +
                "other side of relationship is not set.");
            deferredAssertTrue(!dept2.getEmployees().contains(emp4),
                ASSERTION_FAILED + testMethod,
View Full Code Here

    public void testAddNewFromMappedbySide() {
        testMethod = "testAddNewFromMappedbySide";
        if (isTestToBePerformed) {
           
            // Set relationship
            Employee empNew = new FullTimeEmployee(101, "Jenny", "Merriwether",
                "White", new Date(500L), new Date(10000L), 135000);
            pm.makePersistent(empNew);
            Object empNewOid = pm.getObjectId((Object)empNew);

            dept1.addEmployee(empNew);
            pm.flush();
           
            // Postcondition
            deferredAssertTrue(empNew.getDepartment() == dept1,
                ASSERTION_FAILED + testMethod,
                "Postcondition is false; "
                + "other side of relationship not set on flush");
            pm.currentTransaction().commit();
            cleanupPM();
            getPM();
           
            pm.currentTransaction().begin();
            empNew = (Employee)pm.getObjectById(empNewOid);
            dept1 = (Department)pm.getObjectById(dept1Oid);
            deferredAssertTrue(empNew.getDepartment() == dept1,
                ASSERTION_FAILED + testMethod,
                "In new transaction, postcondition is false; " +
                "other side of relationship is not set.");
            pm.currentTransaction().commit();
           
View Full Code Here

    public void testSetToNewFromMappedSide() {
        testMethod = "testSetToNewFromMappedSide";
        if (isTestToBePerformed) {
           
            // Set relationship
            Employee empNew = new FullTimeEmployee(99, "Matthew", "", "Adams",
                new Date(0L), new Date(10000L), 125000);
            pm.makePersistent(empNew);
            medIns1.setEmployee(empNew);
            Object empNewOid = pm.getObjectId((Object)empNew);
            pm.flush();
           
            // Postcondition
            deferredAssertTrue(empNew.getMedicalInsurance() == medIns1,
                ASSERTION_FAILED + testMethod,
                "Postcondition is false; "
                + "other side of relationship not set on flush");
           
            pm.currentTransaction().commit();
            cleanupPM();
            getPM();
           
            pm.currentTransaction().begin();
            emp1 = (Employee)pm.getObjectById(emp1Oid);
            empNew = (Employee)pm.getObjectById(empNewOid);
            medIns1 = (MedicalInsurance)pm.getObjectById(medIns1Oid);
            deferredAssertTrue(empNew.getMedicalInsurance() == medIns1,
                ASSERTION_FAILED + testMethod,
                "Postcondition is false; "
                + "other side of relationship not set in new pm");
            pm.currentTransaction().commit();
           
View Full Code Here

    public void testAddNewFromMappedSide() {
        testMethod = "testAddNewFromMappedSide";
        if (isTestToBePerformed) {
           
            // Set relationship
            Employee empNew = new FullTimeEmployee(100, "Jerry", "Valentine",
                    "Brown", new Date(500L), new Date(10000L), 125000);
            pm.makePersistent(empNew);
            proj1.addMember(empNew);
            Object empNewOid = pm.getObjectId((Object)empNew);
            pm.flush();

            // Postcondition

            deferredAssertTrue(empNew.getProjects().contains(proj1),
                    ASSERTION_FAILED + testMethod,
                    "Postcondition is false; "
                    + "other side of relationship not set on flush");
            pm.currentTransaction().commit();
            cleanupPM();
            getPM();
           
            pm.currentTransaction().begin();
            empNew = (Employee)pm.getObjectById(empNewOid);
            emp1 = (Employee)pm.getObjectById(emp1Oid);
            proj1 = (Project)pm.getObjectById(proj1Oid);
            deferredAssertTrue(empNew.getProjects().contains(proj1),
                    ASSERTION_FAILED + testMethod,
                    "Postcondition is false; "
                    + "other side of relationship not set in new pm");
            pm.currentTransaction().commit();
           
View Full Code Here

        testMethod = "testAddExistingFromMappedSide";
        if (isTestToBePerformed) {
           
            // Set relationship
            Object emp4Oid = getOidByName("emp4");
            Employee emp4 = (Employee)pm.getObjectById(emp4Oid);
            proj1.addMember(emp4);
            pm.flush();

            // Postcondition

            deferredAssertTrue(emp4.getProjects().contains(proj1),
                    ASSERTION_FAILED + testMethod,
                    "Postcondition is false; "
                    + "other side of relationship not set on flush");
            pm.currentTransaction().commit();
            cleanupPM();
            getPM();
           
            pm.currentTransaction().begin();
            emp4 = (Employee)pm.getObjectById(emp4Oid);
            emp1 = (Employee)pm.getObjectById(emp1Oid);
            proj1 = (Project)pm.getObjectById(proj1Oid);
            deferredAssertTrue(emp4.getProjects().contains(proj1),
                    ASSERTION_FAILED + testMethod,
                    "Postcondition is false; "
                    + "other side of relationship not set in new pm");
            pm.currentTransaction().commit();
           
View Full Code Here

        testMethod = "testReplaceFromMappedSide";
        if (isTestToBePerformed) {
           
            // Set relationship
            Set members = new HashSet();
            Employee empNew = new FullTimeEmployee(100, "Jerry", "Valentine",
                "Brown", new Date(500L), new Date(10000L), 125000);
            pm.makePersistent(empNew);
            members.add(empNew);
            proj1.setMembers(members);
            Object empNewOid = pm.getObjectId(empNew);
            pm.flush();
           
            assertFalse(testMethod + ": Test aborted, precondition is false; " +
                "expected empNewOid to be non-null", empNewOid == null);
           
            // Postcondition
           
            deferredAssertTrue(empNew.getProjects().contains(proj1),
                ASSERTION_FAILED + testMethod,
                "Postcondition is false; "
                + "other side of relationship not set on flush");
            pm.currentTransaction().commit();
            cleanupPM();
            getPM();
           
            pm.currentTransaction().begin();
            empNew = (Employee)pm.getObjectById(empNewOid);
            emp1 = (Employee)pm.getObjectById(emp1Oid);
            proj1 = (Project)pm.getObjectById(proj1Oid);
            deferredAssertTrue(empNew.getProjects().contains(proj1),
                ASSERTION_FAILED + testMethod,
                "Postcondition is false; "
                + "other side of relationship not set in new pm");
            pm.currentTransaction().commit();
           
View Full Code Here

        for (Iterator i = instances.iterator(); i.hasNext(); ) {
            Object pc = i.next();
           
            // clear employee relationships
            if (pc instanceof Employee) {
                Employee employee = (Employee) pc;
                if (employee.getDentalInsurance() != null) {
                    employee.getDentalInsurance().setEmployee(null);
                }
                if (employee.getMedicalInsurance() != null) {
                    employee.getMedicalInsurance().setEmployee(null);
                }
                if (employee.getDepartment() != null) {
                    ((Department)employee.getDepartment()).removeEmployee(employee);
                }
                if (employee.getFundingDept() != null) {
                    ((Department)employee.getFundingDept()).removeEmployee(employee);
                }
                if (employee.getManager() != null) {
                    ((Employee)employee.getManager()).removeFromTeam(employee);
                }
                if (employee.getMentor() != null) {
                    employee.getMentor().setProtege(null);
                }
                if (employee.getProtege() != null) {
                    employee.getProtege().setMentor(null);
                }
                if (employee.getHradvisor() != null) {
                    ((Employee)employee.getHradvisor()).removeAdvisee(employee);
                }
                if (employee.getReviewedProjects() != null) {
                    for (Iterator it=employee.getReviewedProjects().iterator();
                            it.hasNext(); ) {
                        Project other = (Project) it.next();
                        other.removeReviewer(employee);
                    }
                }
                if (employee.getProjects() != null) {
                    for (Iterator it=employee.getProjects().iterator();
                            it.hasNext(); ) {
                        Project other = (Project) it.next();
                        other.removeMember(employee);
                    }
                }
                if (employee.getTeam() != null) {
                    for (Iterator it=employee.getTeam().iterator(); it.hasNext(); ) {
                        Employee other = (Employee) it.next();
                        other.setManager(null);
                    }
                }
                if (employee.getHradvisees() != null) {
                    for (Iterator it=employee.getHradvisees().iterator(); it.hasNext(); ) {
                        Employee other = (Employee) it.next();
                        other.setHradvisor(employee);
                    }
                }
            }
           
            // make the instance dirty.
View Full Code Here

TOP

Related Classes of org.apache.jdo.tck.pc.company.Employee

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.