Package org.apache.isis.runtimes.dflt.runtime.testsystem

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


        // objects
        configuration = new TestProxyConfiguration();
        spec = new TestProxySpecification(this.getClass());
        spec.fields = Collections.emptyList();
        adapter = new TestProxyAdapter();
        adapter.setupSpecification(spec);
        adapter.setOptimisticLock(new SerialNumberVersion(23, null, null));
        adapter.setupOid(SerialOid.createPersistent(1));
        persistenceHelper = new ObjectStorePersistenceHelper(spec);
        transaction = null;
View Full Code Here


            @Override
            public ObjectAdapter createAdapter(final Object pojo, final Oid oid) {
                final ObjectSpecification specification = reflector.loadSpecification(pojo.getClass());
                final ResolveState state = oid == null ? ResolveState.VALUE : oid.isTransient() ? ResolveState.TRANSIENT : ResolveState.GHOST;

                final TestProxyAdapter objectAdapter = new TestProxyAdapter();
                objectAdapter.setupResolveState(state);
                objectAdapter.setupObject(pojo);
                objectAdapter.setupOid(oid);
                objectAdapter.setupSpecification(specification);

                adapters.put(pojo, objectAdapter);

                return objectAdapter;
            }
View Full Code Here

        return "";
    }

    @Override
    public ObjectAdapter get(final ObjectAdapter fromObject) {
        final TestProxyAdapter adapter = new TestProxyAdapter();
        final String object = getMovie(fromObject).getName();
        adapter.setupObject(object);
        return adapter;
    }
View Full Code Here

        action = new ObjectActionImpl(mockFacetedMethod, new ObjectMemberContext(mockAuthenticationSessionProvider, mockSpecificationLookup, mockAdapterManager, mockQuerySubmitter, mockCollectionTypeRegistry), mockServicesProvider);
    }

    @Test
    public void testExecutePassedOnToPeer() {
        final TestProxyAdapter target = new TestProxyAdapter();
        target.setupSpecification(new TestSpecification());
        final ObjectAdapter[] parameters = new ObjectAdapter[2];

        final TestProxyAdapter result = new TestProxyAdapter();
        final ActionInvocationFacet facet = new ActionInvocationFacetAbstract(mockFacetedMethod) {
            @Override
            public ObjectAdapter invoke(final ObjectAdapter target, final ObjectAdapter[] parameters) {
                return result;
            }
View Full Code Here

        return "";
    }

    @Override
    public ObjectAdapter get(final ObjectAdapter fromObject) {
        final TestProxyAdapter adapter = new TestProxyAdapter();
        adapter.setupObject(getPerson(fromObject).getName());
        return adapter;
    }
View Full Code Here

            }

        });
        spec.setupFields(fields);

        fieldsObject = new TestProxyAdapter();
        fieldsObject.setupResolveState(ResolveState.TRANSIENT);
        fieldsObject.setupSpecification(system.getSpecification(String.class));

        adder = new PersistedObjectAdderSpy();
    }
View Full Code Here

        // 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());
        dummyObjectAdapter.setupSpecification(new MovieSpecification());

        final PersistenceQueryData c = new TestCriteria();
        final ObjectSpecification noSpec = getSpecificationLoader().loadSpecification(Movie.class);
        final PersistenceQueryFindAllInstances criteria = new PersistenceQueryFindAllInstances(noSpec);
View Full Code Here

    }

    @Test
    public void testResolveImmediatelyIgnoredWhenAlreadyResolving() throws Exception {

        final TestProxyAdapter object = new TestProxyAdapter();
        object.setupResolveState(ResolveState.RESOLVING);

        // implicit: expect no calls to encoder object
        mockery.checking(new Expectations() {
            {
                never(mockDistribution);
View Full Code Here

    @Ignore("need to get working after refactoring")
    @Test
    public void testResolveImmediately() throws Exception {

        final TestProxyAdapter object = new TestProxyAdapter();
        object.setupOid(new TestProxyOid(5));
        object.setupResolveState(ResolveState.GHOST);

        final IdentityData identityData = new DummyReferenceData();
        final ObjectData objectData = new DummyObjectData();
        final ResolveObjectRequest request = new ResolveObjectRequest(session, identityData);
View Full Code Here

    }

    @Test
    public void testClientSideActionWhereObjectChanged() throws Exception {

        final TestProxyAdapter directorAdapter = new TestProxyAdapter();
        directorAdapter.setupResolveState(ResolveState.RESOLVED);

        final TestProxyAdapter movieAdapter = new TestProxyAdapter();
        movieAdapter.setupResolveState(ResolveState.RESOLVED);

        mockery.checking(new Expectations() {
            {
                final DummyObjectData movieData = encoderShouldCreateGraphForChangedMovie(movieAdapter);
                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

TOP

Related Classes of org.apache.isis.runtimes.dflt.runtime.testsystem.TestProxyAdapter

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.