use of eu.bcvsolutions.idm.core.monitoring.api.dto.IdmMonitoringDto in project CzechIdMng by bcvsolutions.
the class MonitoringReportExecutorIntegrationTest method testExecutor.
@Test
@Transactional
public void testExecutor() throws IOException {
IdmMonitoringDto monitoring = new IdmMonitoringDto();
monitoring.setCheckPeriod(0L);
monitoring.setEvaluatorType(AutowireHelper.getTargetType(h2DatabaseMonitoringEvaluator));
monitoring.setInstanceId(configurationService.getInstanceId());
monitoring = monitoringService.save(monitoring);
monitoringManager.execute(monitoring);
//
// generate report
RptReportDto report = reportExecutor.generate(new RptReportDto(UUID.randomUUID()));
Assert.assertNotNull(report.getData());
List<RptMonitoringResultDto> results = mapper.readValue(attachmentManager.getAttachmentData(report.getData()), new TypeReference<List<RptMonitoringResultDto>>() {
});
//
// test
Assert.assertFalse(results.isEmpty());
Assert.assertTrue(results.stream().anyMatch(r -> r.getEvaluatorType().equals(AutowireHelper.getTargetType(h2DatabaseMonitoringEvaluator))));
//
attachmentManager.deleteAttachments(report);
}
use of eu.bcvsolutions.idm.core.monitoring.api.dto.IdmMonitoringDto in project CzechIdMng by bcvsolutions.
the class AccInitMonitoringProcessor method initProvisioningOperationMonitoring.
protected IdmMonitoringDto initProvisioningOperationMonitoring() {
String evaluatorType = AutowireHelper.getTargetType(provisioningOperationMonitoringEvaluator);
IdmMonitoringDto monitoring = findMonitoring(evaluatorType, null, null);
if (monitoring == null) {
monitoring = new IdmMonitoringDto();
monitoring.setEvaluatorType(evaluatorType);
monitoring.setInstanceId(configurationService.getInstanceId());
// ~ per hour
monitoring.setCheckPeriod(3600L);
// ~ quick
monitoring.setSeq((short) 0);
monitoring.setDescription(PRODUCT_PROVIDED_MONITORING_DESCRIPTION);
ConfigurationMap evaluatorProperties = new ConfigurationMap();
evaluatorProperties.put(ProvisioningOperationMonitoringEvaluator.PARAMETER_NUMBER_OF_DAYS, ProvisioningOperationMonitoringEvaluator.DEFAULT_NUMBER_OF_DAYS);
monitoring.setEvaluatorProperties(evaluatorProperties);
//
monitoring = monitoringService.save(monitoring);
LOG.info("Provisioning operation monitoring configured automatically.");
}
//
return monitoring;
}
use of eu.bcvsolutions.idm.core.monitoring.api.dto.IdmMonitoringDto in project CzechIdMng by bcvsolutions.
the class SyncConfigMonitoringAutoConfigurationProcessor method deleteMonitoring.
/**
* Delete configured monitoring evaluator for given synchronization configuration, if monitoring evaluator is configured.
*
* @param synchronizationId synchronization configuration identifier
*/
public void deleteMonitoring(UUID synchronizationId) {
IdmMonitoringDto monitoring = findMonitoring(synchronizationId);
if (monitoring == null) {
// nothing to remove
return;
}
//
monitoringService.delete(monitoring);
LOG.info("Monitoring [{}] deleted automatically for deteled synchronization configuration [{}]", monitoring.getId(), synchronizationId);
}
use of eu.bcvsolutions.idm.core.monitoring.api.dto.IdmMonitoringDto in project CzechIdMng by bcvsolutions.
the class SyncConfigMonitoringAutoConfigurationProcessor method process.
@Override
public EventResult<AbstractSysSyncConfigDto> process(EntityEvent<AbstractSysSyncConfigDto> event) {
UUID synchronizationId = event.getContent().getId();
Assert.notNull(synchronizationId, "Synchronization identifier is required.");
//
if (event.hasType(SyncConfigEventType.CREATE)) {
configureMonitoring(synchronizationId);
} else if (event.hasType(SyncConfigEventType.UPDATE)) {
// => HIGH priority from FE is reused as workaround for now.
if (event.hasPriority(PriorityType.HIGH)) {
AbstractSysSyncConfigDto syncConfig = event.getContent();
AbstractSysSyncConfigDto originalSource = event.getOriginalSource();
if (originalSource != null && originalSource.isEnabled() != syncConfig.isEnabled()) {
// execute monitoring, if is configured
IdmMonitoringDto monitoring = findMonitoring(synchronizationId);
if (monitoring != null) {
monitoringManager.execute(monitoring);
}
}
}
} else {
// delete
deleteMonitoring(synchronizationId);
}
//
return new DefaultEventResult<>(event, this);
}
use of eu.bcvsolutions.idm.core.monitoring.api.dto.IdmMonitoringDto in project CzechIdMng by bcvsolutions.
the class SynchronizationMonitoringEvaluatorIntegrationTest method testSynchronizationNotRun.
@Test
public void testSynchronizationNotRun() {
UUID syncId = UUID.randomUUID();
SysSyncConfigDto config = new SysSyncConfigDto();
config.setName("mock");
SysSystemMappingDto mapping = new SysSystemMappingDto();
config.getEmbedded().put(SysSyncConfig_.systemMapping.getName(), mapping);
SysSchemaObjectClassDto schema = new SysSchemaObjectClassDto();
schema.setSystem(syncId);
mapping.getEmbedded().put(SysSystemMapping_.objectClass.getName(), schema);
SysSystemDto system = new SysSystemDto(UUID.randomUUID());
system.setName("mock");
//
SysSyncConfigFilter context = new SysSyncConfigFilter();
context.setIncludeLastLog(Boolean.TRUE);
Mockito.when(syncConfigService.get(ArgumentMatchers.any(), (SysSyncConfigFilter) ArgumentMatchers.any())).thenReturn(config);
Mockito.when(systemService.get(syncId)).thenReturn(system);
//
IdmMonitoringDto monitoring = new IdmMonitoringDto();
monitoring.getEvaluatorProperties().put(SynchronizationMonitoringEvaluator.PARAMETER_SYNCHRONIZATION, syncId);
IdmMonitoringResultDto result = evaluator.evaluate(monitoring);
//
Assert.assertEquals(AccResultCode.MONITORING_SYNCHRONIZATION_NOT_EXECUTED.getCode(), result.getResult().getCode());
}
Aggregations