Search in sources :

Example 61 with IdmMonitoringDto

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);
    }
}
Also used : IdmMonitoringDto(eu.bcvsolutions.idm.core.monitoring.api.dto.IdmMonitoringDto) IdmMonitoringResultFilter(eu.bcvsolutions.idm.core.monitoring.api.dto.filter.IdmMonitoringResultFilter) IdmMonitoringResultDto(eu.bcvsolutions.idm.core.monitoring.api.dto.IdmMonitoringResultDto) Test(org.junit.Test) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)

Example 62 with IdmMonitoringDto

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

Example 63 with IdmMonitoringDto

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);
}
Also used : IdmMonitoringDto(eu.bcvsolutions.idm.core.monitoring.api.dto.IdmMonitoringDto) IdmBulkActionDto(eu.bcvsolutions.idm.core.api.bulk.action.dto.IdmBulkActionDto) UUID(java.util.UUID) AbstractBulkActionTest(eu.bcvsolutions.idm.test.api.AbstractBulkActionTest) Test(org.junit.Test)

Example 64 with IdmMonitoringDto

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

Example 65 with IdmMonitoringDto

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

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