Examples of TestProxyVersion


Examples of org.apache.isis.runtimes.dflt.runtime.testsystem.TestProxyVersion

    @Test
    public void testFindInstances() throws Exception {

        // The remote interface is asked for instances, which are returned as
        // data objects
        final DummyObjectData instanceData = new DummyObjectData(new TestProxyOid(12, true), Movie.class.getName(), true, new TestProxyVersion(3));

        // The data then needs to be decoded into the ObjectAdapter
        final TestProxyAdapter dummyObjectAdapter = new TestProxyAdapter();
        // new DummyOid(12, true), ResolveState.GHOST, "test");
        dummyObjectAdapter.setupObject(new Movie());
View Full Code Here

Examples of org.apache.isis.runtimes.dflt.runtime.testsystem.TestProxyVersion

                final DummyObjectData directorData = encoderShouldCreateGraphForChangedDirector(directorAdapter);
                distributionShouldExecuteClientActionForBothChangedObjects(movieData, directorData);
            }

            private DummyObjectData encoderShouldCreateGraphForChangedMovie(final TestProxyAdapter movieAdapter) {
                final DummyObjectData movieData = new DummyObjectData(new TestProxyOid(12, true), Movie.class.getName(), true, new TestProxyVersion(4));
                final DummyEncodeableObjectData expectedMovieName = new DummyEncodeableObjectData("War of the Worlds", String.class.getName());
                final DummyReferenceData expectedDirectorRef = new DummyReferenceData(new TestProxyOid(14, true), Person.class.getName(), new TestProxyVersion(8));
                movieData.setFieldContent(new Data[] { expectedDirectorRef, expectedMovieName });

                one(mockEncoder).encodeGraphForChangedObject(movieAdapter, new KnownObjectsRequest());
                will(returnValue(movieData));
                return movieData;
            }

            private DummyObjectData encoderShouldCreateGraphForChangedDirector(final TestProxyAdapter directorAdapter) {
                final DummyObjectData directorData = new DummyObjectData(new TestProxyOid(14, true), Person.class.getName(), true, new TestProxyVersion(8));
                final DummyEncodeableObjectData expectedDirectorName = new DummyEncodeableObjectData("Unknown", String.class.getName());
                directorData.setFieldContent(new Data[] { expectedDirectorName });

                one(mockEncoder).encodeGraphForChangedObject(directorAdapter, new KnownObjectsRequest());
                will(returnValue(directorData));
                return directorData;
            }

            private void distributionShouldExecuteClientActionForBothChangedObjects(final DummyObjectData movieData, final DummyObjectData directorData) {
                // final ObjectData[] changes = new ObjectData[] { movieData,
                // directorData };
                // final int[] types = new int[] {
                // ClientTransactionEvent.CHANGE, ClientTransactionEvent.CHANGE
                // };

                one(mockDistribution).executeClientAction(with(any(ExecuteClientActionRequest.class)));

                final Version[] versionUpdates = new Version[] { new TestProxyVersion(5), new TestProxyVersion(9) };
                will(returnValue(new ExecuteClientActionResponse(new ObjectData[] { movieData, directorData }, versionUpdates, new ObjectData[0])));
            }
        });
        // TODO: should look inside the request object and ensure:
        // with(equalTo(session)),
        // with(equalTo(changes)),
        // with(equalTo(types)),

        transactionManager.startTransaction();
        persistenceSessionProxy.objectChanged(movieAdapter);
        persistenceSessionProxy.objectChanged(directorAdapter);
        transactionManager.endTransaction();

        assertEquals(new TestProxyVersion(5), movieAdapter.getVersion());
        assertEquals(new TestProxyVersion(9), directorAdapter.getVersion());
    }
View Full Code Here

