Package org.apache.cayenne.unit.di

Examples of org.apache.cayenne.unit.di.UnitTestClosure


        query.addPrefetch(Box.BALLS_PROPERTY).setSemantics(PrefetchTreeNode.JOINT_PREFETCH_SEMANTICS);
        query.addPrefetch(Box.BALLS_PROPERTY + "." + Ball.THING_PROPERTY).setSemantics(
                PrefetchTreeNode.DISJOINT_BY_ID_PREFETCH_SEMANTICS);
        final List<Box> result = context.performQuery(query);

        queryInterceptor.runWithQueriesBlocked(new UnitTestClosure() {

            public void execute() {
                assertFalse(result.isEmpty());
                List<Integer> volumes = new ArrayList<Integer>();
                for (Box box : result) {
View Full Code Here


        query.addPrefetch(Bag.BOXES_PROPERTY).setSemantics(PrefetchTreeNode.DISJOINT_BY_ID_PREFETCH_SEMANTICS);
        query.addPrefetch(Bag.BOXES_PROPERTY + "." + Box.BALLS_PROPERTY).setSemantics(
                PrefetchTreeNode.JOINT_PREFETCH_SEMANTICS);
        final List<Bag> result = context.performQuery(query);

        queryInterceptor.runWithQueriesBlocked(new UnitTestClosure() {

            public void execute() {
                assertFalse(result.isEmpty());

                Bag bag = result.get(0);
View Full Code Here

        runtime.getDataDomain().setMaxIdQualifierSize(-1);

        final SelectQuery query = new SelectQuery(Painting.class);
        query.setPageSize(10);
        int queriesCount = queryInterceptor.runWithQueryCounter(new UnitTestClosure() {

            public void execute() {
                final List<Painting> boxes = context.performQuery(query);
                List<Painting> tempList = new ArrayList<Painting>();
                tempList.addAll(boxes);
View Full Code Here

        assertEquals(PersistenceState.DELETED, deleted.getPersistenceState());
        assertEquals(PersistenceState.NEW, _new.getPersistenceState());

        // now check how objects in different state behave

        queryInterceptor.runWithQueriesBlocked(new UnitTestClosure() {

            public void execute() {
                Persistent newPeer = childContext.localObject(_new.getObjectId(), _new);

                assertEquals(_new.getObjectId(), newPeer.getObjectId());
View Full Code Here

        peerModified.setArtistName("M2");

        assertEquals(PersistenceState.MODIFIED, modified.getPersistenceState());
        assertEquals(PersistenceState.MODIFIED, peerModified.getPersistenceState());

        queryInterceptor.runWithQueriesBlocked(new UnitTestClosure() {

            public void execute() {
                Persistent peerModified2 = childContext.localObject(modified
                        .getObjectId(), modified);
                assertSame(peerModified, peerModified2);
View Full Code Here

        Artist _new = context.newObject(Artist.class);
        final Painting _newP = context.newObject(Painting.class);
        _new.addToPaintingArray(_newP);

        queryInterceptor.runWithQueriesBlocked(new UnitTestClosure() {

            public void execute() {
                Painting painting = (Painting) childContext.localObject(_newP
                        .getObjectId(), _newP);
                assertEquals(PersistenceState.COMMITTED, painting.getPersistenceState());
View Full Code Here

        SelectQuery q = new SelectQuery(Painting.class);
        q.addOrdering(Painting.PAINTING_TITLE_PROPERTY, SortOrder.ASCENDING);
        final List<?> childSources = child.performQuery(q);
        assertEquals(5, childSources.size());

        queryInterceptor.runWithQueriesBlocked(new UnitTestClosure() {

            public void execute() {
                Painting childHollowTargetSrc = (Painting) childSources.get(0);
                assertSame(child, childHollowTargetSrc.getObjectContext());
                Artist childHollowTarget = childHollowTargetSrc.getToArtist();
View Full Code Here

        final List<?> results = child.performQuery(q);

        // blockQueries();

        queryInterceptor.runWithQueriesBlocked(new UnitTestClosure() {

            public void execute() {
                assertEquals(2, results.size());
                Iterator<?> it = results.iterator();
                while (it.hasNext()) {
View Full Code Here

        q.addOrdering(Artist.ARTIST_NAME_PROPERTY, SortOrder.ASCENDING);
        q.addPrefetch(Artist.PAINTING_ARRAY_PROPERTY);

        final List<?> results = child.performQuery(q);

        queryInterceptor.runWithQueriesBlocked(new UnitTestClosure() {

            public void execute() {
                Artist o1 = (Artist) results.get(0);
                assertEquals(PersistenceState.COMMITTED, o1.getPersistenceState());
                assertSame(child, o1.getObjectContext());
View Full Code Here

        tArtist.insert(456, "Bla");

        final Artist a1 = Cayenne.objectForPK(context1, Artist.class, 456);
        final Artist a2 = Cayenne.objectForPK(context2, Artist.class, 456);

        interceptor.runWithQueriesBlocked(new UnitTestClosure() {

            public void execute() {
                Artist a3 = context2.localObject(a1);
                assertSame(a3, a2);
                assertSame(context2, a3.getObjectContext());
View Full Code Here

TOP

Related Classes of org.apache.cayenne.unit.di.UnitTestClosure

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.