use of org.alfresco.repo.dictionary.CustomModelsInfo in project alfresco-repository by Alfresco.
the class ModelUsageDataCollectorTest method setUp.
@Before
public void setUp() {
mockDescriptorDAO = mock(DescriptorDAO.class);
mockCollectorService = mock(HBDataCollectorService.class);
mockScheduler = mock(HeartBeatJobScheduler.class);
Descriptor mockDescriptor = mock(Descriptor.class);
when(mockDescriptor.getId()).thenReturn("mock_id");
when(mockDescriptorDAO.getDescriptor()).thenReturn(mockDescriptor);
CustomModelsInfo mockCustomModelsInfo = mock(CustomModelsInfo.class);
CustomModelService customModelService = mock(CustomModelService.class);
when(customModelService.getCustomModelsInfo()).thenReturn(mockCustomModelsInfo);
TransactionService mockTransactionService = mock(TransactionService.class);
RetryingTransactionHelper mockRetryingTransactionHelper = mock(RetryingTransactionHelper.class);
when(mockRetryingTransactionHelper.doInTransaction(any(RetryingTransactionHelper.RetryingTransactionCallback.class), anyBoolean())).thenReturn(mockCustomModelsInfo);
when(mockTransactionService.getRetryingTransactionHelper()).thenReturn(mockRetryingTransactionHelper);
usageModelCollector = new ModelUsageDataCollector("acs.repository.usage.model", "1.0", "0 0 0 ? * *", mockScheduler);
usageModelCollector.setHbDataCollectorService(mockCollectorService);
usageModelCollector.setCurrentRepoDescriptorDAO(mockDescriptorDAO);
usageModelCollector.setCustomModelService(customModelService);
usageModelCollector.setTransactionService(mockTransactionService);
collectedData = usageModelCollector.collectData();
}
use of org.alfresco.repo.dictionary.CustomModelsInfo in project alfresco-repository by Alfresco.
the class ModelUsageDataCollector method collectData.
@Override
public List<HBData> collectData() {
logger.debug("Preparing repository usage (model) data...");
final CustomModelsInfo customModelsInfo = transactionService.getRetryingTransactionHelper().doInTransaction(() -> customModelService.getCustomModelsInfo(), true);
Map<String, Object> modelUsageValues = new HashMap<>();
modelUsageValues.put("numOfActiveModels", new Integer(customModelsInfo.getNumberOfActiveModels()));
modelUsageValues.put("numOfActiveTypes", new Integer(customModelsInfo.getNumberOfActiveTypes()));
modelUsageValues.put("numOfActiveAspects", new Integer(customModelsInfo.getNumberOfActiveAspects()));
HBData modelUsageData = new HBData(this.currentRepoDescriptorDAO.getDescriptor().getId(), this.getCollectorId(), this.getCollectorVersion(), new Date(), modelUsageValues);
return Arrays.asList(modelUsageData);
}
Aggregations