Search in sources :

Example 6 with IdmMonitoringResultDto

use of eu.bcvsolutions.idm.core.monitoring.api.dto.IdmMonitoringResultDto in project CzechIdMng by bcvsolutions.

the class LongRunningTaskResultMonitoringEvaluator method evaluate.

@Override
public IdmMonitoringResultDto evaluate(IdmMonitoringDto monitoring) {
    IdmMonitoringResultDto result = new IdmMonitoringResultDto();
    ResultModel resultModel;
    // 
    IdmProcessedTaskItemFilter filter = new IdmProcessedTaskItemFilter();
    filter.setOperationState(OperationState.EXCEPTION);
    filter.setTaskMonitoringIgnored(false);
    Long givenNumberOfDays = getParameterConverter().toLong(monitoring.getEvaluatorProperties(), PARAMETER_NUMBER_OF_DAYS);
    if (givenNumberOfDays != null) {
        filter.setCreatedFrom(ZonedDateTime.now().truncatedTo(ChronoUnit.DAYS).minusDays(givenNumberOfDays));
    }
    long count = processedTaskItemService.count(filter);
    // 
    if (count > 0) {
        resultModel = new DefaultResultModel(CoreResultCode.MONITORING_LONG_RUNNING_TASK_ERROR, ImmutableMap.of("count", Long.toString(count)));
    } else {
        resultModel = new DefaultResultModel(CoreResultCode.OK);
    }
    // 
    result.setResult(new OperationResultDto.Builder(OperationState.EXECUTED).setModel(resultModel).build());
    result.setValue(String.valueOf(count));
    // 
    return result;
}
Also used : DefaultResultModel(eu.bcvsolutions.idm.core.api.dto.DefaultResultModel) OperationResultDto(eu.bcvsolutions.idm.core.api.dto.OperationResultDto) DefaultResultModel(eu.bcvsolutions.idm.core.api.dto.DefaultResultModel) ResultModel(eu.bcvsolutions.idm.core.api.dto.ResultModel) IdmProcessedTaskItemFilter(eu.bcvsolutions.idm.core.scheduler.api.dto.filter.IdmProcessedTaskItemFilter) IdmMonitoringResultDto(eu.bcvsolutions.idm.core.monitoring.api.dto.IdmMonitoringResultDto)

Example 7 with IdmMonitoringResultDto

use of eu.bcvsolutions.idm.core.monitoring.api.dto.IdmMonitoringResultDto in project CzechIdMng by bcvsolutions.

the class MonitoringResultRunBulkActionIntegrationTest method testRun.

@Test
public void testRun() {
    IdmMonitoringResultDto monitoringResult = createDto();
    IdmBulkActionDto bulkAction = findBulkAction(IdmMonitoringResult.class, MonitoringResultRunBulkAction.NAME);
    Set<UUID> ids = Sets.newHashSet(monitoringResult.getId());
    bulkAction.setIdentifiers(ids);
    IdmBulkActionDto processAction = bulkActionManager.processAction(bulkAction);
    checkResultLrt(processAction, 1l, null, null);
    monitoringService.deleteById(monitoringResult.getMonitoring());
}
Also used : IdmBulkActionDto(eu.bcvsolutions.idm.core.api.bulk.action.dto.IdmBulkActionDto) UUID(java.util.UUID) IdmMonitoringResultDto(eu.bcvsolutions.idm.core.monitoring.api.dto.IdmMonitoringResultDto) AbstractBulkActionTest(eu.bcvsolutions.idm.test.api.AbstractBulkActionTest) Test(org.junit.Test)

Example 8 with IdmMonitoringResultDto

use of eu.bcvsolutions.idm.core.monitoring.api.dto.IdmMonitoringResultDto in project CzechIdMng by bcvsolutions.

the class MonitoringResultRunBulkActionIntegrationTest method createDto.

protected IdmMonitoringResultDto createDto() {
    IdmMonitoringDto monitoring = new IdmMonitoringDto();
    monitoring.setCheckPeriod(0L);
    monitoring.setEvaluatorType(AutowireHelper.getTargetType(h2DatabaseMonitoringEvaluator));
    monitoring.setInstanceId(configurationService.getInstanceId());
    monitoring = monitoringService.save(monitoring);
    // 
    IdmMonitoringResultDto dto = new IdmMonitoringResultDto();
    dto.setMonitoring(monitoring.getId());
    dto.setEvaluatorType(AutowireHelper.getTargetType(h2DatabaseMonitoringEvaluator));
    dto.setInstanceId(configurationService.getInstanceId());
    dto.setResult(new OperationResultDto(OperationState.BLOCKED));
    // 
    return monitoringResultService.save(dto);
}
Also used : IdmMonitoringDto(eu.bcvsolutions.idm.core.monitoring.api.dto.IdmMonitoringDto) OperationResultDto(eu.bcvsolutions.idm.core.api.dto.OperationResultDto) IdmMonitoringResultDto(eu.bcvsolutions.idm.core.monitoring.api.dto.IdmMonitoringResultDto)

Example 9 with IdmMonitoringResultDto

