Search in sources :

Example 1 with MockedTestServiceRegistry

use of org.alfresco.repo.rendition.MockedTestServiceRegistry in project alfresco-repository by Alfresco.

the class ThumbnailServiceImplParameterTest method initMockObjects.

@Before
public void initMockObjects() {
    renditionService = new RenditionServiceImpl() {

        @Override
        public RenditionDefinition loadRenditionDefinition(QName renditionDefinitionName) {
            // We're intentionally returning null for this test.
            return null;
        }
    };
    renditionService.setActionService(mockActionService);
    renditionService.setServiceRegistry(new MockedTestServiceRegistry());
    renditionService.setRenditionService2(mockRenditionService2);
    when(mockRenditionService2.isCreatedByRenditionService2(any(), any())).thenReturn(false);
    ThumbnailServiceImpl thumbs = new ThumbnailServiceImpl() {

        @Override
        public NodeRef getThumbnailByName(NodeRef node, QName contentProperty, String thumbnailName) {
            return null;
        }

        /**
         * In this test the thumbnailRef will be null, so we need to ensure
         * it is not dereferenced here.
         */
        @Override
        public NodeRef getThumbnailNode(ChildAssociationRef thumbnailRef) {
            return null;
        }
    };
    thumbs.setRenditionService(renditionService);
    thumbs.setThumbnailRegistry(new ThumbnailRegistry() {

        @Override
        public ThumbnailRenditionConvertor getThumbnailRenditionConvertor() {
            return new ThumbnailRenditionConvertor();
        }
    });
    thumbs.setNodeService(mock(NodeService.class));
    TransactionServiceImpl transactionServiceImpl = new TransactionServiceImpl() {

        @Override
        public boolean getAllowWrite() {
            return true;
        }

        @Override
        public boolean isReadOnly() {
            return false;
        }

        @Override
        public RetryingTransactionHelper getRetryingTransactionHelper() {
            RetryingTransactionHelper rth = new RetryingTransactionHelper() {

                @Override
                public <R> R doInTransaction(RetryingTransactionCallback<R> cb, boolean readOnly, boolean requiresNew) {
                    try {
                        return cb.execute();
                    } catch (Throwable e) {
                        e.printStackTrace();
                    }
                    return null;
                }
            };
            return rth;
        }
    };
    thumbs.setTransactionService(transactionServiceImpl);
    thumbnailService = thumbs;
}
Also used : RetryingTransactionHelper(org.alfresco.repo.transaction.RetryingTransactionHelper) QName(org.alfresco.service.namespace.QName) TransactionServiceImpl(org.alfresco.repo.transaction.TransactionServiceImpl) NodeService(org.alfresco.service.cmr.repository.NodeService) RenditionServiceImpl(org.alfresco.repo.rendition.RenditionServiceImpl) MockedTestServiceRegistry(org.alfresco.repo.rendition.MockedTestServiceRegistry) ChildAssociationRef(org.alfresco.service.cmr.repository.ChildAssociationRef) NodeRef(org.alfresco.service.cmr.repository.NodeRef) RenditionDefinition(org.alfresco.service.cmr.rendition.RenditionDefinition) Before(org.junit.Before)

Aggregations

MockedTestServiceRegistry (org.alfresco.repo.rendition.MockedTestServiceRegistry)1 RenditionServiceImpl (org.alfresco.repo.rendition.RenditionServiceImpl)1 RetryingTransactionHelper (org.alfresco.repo.transaction.RetryingTransactionHelper)1 TransactionServiceImpl (org.alfresco.repo.transaction.TransactionServiceImpl)1 RenditionDefinition (org.alfresco.service.cmr.rendition.RenditionDefinition)1 ChildAssociationRef (org.alfresco.service.cmr.repository.ChildAssociationRef)1 NodeRef (org.alfresco.service.cmr.repository.NodeRef)1 NodeService (org.alfresco.service.cmr.repository.NodeService)1 QName (org.alfresco.service.namespace.QName)1 Before (org.junit.Before)1