use of org.alfresco.repo.mode.ServerModeProvider 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();
}
Aggregations