Search in sources :

Example 36 with IdmMonitoringDto

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);
}
Also used : MonitoringManager(eu.bcvsolutions.idm.core.monitoring.api.service.MonitoringManager) IdmMonitoringDto(eu.bcvsolutions.idm.core.monitoring.api.dto.IdmMonitoringDto) IdmMonitoringService(eu.bcvsolutions.idm.core.monitoring.api.service.IdmMonitoringService) RptMonitoringResultDto(eu.bcvsolutions.idm.rpt.dto.RptMonitoringResultDto) AttachmentManager(eu.bcvsolutions.idm.core.ecm.api.service.AttachmentManager) H2DatabaseMonitoringEvaluator(eu.bcvsolutions.idm.core.monitoring.service.impl.H2DatabaseMonitoringEvaluator) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Autowired(org.springframework.beans.factory.annotation.Autowired) IOException(java.io.IOException) Test(org.junit.Test) UUID(java.util.UUID) ConfigurationService(eu.bcvsolutions.idm.core.api.service.ConfigurationService) RptReportDto(eu.bcvsolutions.idm.rpt.api.dto.RptReportDto) AutowireHelper(eu.bcvsolutions.idm.core.api.utils.AutowireHelper) List(java.util.List) After(org.junit.After) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Assert(org.junit.Assert) TypeReference(com.fasterxml.jackson.core.type.TypeReference) Before(org.junit.Before) Transactional(org.springframework.transaction.annotation.Transactional) IdmMonitoringDto(eu.bcvsolutions.idm.core.monitoring.api.dto.IdmMonitoringDto) RptMonitoringResultDto(eu.bcvsolutions.idm.rpt.dto.RptMonitoringResultDto) List(java.util.List) RptReportDto(eu.bcvsolutions.idm.rpt.api.dto.RptReportDto) Test(org.junit.Test) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Transactional(org.springframework.transaction.annotation.Transactional)

Example 37 with IdmMonitoringDto

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;
}
Also used : IdmMonitoringDto(eu.bcvsolutions.idm.core.monitoring.api.dto.IdmMonitoringDto) ConfigurationMap(eu.bcvsolutions.idm.core.api.domain.ConfigurationMap)

Example 38 with IdmMonitoringDto

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);
}
Also used : IdmMonitoringDto(eu.bcvsolutions.idm.core.monitoring.api.dto.IdmMonitoringDto)

Example 39 with IdmMonitoringDto

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);
}
Also used : AbstractSysSyncConfigDto(eu.bcvsolutions.idm.acc.dto.AbstractSysSyncConfigDto) IdmMonitoringDto(eu.bcvsolutions.idm.core.monitoring.api.dto.IdmMonitoringDto) DefaultEventResult(eu.bcvsolutions.idm.core.api.event.DefaultEventResult) UUID(java.util.UUID)

Example 40 with IdmMonitoringDto

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());
}
Also used : IdmMonitoringDto(eu.bcvsolutions.idm.core.monitoring.api.dto.IdmMonitoringDto) SysSystemMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto) SysSyncConfigDto(eu.bcvsolutions.idm.acc.dto.SysSyncConfigDto) SysSchemaObjectClassDto(eu.bcvsolutions.idm.acc.dto.SysSchemaObjectClassDto) UUID(java.util.UUID) SysSyncConfigFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSyncConfigFilter) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) IdmMonitoringResultDto(eu.bcvsolutions.idm.core.monitoring.api.dto.IdmMonitoringResultDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Aggregations

IdmMonitoringDto (eu.bcvsolutions.idm.core.monitoring.api.dto.IdmMonitoringDto)73 Test (org.junit.Test)46 IdmMonitoringResultDto (eu.bcvsolutions.idm.core.monitoring.api.dto.IdmMonitoringResultDto)45 AbstractUnitTest (eu.bcvsolutions.idm.test.api.AbstractUnitTest)24 AbstractIntegrationTest (eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)16 UUID (java.util.UUID)13 IdmMonitoringResultFilter (eu.bcvsolutions.idm.core.monitoring.api.dto.filter.IdmMonitoringResultFilter)10 SysSystemDto (eu.bcvsolutions.idm.acc.dto.SysSystemDto)6 SysSystemMappingDto (eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto)6 SysSyncConfigFilter (eu.bcvsolutions.idm.acc.dto.filter.SysSyncConfigFilter)6 IdmIdentityDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto)6 SysSchemaObjectClassDto (eu.bcvsolutions.idm.acc.dto.SysSchemaObjectClassDto)5 SysSyncConfigDto (eu.bcvsolutions.idm.acc.dto.SysSyncConfigDto)5 ConfigurationMap (eu.bcvsolutions.idm.core.api.domain.ConfigurationMap)5 OperationResultDto (eu.bcvsolutions.idm.core.api.dto.OperationResultDto)5 AbstractReadWriteDtoControllerRestTest (eu.bcvsolutions.idm.core.api.rest.AbstractReadWriteDtoControllerRestTest)5 IdmMonitoringFilter (eu.bcvsolutions.idm.core.monitoring.api.dto.filter.IdmMonitoringFilter)5 DefaultEventResult (eu.bcvsolutions.idm.core.api.event.DefaultEventResult)4 AutowireHelper (eu.bcvsolutions.idm.core.api.utils.AutowireHelper)4 IdmMonitoringService (eu.bcvsolutions.idm.core.monitoring.api.service.IdmMonitoringService)4