Search in sources :

Example 6 with Repository

use of org.alfresco.repo.model.Repository in project alfresco-repository by Alfresco.

the class InviteSenderTest method mockRepository.

/**
 * Mocks up a Repository that will return the inviter as the current user.
 *
 * @return Repository
 */
private Repository mockRepository() {
    Repository repository = mock(Repository.class);
    when(repository.getPerson()).thenReturn(inviter.node);
    return repository;
}
Also used : Repository(org.alfresco.repo.model.Repository)

Example 7 with Repository

use of org.alfresco.repo.model.Repository in project alfresco-repository by Alfresco.

the class InviteModeratedSenderTest method setUp.

@Override
protected void setUp() throws Exception {
    super.setUp();
    ServiceRegistry services = mockServices();
    Repository repository = mockRepository();
    inviteModeratedSender = new InviteModeratedSender(services, repository, messageService);
}
Also used : Repository(org.alfresco.repo.model.Repository) ServiceRegistry(org.alfresco.service.ServiceRegistry)

Example 8 with Repository

use of org.alfresco.repo.model.Repository in project alfresco-repository by Alfresco.

the class AbstractActivitiComponentTest method setUp.

@Before
public void setUp() throws Exception {
    mockNamespaceService();
    mockDictionaryService();
    mockNodeService();
    mockSearchService();
    mockPermissionService();
    mockPersonService();
    mockAuthorityDAO();
    mockServiceRegistry();
    Repository repoHelper = mock(Repository.class);
    when(repoHelper.getCompanyHome()).thenReturn(companyHomeNode);
    workflowEngine.setRepositoryHelper(repoHelper);
    // Also add custom type
    // TODO: Should come from configuration
    ScriptNodeVariableType variableType = new ScriptNodeVariableType();
    variableType.setServiceRegistry(serviceRegistry);
    // ((ProcessEngineImpl)processEngine).getProcessEngineConfiguration().getVariableTypes().addType(variableType, 1);
    // Use util to set current user to admin
    AuthenticationUtil.setFullyAuthenticatedUser("admin");
    workflowEngine.afterPropertiesSet();
}
Also used : Repository(org.alfresco.repo.model.Repository) ScriptNodeVariableType(org.alfresco.repo.workflow.activiti.variable.ScriptNodeVariableType) Before(org.junit.Before)

Example 9 with Repository

use of org.alfresco.repo.model.Repository in project alfresco-remote-api by Alfresco.

the class TestEnterpriseAtomPubTCK method setup.

@Before
public void setup() throws Exception {
    JettyComponent jetty = getTestFixture().getJettyComponent();
    final SearchService searchService = (SearchService) jetty.getApplicationContext().getBean("searchService");
    ;
    final NodeService nodeService = (NodeService) jetty.getApplicationContext().getBean("nodeService");
    final FileFolderService fileFolderService = (FileFolderService) jetty.getApplicationContext().getBean("fileFolderService");
    final NamespaceService namespaceService = (NamespaceService) jetty.getApplicationContext().getBean("namespaceService");
    final TransactionService transactionService = (TransactionService) jetty.getApplicationContext().getBean("transactionService");
    final String name = "abc" + System.currentTimeMillis();
    transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback<Void>() {

        @Override
        public Void execute() throws Throwable {
            AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getAdminUserName());
            Repository repositoryHelper = (Repository) jetty.getApplicationContext().getBean("repositoryHelper");
            NodeRef companyHome = repositoryHelper.getCompanyHome();
            fileFolderService.create(companyHome, name, ContentModel.TYPE_FOLDER).getNodeRef();
            return null;
        }
    }, false, true);
    int port = jetty.getPort();
    Map<String, String> cmisParameters = new HashMap<String, String>();
    cmisParameters.put(TestParameters.DEFAULT_RELATIONSHIP_TYPE, "R:cm:replaces");
    cmisParameters.put(TestParameters.DEFAULT_TEST_FOLDER_PARENT, "/" + name);
    clientContext = new OpenCMISClientContext(BindingType.ATOMPUB, MessageFormat.format(CMIS_URL, "localhost", String.valueOf(port), "alfresco"), "admin", "admin", cmisParameters, jetty.getApplicationContext());
    overrideVersionableAspectProperties(jetty.getApplicationContext());
}
Also used : TransactionService(org.alfresco.service.transaction.TransactionService) HashMap(java.util.HashMap) NodeService(org.alfresco.service.cmr.repository.NodeService) FileFolderService(org.alfresco.service.cmr.model.FileFolderService) NodeRef(org.alfresco.service.cmr.repository.NodeRef) Repository(org.alfresco.repo.model.Repository) NamespaceService(org.alfresco.service.namespace.NamespaceService) SearchService(org.alfresco.service.cmr.search.SearchService) JettyComponent(org.alfresco.repo.web.util.JettyComponent) OpenCMISClientContext(org.alfresco.opencmis.OpenCMISClientContext) Before(org.junit.Before)

