Search in sources :

Example 1 with MessageService

use of org.alfresco.repo.i18n.MessageService in project alfresco-repository by Alfresco.

the class DictionaryModelTypeTest method before.

@Before
public void before() throws Exception {
    TestTransaction.flagForCommit();
    this.nodeService = (NodeService) this.applicationContext.getBean("nodeService");
    this.contentService = (ContentService) this.applicationContext.getBean("contentService");
    this.authenticationService = (MutableAuthenticationService) this.applicationContext.getBean("authenticationService");
    this.actionService = (ActionService) this.applicationContext.getBean("actionService");
    this.transactionService = (TransactionService) this.applicationContext.getBean("transactionComponent");
    // Authenticate as the admin user for dictionaryModelType
    // "System" user should also be allowed to create models
    AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getAdminUserName());
    // Create the store and get the root node
    this.storeRef = this.nodeService.createStore(StoreRef.PROTOCOL_WORKSPACE, "Test_" + System.currentTimeMillis());
    this.rootNodeRef = this.nodeService.getRootNode(this.storeRef);
    // Get the required services
    this.dictionaryService = (DictionaryService) this.applicationContext.getBean("dictionaryService");
    this.namespaceService = (NamespaceService) this.applicationContext.getBean("namespaceService");
    this.cociService = (CheckOutCheckInService) this.applicationContext.getBean("checkOutCheckInService");
    this.dictionaryDAO = (DictionaryDAO) this.applicationContext.getBean("dictionaryDAO");
    this.nodeService = (NodeService) this.applicationContext.getBean("NodeService");
    this.policyComponent = (PolicyComponent) this.applicationContext.getBean("policyComponent");
    TenantAdminService tenantAdminService = (TenantAdminService) this.applicationContext.getBean("tenantAdminService");
    MessageService messageService = (MessageService) this.applicationContext.getBean("messageService");
    TestTransaction.end();
    TestTransaction.start();
    TestTransaction.flagForCommit();
    DictionaryRepositoryBootstrap bootstrap = new DictionaryRepositoryBootstrap();
    bootstrap.setContentService(this.contentService);
    bootstrap.setDictionaryDAO(this.dictionaryDAO);
    bootstrap.setTransactionService(this.transactionService);
    bootstrap.setTenantAdminService(tenantAdminService);
    bootstrap.setNodeService(this.nodeService);
    bootstrap.setNamespaceService(this.namespaceService);
    bootstrap.setMessageService(messageService);
    bootstrap.setPolicyComponent(policyComponent);
    RepositoryLocation location = new RepositoryLocation();
    location.setStoreProtocol(this.storeRef.getProtocol());
    location.setStoreId(this.storeRef.getIdentifier());
    location.setQueryLanguage(RepositoryLocation.LANGUAGE_PATH);
    // NOTE: we are not setting the path for now .. in doing so we are searching the root node only
    List<RepositoryLocation> locations = new ArrayList<RepositoryLocation>();
    locations.add(location);
    bootstrap.setRepositoryModelsLocations(locations);
    // register with dictionary service
    bootstrap.register();
    TestTransaction.end();
    TestTransaction.start();
}
Also used : TenantAdminService(org.alfresco.repo.tenant.TenantAdminService) ArrayList(java.util.ArrayList) MessageService(org.alfresco.repo.i18n.MessageService) Before(org.junit.Before)

Example 2 with MessageService

use of org.alfresco.repo.i18n.MessageService in project alfresco-repository by Alfresco.

the class ActivitiPriorityPropertyHandlerTest method setUp.

@BeforeClass
public static void setUp() {
    handler = new ActivitiPriorityPropertyHandler();
    MessageService messageService = mock(MessageService.class);
    handler.setMessageService(messageService);
}
Also used : MessageService(org.alfresco.repo.i18n.MessageService) BeforeClass(org.junit.BeforeClass)

Example 3 with MessageService

use of org.alfresco.repo.i18n.MessageService in project alfresco-repository by Alfresco.

the class WorklfowObjectFactoryTest method testTransitionDefaultLabel.

/**
 * Test to validate ALF-18332 (default description label key).
 */
public void testTransitionDefaultLabel() {
    MessageService mockedMessageService = Mockito.mock(MessageService.class);
    Mockito.when(mockedMessageService.getMessage(Mockito.anyString())).thenAnswer(new Answer<String>() {

        @Override
        public String answer(InvocationOnMock invocation) throws Throwable {
            String arg = (String) invocation.getArguments()[0];
            if ("base.key.title".equals(arg)) {
                return "The title";
            } else if ("base.key.description".equals(arg)) {
                return "The description";
            }
            return null;
        }
    });
    WorkflowObjectFactory factory = new WorkflowObjectFactory(null, null, mockedMessageService, null, ActivitiConstants.ENGINE_ID, null);
    WorkflowTransition createTransition = factory.createTransition("test-transition", "title", null, true, "base.key");
    assertNotNull(createTransition);
    assertEquals("The title", createTransition.getTitle());
    assertEquals("The description", createTransition.getDescription());
}
Also used : InvocationOnMock(org.mockito.invocation.InvocationOnMock) WorkflowTransition(org.alfresco.service.cmr.workflow.WorkflowTransition) MessageService(org.alfresco.repo.i18n.MessageService) WorkflowObjectFactory(org.alfresco.repo.workflow.WorkflowObjectFactory)

Aggregations

MessageService (org.alfresco.repo.i18n.MessageService)3 ArrayList (java.util.ArrayList)1 TenantAdminService (org.alfresco.repo.tenant.TenantAdminService)1 WorkflowObjectFactory (org.alfresco.repo.workflow.WorkflowObjectFactory)1 WorkflowTransition (org.alfresco.service.cmr.workflow.WorkflowTransition)1 Before (org.junit.Before)1 BeforeClass (org.junit.BeforeClass)1 InvocationOnMock (org.mockito.invocation.InvocationOnMock)1