use of eu.bcvsolutions.idm.core.monitoring.api.dto.IdmMonitoringResultDto in project CzechIdMng by bcvsolutions.

the class DatabaseTableMonitoringEvaluatorUnitTest method testWarning.

@Test
public void testWarning() {
    Mockito.when(context.getBean("mock")).thenReturn(identityService);
    Mockito.when(identityService.count(ArgumentMatchers.any())).thenReturn(DatabaseTableMonitoringEvaluator.DEFAULT_THRESHOLD + 1);
    Mockito.when(identityService.getEntityClass()).thenReturn(IdmIdentity.class);
    Mockito.when(identityService.getDtoClass()).thenReturn(IdmIdentityDto.class);
    // 
    IdmMonitoringDto monitoring = new IdmMonitoringDto();
    monitoring.setInstanceId("mock");
    monitoring.getEvaluatorProperties().put(DatabaseTableMonitoringEvaluator.PARAMETER_READ_SERVICE_BEAN_NAME, "mock");
    IdmMonitoringResultDto result = evaluator.evaluate(monitoring);
    // 
    Assert.assertEquals(CoreResultCode.MONITORING_DATABASE_TABLE.getCode(), result.getResult().getCode());
    Assert.assertEquals(NotificationLevel.WARNING, result.getLevel());
    Assert.assertEquals(String.valueOf(DatabaseTableMonitoringEvaluator.DEFAULT_THRESHOLD + 1), result.getValue());
}
Also used : IdmMonitoringDto(eu.bcvsolutions.idm.core.monitoring.api.dto.IdmMonitoringDto) IdmMonitoringResultDto(eu.bcvsolutions.idm.core.monitoring.api.dto.IdmMonitoringResultDto) Test(org.junit.Test) AbstractUnitTest(eu.bcvsolutions.idm.test.api.AbstractUnitTest)

Example 10 with IdmMonitoringResultDto

use of eu.bcvsolutions.idm.core.monitoring.api.dto.IdmMonitoringResultDto in project CzechIdMng by bcvsolutions.

the class DemoAdminMonitoringEvaluatorUnitTest method testProductionWithDemoAdmin.

@Test
public void testProductionWithDemoAdmin() {
    Mockito.when(applicationConfiguration.isDevelopment()).thenReturn(false);
    Mockito.when(lookupService.lookupDto(IdmIdentityDto.class, InitAdminIdentityProcessor.ADMIN_USERNAME)).thenReturn(new IdmIdentityDto(InitAdminIdentityProcessor.ADMIN_USERNAME));
    Mockito.when(authenticationManager.validate(ArgumentMatchers.any())).thenReturn(true);
    // 
    IdmMonitoringDto monitoring = new IdmMonitoringDto();
    monitoring.setInstanceId("mock");
    IdmMonitoringResultDto result = evaluator.evaluate(monitoring);
    // 
    Assert.assertEquals(CoreResultCode.MONITORING_DEMO_ADMIN_WARNING.getCode(), result.getResult().getCode());
    Assert.assertEquals(NotificationLevel.ERROR, result.getLevel());
}
Also used : IdmMonitoringDto(eu.bcvsolutions.idm.core.monitoring.api.dto.IdmMonitoringDto) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) IdmMonitoringResultDto(eu.bcvsolutions.idm.core.monitoring.api.dto.IdmMonitoringResultDto) Test(org.junit.Test) AbstractUnitTest(eu.bcvsolutions.idm.test.api.AbstractUnitTest)

Aggregations

IdmMonitoringResultDto (eu.bcvsolutions.idm.core.monitoring.api.dto.IdmMonitoringResultDto)63 IdmMonitoringDto (eu.bcvsolutions.idm.core.monitoring.api.dto.IdmMonitoringDto)47 Test (org.junit.Test)39 AbstractUnitTest (eu.bcvsolutions.idm.test.api.AbstractUnitTest)21 OperationResultDto (eu.bcvsolutions.idm.core.api.dto.OperationResultDto)18 IdmMonitoringResultFilter (eu.bcvsolutions.idm.core.monitoring.api.dto.filter.IdmMonitoringResultFilter)13 UUID (java.util.UUID)13 ResultModel (eu.bcvsolutions.idm.core.api.dto.ResultModel)12 AbstractIntegrationTest (eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)12 DefaultResultModel (eu.bcvsolutions.idm.core.api.dto.DefaultResultModel)10 IdmIdentityDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto)7 SysSchemaObjectClassDto (eu.bcvsolutions.idm.acc.dto.SysSchemaObjectClassDto)6 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 SysSyncConfigDto (eu.bcvsolutions.idm.acc.dto.SysSyncConfigDto)5 AbstractReadWriteDtoControllerRestTest (eu.bcvsolutions.idm.core.api.rest.AbstractReadWriteDtoControllerRestTest)5 GuardedString (eu.bcvsolutions.idm.core.security.api.domain.GuardedString)5 SysSyncActionLogDto (eu.bcvsolutions.idm.acc.dto.SysSyncActionLogDto)4 SysSyncLogDto (eu.bcvsolutions.idm.acc.dto.SysSyncLogDto)4