use of eu.bcvsolutions.idm.core.monitoring.api.dto.IdmMonitoringDto in project CzechIdMng by bcvsolutions.
the class DefaultMonitoringManagerIntegrationTest method testRegisterMonitoringEvaluatorWithCheckPeriod.
@Test
public void testRegisterMonitoringEvaluatorWithCheckPeriod() {
IdmMonitoringDto monitoring = new IdmMonitoringDto();
// ~ hour
monitoring.setCheckPeriod(3600L);
monitoring.setEvaluatorType(AutowireHelper.getTargetType(h2DatabaseMonitoringEvaluator));
monitoring.setInstanceId(configurationService.getInstanceId());
monitoring = monitoringService.save(monitoring);
try {
//
manager.scheduleExecute();
manager.scheduleExecute();
manager.scheduleExecute();
//
IdmMonitoringResultFilter filter = new IdmMonitoringResultFilter();
filter.setMonitoring(monitoring.getId());
//
List<IdmMonitoringResultDto> results = monitoringResultService.find(filter, null).getContent();
// executed only once => 0 check period
Assert.assertEquals(1, results.size());
//
List<IdmMonitoringResultDto> lastResults = manager.getLastResults(filter, null).getContent();
//
Assert.assertEquals(1, lastResults.size());
Assert.assertEquals(results.get(0).getId(), lastResults.get(0).getId());
//
manager.init();
//
lastResults = manager.getLastResults(filter, null).getContent();
//
Assert.assertEquals(1, lastResults.size());
Assert.assertEquals(results.get(0).getId(), lastResults.get(0).getId());
//
// evict and load cache again
cacheManager.evictCache(MonitoringManager.LAST_RESULT_CACHE_NAME);
lastResults = manager.getLastResults(filter, null).getContent();
//
Assert.assertEquals(1, lastResults.size());
Assert.assertEquals(results.get(0).getId(), lastResults.get(0).getId());
} finally {
monitoringService.delete(monitoring);
}
}
use of eu.bcvsolutions.idm.core.monitoring.api.dto.IdmMonitoringDto in project CzechIdMng by bcvsolutions.
the class EntityEventMonitoringEvaluatorUnitTest method testOk.
@Test
public void testOk() {
Mockito.when(entityEventService.count(ArgumentMatchers.any())).thenReturn(0L);
//
IdmMonitoringDto monitoring = new IdmMonitoringDto();
monitoring.setInstanceId("mock");
monitoring.getEvaluatorProperties().put(AbstractDailyMonitoringEvaluator.PARAMETER_NUMBER_OF_DAYS, 2);
IdmMonitoringResultDto result = evaluator.evaluate(monitoring);
//
Assert.assertEquals(CoreResultCode.OK.getCode(), result.getResult().getCode());
}
use of eu.bcvsolutions.idm.core.monitoring.api.dto.IdmMonitoringDto in project CzechIdMng by bcvsolutions.
the class MonitoringRunBulkActionIntegrationTest method testRun.
@Test
public void testRun() {
IdmMonitoringDto monitoring = createDto();
IdmBulkActionDto bulkAction = findBulkAction(IdmMonitoring.class, MonitoringRunBulkAction.NAME);
Set<UUID> ids = Sets.newHashSet(monitoring.getId());
bulkAction.setIdentifiers(ids);
IdmBulkActionDto processAction = bulkActionManager.processAction(bulkAction);
checkResultLrt(processAction, 1l, null, null);
service.delete(monitoring);
}
use of eu.bcvsolutions.idm.core.monitoring.api.dto.IdmMonitoringDto in project CzechIdMng by bcvsolutions.
the class MonitoringRunBulkActionIntegrationTest method createDto.
protected IdmMonitoringDto createDto() {
IdmMonitoringDto monitoring = new IdmMonitoringDto();
monitoring.setCheckPeriod(0L);
monitoring.setEvaluatorType(AutowireHelper.getTargetType(h2DatabaseMonitoringEvaluator));
monitoring.setInstanceId(configurationService.getInstanceId());
//
return service.save(monitoring);
}
use of eu.bcvsolutions.idm.core.monitoring.api.dto.IdmMonitoringDto in project CzechIdMng by bcvsolutions.
the class InitMonitoringProcessor method initEntityEventMonitoring.
protected IdmMonitoringDto initEntityEventMonitoring() {
String evaluatorType = AutowireHelper.getTargetType(entityEventMonitoringEvaluator);
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(EntityEventMonitoringEvaluator.PARAMETER_NUMBER_OF_DAYS, EntityEventMonitoringEvaluator.DEFAULT_NUMBER_OF_DAYS);
monitoring.setEvaluatorProperties(evaluatorProperties);
//
monitoring = monitoringService.save(monitoring);
LOG.info("Entity event monitoring configured automatically.");
}
//
return monitoring;
}
Aggregations