Package org.apache.cayenne.testdo.inherit

Examples of org.apache.cayenne.testdo.inherit.Department


    public void testDepartmentEmployees() throws Exception {
        createTestData("testDepartmentEmployees");
        List departments = context.performQuery(new SelectQuery(Department.class));

        assertEquals(1, departments.size());
        Department dept = (Department) departments.get(0);
        List employees = dept.getEmployees();
        assertEquals(3, employees.size());
        assertEquals(3, countObjectOfClass(employees, Employee.class));
        assertEquals(1, countObjectOfClass(employees, Manager.class));
    }
View Full Code Here


    @Override
    protected void setUp() throws Exception {
        deleteTestData();

        ObjectContext context = createDataContext();
        Department d1 = context.newObject(Department.class);
        d1.setName("d1");

        Department d2 = context.newObject(Department.class);
        d2.setName("d2");

        Department d3 = context.newObject(Department.class);
        d3.setName("d3");

        context.commitChanges();

        Manager m1 = context.newObject(Manager.class);
        m1.setName("m1");
        m1.setPersonType("EM");

        Manager m2 = context.newObject(Manager.class);
        m2.setName("m2");
        m2.setPersonType("EM");

        Manager m3 = context.newObject(Manager.class);
        m3.setName("m3");
        m3.setPersonType("EM");

        Address a1 = context.newObject(Address.class);
        m1.addToAddresses(a1);

        Address a2 = context.newObject(Address.class);
        m2.addToAddresses(a2);

        Address a3 = context.newObject(Address.class);
        m3.addToAddresses(a3);

        d1.addToEmployees(m1);
        d1.addToEmployees(m2);
        d3.addToEmployees(m3);

        context.commitChanges();

        d1.setToManager(m1);
        d2.setToManager(m2);
        d3.setToManager(m3);

        context.commitChanges();
    }
