Search in sources :

Example 1 with ModuleService

use of org.alfresco.service.cmr.module.ModuleService in project alfresco-repository by Alfresco.

the class ConfigurationDataCollectorTest method setUp.

@Before
public void setUp() {
    smartFoldersBundle = mock(SpringExtensionBundle.class);
    mockDescriptorDAO = mock(DescriptorDAO.class);
    mockServerDescriptorDAO = mock(DescriptorDAO.class);
    mockCollectorService = mock(HBDataCollectorService.class);
    mockScheduler = mock(HeartBeatJobScheduler.class);
    Descriptor mockDescriptor = mock(Descriptor.class);
    when(mockDescriptor.getId()).thenReturn("mock_id");
    when(mockServerDescriptorDAO.getDescriptor()).thenReturn(mockDescriptor);
    when(mockDescriptorDAO.getDescriptor()).thenReturn(mockDescriptor);
    BasicDataSource mockBasicDataSource = mock(BasicDataSource.class);
    RepoUsageComponent mockRepoUsageComponent = mock(RepoUsageComponent.class);
    ServerModeProvider mockServerModeProvider = mock(ServerModeProvider.class);
    when(mockServerModeProvider.getServerMode()).thenReturn(SERVER_MODE);
    ChildApplicationContextFactory mockFileServerSubsystem = mock(ChildApplicationContextFactory.class);
    WebDavService mockWebDavService = mock(WebDavService.class);
    ThumbnailService mockThumbnailService = mock(ThumbnailService.class);
    ChildApplicationContextFactory mockActivitiesFeedSubsystem = mock(ChildApplicationContextFactory.class);
    WorkflowAdminService mockWorkflowAdminService = mock(WorkflowAdminService.class);
    ChildApplicationContextFactory mockInboundSMTPSubsystem = mock(ChildApplicationContextFactory.class);
    ChildApplicationContextFactory mockImapSubsystem = mock(ChildApplicationContextFactory.class);
    ChildApplicationContextFactory mockReplication = mock(ChildApplicationContextFactory.class);
    // mock modules and module service
    ModuleService mockModuleService = mock(ModuleService.class);
    ModuleDetails mockInstalledModule1 = mock(ModuleDetails.class);
    when(mockInstalledModule1.getId()).thenReturn(INSTALLED_MODULE_ID_1);
    when(mockInstalledModule1.getModuleVersionNumber()).thenReturn(INSTALLED_MODULE_VERSION_1);
    ModuleDetails mockInstalledModule2 = mock(ModuleDetails.class);
    when(mockInstalledModule2.getId()).thenReturn(INSTALLED_MODULE_ID_2);
    when(mockInstalledModule2.getModuleVersionNumber()).thenReturn(INSTALLED_MODULE_VERSION_2);
    ModuleDetails mockMissingModule = mock(ModuleDetails.class);
    when(mockMissingModule.getId()).thenReturn(MISSING_MODULE_ID_1);
    when(mockMissingModule.getModuleVersionNumber()).thenReturn(MISSING_MODULE_VERSION_1);
    when(mockModuleService.getAllModules()).thenReturn(Arrays.asList(mockInstalledModule1, mockInstalledModule2));
    when(mockModuleService.getMissingModules()).thenReturn(Arrays.asList(mockMissingModule));
    // mock audit applications and audit service
    AuditService mockAuditService = mock(AuditService.class);
    AuditService.AuditApplication mockAuditApp = mock(AuditService.AuditApplication.class);
    when(mockAuditApp.isEnabled()).thenReturn(AUDIT_APP_ENABLED);
    Map<String, AuditService.AuditApplication> auditApps = new HashMap<>();
    auditApps.put(AUDIT_APP_NAME, mockAuditApp);
    TransactionService mockTransactionService = mock(TransactionService.class);
    RetryingTransactionHelper mockRetryingTransactionHelper = mock(RetryingTransactionHelper.class);
    // Mock transaction service calls
    when(mockRetryingTransactionHelper.doInTransaction(any(RetryingTransactionHelper.RetryingTransactionCallback.class), anyBoolean())).thenReturn(// First call made by the collector to get the server readOnly value via transformation service
    true).thenReturn(// Second call to get the audit applications
    auditApps);
    when(mockTransactionService.getRetryingTransactionHelper()).thenReturn(mockRetryingTransactionHelper);
    // mock authentication chain
    DefaultChildApplicationContextManager mockAuthenticationSubsystem = mock(DefaultChildApplicationContextManager.class);
    configurationCollector = new ConfigurationDataCollector("acs.repository.configuration", "1.0", "0 0 0 ? * SUN", mockScheduler);
    configurationCollector.setHbDataCollectorService(mockCollectorService);
    configurationCollector.setCurrentRepoDescriptorDAO(mockDescriptorDAO);
    configurationCollector.setSmartFoldersBundle(smartFoldersBundle);
    configurationCollector.setDataSource(mockBasicDataSource);
    configurationCollector.setTransactionService(mockTransactionService);
    configurationCollector.setRepoUsageComponent(mockRepoUsageComponent);
    configurationCollector.setServerModeProvider(mockServerModeProvider);
    configurationCollector.setFileServersSubsystem(mockFileServerSubsystem);
    configurationCollector.setWebdavService(mockWebDavService);
    configurationCollector.setThumbnailService(mockThumbnailService);
    configurationCollector.setActivitiesFeedSubsystem(mockActivitiesFeedSubsystem);
    configurationCollector.setWorkflowAdminService(mockWorkflowAdminService);
    configurationCollector.setInboundSMTPSubsystem(mockInboundSMTPSubsystem);
    configurationCollector.setImapSubsystem(mockImapSubsystem);
    configurationCollector.setReplicationSubsystem(mockReplication);
    configurationCollector.setModuleService(mockModuleService);
    configurationCollector.setAuditService(mockAuditService);
    configurationCollector.setAuthenticationSubsystem(mockAuthenticationSubsystem);
    collectedData = configurationCollector.collectData();
}
Also used : ModuleService(org.alfresco.service.cmr.module.ModuleService) ThumbnailService(org.alfresco.service.cmr.thumbnail.ThumbnailService) TransactionService(org.alfresco.service.transaction.TransactionService) HashMap(java.util.HashMap) RetryingTransactionHelper(org.alfresco.repo.transaction.RetryingTransactionHelper) DefaultChildApplicationContextManager(org.alfresco.repo.management.subsystems.DefaultChildApplicationContextManager) SpringExtensionBundle(org.alfresco.traitextender.SpringExtensionBundle) ModuleDetails(org.alfresco.service.cmr.module.ModuleDetails) ChildApplicationContextFactory(org.alfresco.repo.management.subsystems.ChildApplicationContextFactory) RepoUsageComponent(org.alfresco.repo.usage.RepoUsageComponent) WebDavService(org.alfresco.service.cmr.webdav.WebDavService) HeartBeatJobScheduler(org.alfresco.heartbeat.jobs.HeartBeatJobScheduler) HBDataCollectorService(org.alfresco.service.cmr.repository.HBDataCollectorService) WorkflowAdminService(org.alfresco.service.cmr.workflow.WorkflowAdminService) Descriptor(org.alfresco.service.descriptor.Descriptor) DescriptorDAO(org.alfresco.repo.descriptor.DescriptorDAO) BasicDataSource(org.apache.commons.dbcp.BasicDataSource) AuditService(org.alfresco.service.cmr.audit.AuditService) ServerModeProvider(org.alfresco.repo.mode.ServerModeProvider) Before(org.junit.Before)