Examples of org.apache.isis.runtimes.dflt.runtime.testsystem.TestProxyVersion

        mockery.checking(new Expectations() {
            {
                // this returns results data with new oid and version
                final TestProxyOid newOid = new TestProxyOid(123, true);
                newOid.setupPrevious(previousOid);
                final DummyReferenceData updateData = new DummyReferenceData(newOid, "type", new TestProxyVersion(456));

                // the server is called with data (movieData) for the object to
                // be persisted
                one(mockDistribution).executeClientAction(with(any(ExecuteClientActionRequest.class)));
View Full Code Here

Examples of org.apache.isis.runtimes.dflt.runtime.testsystem.TestProxyVersion

    }

    @Test
    public void testSetAssociationFailsWithNonCurrentTarget() {
        // version should be different, causing concurrency exception
        movieAdapter.setOptimisticLock(new TestProxyVersion(6));
        try {
            final SetAssociationRequest request = new SetAssociationRequest(authenticationSession, "director", movieData, personData);
            server.setAssociation(request);
            fail();
        } catch (final ConcurrencyException expected) {
View Full Code Here

Examples of org.apache.isis.runtimes.dflt.runtime.testsystem.TestProxyVersion

    }

    @Test
    public void testSetAssociationFailsWithNonCurrentAssociate() {
        // version should be different, causing concurrency exception
        personAdapter.setOptimisticLock(new TestProxyVersion(6));
        try {
            final SetAssociationRequest request = new SetAssociationRequest(authenticationSession, "director", movieData, personData);
            server.setAssociation(request);
            fail();
        } catch (final ConcurrencyException expected) {
View Full Code Here

Examples of org.apache.isis.runtimes.dflt.runtime.testsystem.TestProxyVersion

    @Test
    public void testExecuteClientActionWhereObjectChanged() {
        final ObjectAdapter adapter = system.createPersistentTestObject();

        final DummyObjectData data = new DummyObjectData(adapter.getOid(), "none", true, new TestProxyVersion(1));

        // prepare the update data to return
        mockery.checking(new Expectations() {
            {
                one(mockEncoder).decode(data, new KnownObjectsRequest());
                will(returnValue(adapter));

            }
        });

        // results returned in their own container
        final ExecuteClientActionResponse results = new ExecuteClientActionResponse(new ObjectData[0], new Version[0], null);
        mockery.checking(new Expectations() {
            {
                one(mockEncoder).encodeClientActionResult(with(equalTo(new ReferenceData[1])), with(equalTo(new Version[] { new TestProxyVersion(2) })), with(equalTo(new ObjectData[0])));
                will(returnValue(results));
            }
        });

        final ExecuteClientActionRequest request = new ExecuteClientActionRequest(session, new ReferenceData[] { data }, new int[] { ClientTransactionEvent.CHANGE });
        // don't start xactn here, since within call.
        final ExecuteClientActionResponse result = server.executeClientAction(request);
        final ObjectAdapter object = IsisContext.getPersistenceSession().loadObject(adapter.getOid(), adapter.getSpecification());

        assertEquals(new TestProxyVersion(2), object.getVersion());

        assertEquals(results, result);
    }
View Full Code Here

Examples of org.apache.isis.runtimes.dflt.runtime.testsystem.TestProxyVersion

    @Test
    public void testExecuteClientActionWhereObjectMadePersistent() {
        final ObjectAdapter adapter = system.createTransientTestObject();

        final DummyObjectData data = new DummyObjectData(adapter.getOid(), "none", true, new TestProxyVersion(1));

        // restore the object on the server
        mockery.checking(new Expectations() {
            {
                one(mockEncoder).decode(data, new KnownObjectsRequest());
                will(returnValue(adapter));

                one(mockEncoder).encodeIdentityData(adapter);
                will(returnValue(null));
            }
        });

        // return results
        final ExecuteClientActionResponse results = new ExecuteClientActionResponse(new ObjectData[0], new Version[0], new ObjectData[0]);
        mockery.checking(new Expectations() {
            {
                one(mockEncoder).encodeClientActionResult(with(equalTo(new ReferenceData[1])), with(equalTo(new Version[1])), with(equalTo(new ObjectData[0])));
                will(returnValue(results));
            }
        });

        // don't start xactn here, since within call.

        final ExecuteClientActionRequest request = new ExecuteClientActionRequest(session, new ReferenceData[] { data }, new int[] { ClientTransactionEvent.ADD });
        final ExecuteClientActionResponse response = server.executeClientAction(request);

        final ObjectAdapter object = IsisContext.getPersistenceSession().loadObject(adapter.getOid(), adapter.getSpecification());

        assertEquals(results, response);
        assertEquals(adapter, object);
        assertEquals(new TestProxyVersion(1), object.getVersion());
    }
View Full Code Here

Examples of org.apache.isis.runtimes.dflt.runtime.testsystem.TestProxyVersion

    }

    @Test
    public void testExecuteClientActionFailsWithConcurrencyError() {
        final ObjectAdapter adapter = system.createPersistentTestObject();
        adapter.setOptimisticLock(new TestProxyVersion(7));

        final Oid oid = adapter.getOid();
        final DummyIdentityData identityData = new DummyIdentityData(oid, TestProxyAdapter.class.getName(), new TestProxyVersion(6));

        try {
            final ExecuteClientActionRequest request = new ExecuteClientActionRequest(new TestProxySession(), new ReferenceData[] { identityData }, new int[] { ClientTransactionEvent.DELETE });
            server.executeClientAction(request);
            fail();
View Full Code Here

Examples of org.apache.isis.runtimes.dflt.runtime.testsystem.TestProxyVersion

    @Test
    public void testExecuteClientActionWhereObjectDeleted() {
        final ObjectAdapter adapter = system.createPersistentTestObject();

        final Oid oid = adapter.getOid();
        final DummyIdentityData identityData = new DummyIdentityData(oid, TestProxyAdapter.class.getName(), new TestProxyVersion(1));

        // return results
        final ExecuteClientActionResponse results = new ExecuteClientActionResponse(new ObjectData[0], new Version[0], null);
        mockery.checking(new Expectations() {
            {
View Full Code Here

Examples of org.apache.isis.runtimes.dflt.runtime.testsystem.TestProxyVersion

    public void testLookedUpObjectHasDifferentVersion() {
        final ObjectAdapter object = system.createPersistentTestObject();
        final String id = context.mapObject(object);
        // change version on the object being passed back
        object.setOptimisticLock(new TestProxyVersion(5));
        context.getMappedObject(id);
        assertEquals("Reloaded object " + object.titleString(), context.getMessage(1));
    }
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.