use of eu.bcvsolutions.idm.core.monitoring.api.event.MonitoringEvent in project CzechIdMng by bcvsolutions.
the class DefaultMonitoringManagerIntegrationTest method testExecuteMonitoringAfterSave.
@Test
@Transactional
public void testExecuteMonitoringAfterSave() {
IdmMonitoringDto monitoring = new IdmMonitoringDto();
monitoring.setCheckPeriod(0L);
monitoring.setEvaluatorType(AutowireHelper.getTargetType(h2DatabaseMonitoringEvaluator));
monitoring.setInstanceId(configurationService.getInstanceId());
monitoring.setDisabled(false);
//
MonitoringEvent event = new MonitoringEvent(MonitoringEventType.CREATE, monitoring);
event.setPriority(PriorityType.HIGH);
monitoring = monitoringService.publish(event).getContent();
try {
IdmMonitoringResultFilter filter = new IdmMonitoringResultFilter();
filter.setMonitoring(monitoring.getId());
List<IdmMonitoringResultDto> results = monitoringResultService.find(filter, null).getContent();
Assert.assertFalse(results.isEmpty());
} finally {
monitoringService.delete(monitoring);
}
}
use of eu.bcvsolutions.idm.core.monitoring.api.event.MonitoringEvent in project CzechIdMng by bcvsolutions.
the class DefaultMonitoringManager method execute.
@Override
public IdmMonitoringResultDto execute(IdmMonitoringDto monitoring, BasePermission... permission) {
Assert.notNull(monitoring, "Monitoring is required.");
//
EventContext<IdmMonitoringDto> context = monitoringService.publish(new MonitoringEvent(MonitoringEventType.EXECUTE, monitoring), permission);
// with result
for (EventResult<IdmMonitoringDto> eventResult : context.getResults()) {
for (OperationResult operationResult : eventResult.getResults()) {
ResultModel model = operationResult.getModel();
if (model != null && CoreResultCode.MONITORING_RESULT.getCode().equals(model.getStatusEnum()) && model.getParameters().containsKey(EventResult.EVENT_PROPERTY_RESULT)) {
return (IdmMonitoringResultDto) model.getParameters().get(EventResult.EVENT_PROPERTY_RESULT);
}
}
}
// without result (just for sure - e.g. wrong exception handling in custom monitoring evaluator)
return null;
}
Aggregations