Aggregations

HashMap (java.util.HashMap)1 HeartBeatJobScheduler (org.alfresco.heartbeat.jobs.HeartBeatJobScheduler)1 DescriptorDAO (org.alfresco.repo.descriptor.DescriptorDAO)1 ChildApplicationContextFactory (org.alfresco.repo.management.subsystems.ChildApplicationContextFactory)1 DefaultChildApplicationContextManager (org.alfresco.repo.management.subsystems.DefaultChildApplicationContextManager)1 ServerModeProvider (org.alfresco.repo.mode.ServerModeProvider)1 RetryingTransactionHelper (org.alfresco.repo.transaction.RetryingTransactionHelper)1 RepoUsageComponent (org.alfresco.repo.usage.RepoUsageComponent)1 AuditService (org.alfresco.service.cmr.audit.AuditService)1 ModuleDetails (org.alfresco.service.cmr.module.ModuleDetails)1 ModuleService (org.alfresco.service.cmr.module.ModuleService)1 HBDataCollectorService (org.alfresco.service.cmr.repository.HBDataCollectorService)1 ThumbnailService (org.alfresco.service.cmr.thumbnail.ThumbnailService)1 WebDavService (org.alfresco.service.cmr.webdav.WebDavService)1 WorkflowAdminService (org.alfresco.service.cmr.workflow.WorkflowAdminService)1 Descriptor (org.alfresco.service.descriptor.Descriptor)1 TransactionService (org.alfresco.service.transaction.TransactionService)1 SpringExtensionBundle (org.alfresco.traitextender.SpringExtensionBundle)1 BasicDataSource (org.apache.commons.dbcp.BasicDataSource)1 Before (org.junit.Before)1