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());
}
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());
}
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;
}
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());
}
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);
}
}
Aggregations