Example 10 with Repository

use of org.alfresco.repo.model.Repository in project alfresco-remote-api by Alfresco.

the class ContentGetTest method testRelativePath.

/**
 * MNT-16380
 */
public void testRelativePath() throws Exception {
    Repository repositoryHelper = (Repository) getServer().getApplicationContext().getBean("repositoryHelper");
    NodeRef companyHome = repositoryHelper.getCompanyHome();
    rootFolder = createNode(companyHome, "rootFolder", ContentModel.TYPE_FOLDER);
    NodeRef doc1 = createNodeWithTextContent(rootFolder, "doc1", ContentModel.TYPE_CONTENT, "doc1 file content");
    NodeRef folderX = createNode(rootFolder, "X", ContentModel.TYPE_FOLDER);
    NodeRef folderY = createNode(folderX, "Y", ContentModel.TYPE_FOLDER);
    NodeRef folderZ = createNode(folderY, "Z", ContentModel.TYPE_FOLDER);
    NodeRef doc2 = createNodeWithTextContent(folderZ, "doc2", ContentModel.TYPE_CONTENT, "doc2 file content");
    // uri with relative path at the end
    String uri = URL_CONTENT_DOWNLOAD + doc1.getId() + "/X/Y/Z/doc2";
    Response resp = sendRequest(new GetRequest(uri), 200);
    // check if we really have doc2 as target
    Assert.assertEquals("doc2 file content", resp.getContentAsString());
}
Also used : Response(org.springframework.extensions.webscripts.TestWebScriptServer.Response) Repository(org.alfresco.repo.model.Repository) GetRequest(org.springframework.extensions.webscripts.TestWebScriptServer.GetRequest)

Aggregations

Repository (org.alfresco.repo.model.Repository)24 NodeRef (org.alfresco.service.cmr.repository.NodeRef)10 Before (org.junit.Before)6 Test (org.junit.Test)6 ActivitiScriptNode (org.alfresco.repo.workflow.activiti.ActivitiScriptNode)5 NodeService (org.alfresco.service.cmr.repository.NodeService)4 BeforeClass (org.junit.BeforeClass)4 RetryingTransactionHelper (org.alfresco.repo.transaction.RetryingTransactionHelper)3 ServiceRegistry (org.alfresco.service.ServiceRegistry)3 ContentService (org.alfresco.service.cmr.repository.ContentService)3 PersonService (org.alfresco.service.cmr.security.PersonService)3 QName (org.alfresco.service.namespace.QName)3 ScriptContentData (org.alfresco.repo.jscript.ScriptNode.ScriptContentData)2 AuthenticationComponent (org.alfresco.repo.security.authentication.AuthenticationComponent)2 AccessDeniedException (org.alfresco.repo.security.permissions.AccessDeniedException)2 ScriptException (org.alfresco.scripts.ScriptException)2 FileFolderService (org.alfresco.service.cmr.model.FileFolderService)2 ContentData (org.alfresco.service.cmr.repository.ContentData)2 MutableAuthenticationService (org.alfresco.service.cmr.security.MutableAuthenticationService)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1