View Full Code Here

    public void testDeepMergeExistingSubclass() {

        final ClassDescriptor d = resolver.getClassDescriptor("Department");

        final Department d1 = context.newObject(Department.class);
        d1.setName("D1");

        // need to do double commit as Ashwood sorter blows on Employees/Departments
        // ordering...
        context.commitChanges();

        Employee e1 = context.newObject(Employee.class);
        e1.setName("E1");
        e1.setPersonType("EE");
        d1.addToEmployees(e1);

        Manager e2 = context.newObject(Manager.class);
        e2.setName("E2");
        e2.setPersonType("EM");
        d1.addToEmployees(e2);

        context.commitChanges();

        // need to make sure source relationship is resolved as a result of some Ashwood
        // strangeness...
        d1.getEmployees().size();

        // resolve Employees
        context1.performQuery(new SelectQuery(Employee.class));

        final DeepMergeOperation op = new DeepMergeOperation(context1);

        queryInterceptor.runWithQueriesBlocked(new UnitTestClosure() {

            public void execute() {
                Department d2 = (Department) op.merge(d1, d);
                assertNotNull(d2);
                assertEquals(PersistenceState.COMMITTED, d2.getPersistenceState());

                for (Employee ex : d2.getEmployees()) {
                    if ("E2".equals(ex.getName())) {
                        assertTrue(ex instanceof Manager);
                    }
                    else {
                        assertFalse(ex instanceof Manager);
View Full Code Here

    public void testDeepMergeNonExistentSubclass() {

        final ClassDescriptor d = resolver.getClassDescriptor("Department");

        final Department d1 = context.newObject(Department.class);
        d1.setName("D1");

        // need to do double commit as Ashwood sorter blows on Employees/Departments
        // ordering...
        context.commitChanges();

        Employee e1 = context.newObject(Employee.class);
        e1.setName("E1");
        e1.setPersonType("EE");
        d1.addToEmployees(e1);

        Manager e2 = context.newObject(Manager.class);
        e2.setName("E2");
        e2.setPersonType("EM");
        d1.addToEmployees(e2);

        context.commitChanges();

        // need to make sure source relationship is resolved as a result of some Ashwood
        // strangeness...
        d1.getEmployees().size();
        final DeepMergeOperation op = new DeepMergeOperation(context1);

        queryInterceptor.runWithQueriesBlocked(new UnitTestClosure() {

            public void execute() {
                Department d2 = (Department) op.merge(d1, d);
                assertNotNull(d2);
                assertEquals(PersistenceState.COMMITTED, d2.getPersistenceState());

                for (Employee ex : d2.getEmployees()) {
                    if ("E2".equals(ex.getName())) {
                        assertTrue(ex instanceof Manager);
                    }
                    else {
                        assertFalse(ex instanceof Manager);
View Full Code Here

    public void testDepartmentEmployees() throws Exception {
        createTestData("testDepartmentEmployees");
        List departments = context.performQuery(new SelectQuery(Department.class));

        assertEquals(1, departments.size());
        Department dept = (Department) departments.get(0);
        List employees = dept.getEmployees();
        assertEquals(3, employees.size());
        assertEquals(3, countObjectOfClass(employees, Employee.class));
        assertEquals(1, countObjectOfClass(employees, Manager.class));
    }
View Full Code Here

                "Department");

        DataContext context = createDataContext();
        DataContext context1 = createDataContext();

        Department d1 = context.newObject(Department.class);
        d1.setName("D1");

        // need to do double commit as Ashwood sorter blows on Employees/Departments
        // ordering...
        context.commitChanges();

        Employee e1 = context.newObject(Employee.class);
        e1.setName("E1");
        e1.setPersonType("EE");
        d1.addToEmployees(e1);

        Manager e2 = context.newObject(Manager.class);
        e2.setName("E2");
        e2.setPersonType("EM");
        d1.addToEmployees(e2);

        context.commitChanges();

        // need to make sure source relationship is resolved as a result of some Ashwood
        // strangeness...
        d1.getEmployees().size();

        // resolve Employees
        context1.performQuery(new SelectQuery(Employee.class));

        DeepMergeOperation op = new DeepMergeOperation(context1);

        blockQueries();
        try {
            Department d2 = (Department) op.merge(d1, d);
            assertNotNull(d2);
            assertEquals(PersistenceState.COMMITTED, d2.getPersistenceState());

            Iterator it = d2.getEmployees().iterator();
            while (it.hasNext()) {
                Employee ex = (Employee) it.next();
                if ("E2".equals(ex.getName())) {
                    assertTrue(ex instanceof Manager);
                }
View Full Code Here

        ClassDescriptor d = getDomain().getEntityResolver().getClassDescriptor(
                "Department");
        DataContext context = createDataContext();
        DataContext context1 = createDataContext();

        Department d1 = context.newObject(Department.class);
        d1.setName("D1");

        // need to do double commit as Ashwood sorter blows on Employees/Departments
        // ordering...
        context.commitChanges();

        Employee e1 = context.newObject(Employee.class);
        e1.setName("E1");
        e1.setPersonType("EE");
        d1.addToEmployees(e1);

        Manager e2 = context.newObject(Manager.class);
        e2.setName("E2");
        e2.setPersonType("EM");
        d1.addToEmployees(e2);

        context.commitChanges();

        // need to make sure source relationship is resolved as a result of some Ashwood
        // strangeness...
        d1.getEmployees().size();
        DeepMergeOperation op = new DeepMergeOperation(context1);

        blockQueries();
        try {
            Department d2 = (Department) op.merge(d1, d);
            assertNotNull(d2);
            assertEquals(PersistenceState.COMMITTED, d2.getPersistenceState());

            Iterator it = d2.getEmployees().iterator();
            while (it.hasNext()) {
                Employee ex = (Employee) it.next();
                if ("E2".equals(ex.getName())) {
                    assertTrue(ex instanceof Manager);
                }
View Full Code Here

        createDepartmentEmployeesDataSet();

        List<?> departments = context.performQuery(new SelectQuery(Department.class));

        assertEquals(1, departments.size());
        Department dept = (Department) departments.get(0);
        List<?> employees = dept.getEmployees();
        assertEquals(3, employees.size());
        assertEquals(3, countObjectOfClass(employees, Employee.class));
        assertEquals(1, countObjectOfClass(employees, Manager.class));
    }
View Full Code Here

        dbHelper.deleteAll("PERSON");
        dbHelper.deleteAll("CLIENT_COMPANY");

        // TODO: use TableHelper to create test data

        Department d1 = context.newObject(Department.class);
        d1.setName("d1");

        Department d2 = context.newObject(Department.class);
        d2.setName("d2");

        Department d3 = context.newObject(Department.class);
        d3.setName("d3");

        context.commitChanges();

        Manager m1 = context.newObject(Manager.class);
        m1.setName("m1");
        m1.setPersonType("EM");

        Manager m2 = context.newObject(Manager.class);
        m2.setName("m2");
        m2.setPersonType("EM");

        Manager m3 = context.newObject(Manager.class);
        m3.setName("m3");
        m3.setPersonType("EM");

        Address a1 = context.newObject(Address.class);
        m1.addToAddresses(a1);

        Address a2 = context.newObject(Address.class);
        m2.addToAddresses(a2);

        Address a3 = context.newObject(Address.class);
        m3.addToAddresses(a3);

        d1.addToEmployees(m1);
        d1.addToEmployees(m2);
        d3.addToEmployees(m3);

        context.commitChanges();

        d1.setToManager(m1);
        d2.setToManager(m2);
        d3.setToManager(m3);

        context.commitChanges();
    }
View Full Code Here

    @Inject
    protected DataChannelInterceptor queryInterceptor;

    public void testDeepMergeExistingSubclass() {

        final Department d1 = context.newObject(Department.class);
        d1.setName("D1");

        // need to do double commit as Ashwood sorter blows on Employees/Departments
        // ordering...
        context.commitChanges();

        Employee e1 = context.newObject(Employee.class);
        e1.setName("E1");
        e1.setPersonType("EE");
        d1.addToEmployees(e1);

        Manager e2 = context.newObject(Manager.class);
        e2.setName("E2");
        e2.setPersonType("EM");
        d1.addToEmployees(e2);

        context.commitChanges();

        // need to make sure source relationship is resolved as a result of some Ashwood
        // strangeness...
        d1.getEmployees().size();

        // resolve Employees
        context1.performQuery(new SelectQuery(Employee.class));

        final DeepMergeOperation op = new DeepMergeOperation(context1);

        queryInterceptor.runWithQueriesBlocked(new UnitTestClosure() {

            public void execute() {
                Department d2 = (Department) op.merge(d1);
                assertNotNull(d2);
                assertEquals(PersistenceState.COMMITTED, d2.getPersistenceState());

                for (Employee ex : d2.getEmployees()) {
                    if ("E2".equals(ex.getName())) {
                        assertTrue(ex instanceof Manager);
                    }
                    else {
                        assertFalse(ex instanceof Manager);
View Full Code Here

TOP

Related Classes of org.apache.cayenne.testdo.inherit.Department

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.