Search in sources :

Example 46 with IdmMonitoringResultDto

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

the class H2DatabaseMonitoringEvaluatorUnitTest method testDevelopmentWithH2.

@Test
public void testDevelopmentWithH2() {
    Mockito.when(applicationConfiguration.isProduction()).thenReturn(false);
    Mockito.when(applicationConfiguration.getStage()).thenReturn(ApplicationConfiguration.STAGE_DEVELOPMENT);
    Mockito.when(flywayMigrationStrategy.resolveDbName(dataSource)).thenReturn(IdmFlywayMigrationStrategy.H2_DBNAME);
    // 
    IdmMonitoringDto monitoring = new IdmMonitoringDto();
    monitoring.setInstanceId("mock");
    IdmMonitoringResultDto result = evaluator.evaluate(monitoring);
    // 
    Assert.assertEquals(CoreResultCode.MONITORING_H2_DATABASE_WARNING.getCode(), result.getResult().getCode());
    Assert.assertEquals(IdmFlywayMigrationStrategy.H2_DBNAME, result.getValue());
}
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 47 with IdmMonitoringResultDto

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

the class LoggingEventMonitoringEvaluatorUnitTest method testError.

@Test
public void testError() {
    Mockito.when(loggingEventService.count(ArgumentMatchers.any())).thenReturn(10L);
    // 
    IdmMonitoringDto monitoring = new IdmMonitoringDto();
    monitoring.setInstanceId("mock");
    IdmMonitoringResultDto result = evaluator.evaluate(monitoring);
    // 
    Assert.assertEquals(CoreResultCode.MONITORING_LOGGING_EVENT_ERROR.getCode(), result.getResult().getCode());
    Assert.assertNull(result.getLevel());
}
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 48 with IdmMonitoringResultDto

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

the class IdmMonitoringResultControllerRestTest method prepareDto.

@Override
protected IdmMonitoringResultDto prepareDto() {
    IdmMonitoringDto monitoring = new IdmMonitoringDto();
    monitoring.setEvaluatorType("mock");
    monitoring.setInstanceId("mock");
    monitoring = monitoringService.save(monitoring);
    // 
    IdmMonitoringResultDto dto = new IdmMonitoringResultDto();
    dto.setMonitoring(monitoring.getId());
    dto.setEvaluatorType("mock");
    dto.setInstanceId("mock");
    dto.setResult(new OperationResultDto(OperationState.BLOCKED));
    // 
    return 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 49 with IdmMonitoringResultDto

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

the class DefaultMonitoringManagerIntegrationTest method testReferentiralIntegrity.

@Test
public void testReferentiralIntegrity() {
    IdmMonitoringDto monitoring = new IdmMonitoringDto();
    monitoring.setCheckPeriod(0L);
    monitoring.setEvaluatorType(AutowireHelper.getTargetType(h2DatabaseMonitoringEvaluator));
    monitoring.setInstanceId(configurationService.getInstanceId());
    monitoring = monitoringService.save(monitoring);
    // 
    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());
    // 
    monitoringService.delete(monitoring);
    // 
    results = monitoringResultService.find(filter, null).getContent();
    Assert.assertTrue(results.isEmpty());
}
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 50 with IdmMonitoringResultDto

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

the class DefaultMonitoringManagerIntegrationTest method testNotExecuteBeforeExecuteDate.

@Test
public void testNotExecuteBeforeExecuteDate() {
    IdmMonitoringDto monitoring = new IdmMonitoringDto();
    monitoring.setCheckPeriod(0L);
    monitoring.setEvaluatorType(AutowireHelper.getTargetType(h2DatabaseMonitoringEvaluator));
    monitoring.setInstanceId(configurationService.getInstanceId());
    monitoring.setExecuteDate(ZonedDateTime.now().plusHours(1));
    monitoring = monitoringService.save(monitoring);
    try {
        // 
        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.assertTrue(results.isEmpty());
    } 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)

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