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

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


    private void createObjects(PersistenceManager pm) {
        Transaction tx = pm.currentTransaction();
        tx.begin();
        Date date = new Date();
        Person p1 = new Person(1L, "Craig", "Russell", null, date, null);
        Employee p2 = new FullTimeEmployee(2L, "Michael", "Bouschen", null, date, null, date, 0.0);
        Employee p3 = new PartTimeEmployee(3L, "Michelle", "Caisse", null, date, null, date, 0.0);
        Employee p4 = new FullTimeEmployee(4L, "Victor", "Kirkebo", null, date, null, date, 0.0);
        pm.makePersistent(p1);
        pm.makePersistent(p2);
        pm.makePersistent(p3);
        pm.makePersistent(p4);
        tx.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 = "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

        born.set(1969, 7, 20);
        hired.set(1982, 5, 5);
        Address addr2 = new Address (7002L, "43 Sematery Drive",
                                     "Woodside", "CA", "94320", "USA");
        Employee scott = new FullTimeEmployee(3001L, "Scott", "McNealy", "G",
                                              born.getTime(), addr2,
                                              hired.getTime(), 200000.0);
        born.set(1960, 4, 8);
        hired.set(1985, 2, 3);
        Address addr3 = new Address (7003L, "1298 Wanderlust Road",
                                     "Pleasanton", "CA", "95560", "USA");
        Employee ed =  new PartTimeEmployee(3002L, "Ed", "Zander", null,
                                            born.getTime(), addr3,
                                            hired.getTime(), 400000.0);
        scott.addToTeam(ed);

        // Set up their departments.
        Department board =
            new Department(2001L, "board", company);
        h = new HashSet();
        h.add(scott);
        board.setEmployees(h);
        scott.setDepartment(board);
       
        company.addDepartment(board);

        Department emg = new Department(2002L, "emg", company);
        h = new HashSet();
        h.add(ed);
        emg.setEmployees(h);
        ed.setDepartment(emg);
       
        company.addDepartment(emg);

        // Insure these guys
        DentalInsurance scottDentalIns = new DentalInsurance(
            5001L, "Aetna", scott, new BigDecimal("12000"));
        MedicalInsurance scottMedicalIns = new MedicalInsurance(
            5002L, "Aetna", scott, "PPO");
        DentalInsurance edDentalIns = new DentalInsurance(
            5003L, "BlueCross", ed, new BigDecimal("10000"));
        MedicalInsurance edMedicalIns = new MedicalInsurance(
            5004L, "BlueCross", ed, "EPO");
        scott.setDentalInsurance(scottDentalIns);
        scott.setMedicalInsurance(scottMedicalIns);
        ed.setDentalInsurance(edDentalIns);
        ed.setMedicalInsurance(edMedicalIns);

        // Give them some projects to work on.  Scott works on both; Ed only
        // on one.
        Project solaris = new Project(4001L, "Solaris", new BigDecimal(100.375));
        Project sparc = new Project(4002L, "Sparc", new BigDecimal(200.500));
        h = new HashSet();
        h.add(scott);
        h.add(ed);
        solaris.setMembers(h); // Solaris is worked on by Scott and Ed

        h = new HashSet();
        h.add(scott);
        sparc.setMembers(h); // Sparc is worked on by Scott
       
        h = new HashSet();
        h.add(solaris);
        h.add(sparc);
        scott.setProjects(h); // Scott works on Solaris and Sparc

        h = new HashSet();
        h.add(solaris);
        ed.setProjects(h); // Ed works on Solaris
       
        /* Now put all of these into the database
         */
        pm.currentTransaction().begin();
        pm.makePersistent (company);
View Full Code Here

   
    /** */
    protected Employee addEmployee() {
        Address addr1 = new Address (7004L, "456 Chelsey Lane",
                                     "Mountain View", "CA", "94040", "USA");
        Employee emp1 = new FullTimeEmployee (3003L, "First3003", "Last3003", "Middle3003",
                                              new Date(), addr1, new Date(), 10000.0);
        getPM().makePersistent (emp1);
        return emp1;
    }
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

     */
    protected void localSetUp() {
        addTearDownClass(CompanyModelReader.getTearDownClasses());
        loadAndPersistCompanyModel(getPM());
        getPM().currentTransaction().begin();
        Employee emp1 = (Employee) getPersistentCompanyModelInstance("emp1");
        emp1.setProjects(null);
        getPM().currentTransaction().commit();
    }
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.