use of eu.bcvsolutions.idm.core.monitoring.api.dto.IdmMonitoringDto in project CzechIdMng by bcvsolutions.
the class DemoAdminMonitoringEvaluatorUnitTest method testDevelopmentWithDemoAdmin.
@Test
public void testDevelopmentWithDemoAdmin() {
Mockito.when(applicationConfiguration.isDevelopment()).thenReturn(true);
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.assertNull(result.getLevel());
}
use of eu.bcvsolutions.idm.core.monitoring.api.dto.IdmMonitoringDto in project CzechIdMng by bcvsolutions.
the class H2DatabaseMonitoringEvaluatorUnitTest method testSuccess.
@Test
public void testSuccess() {
Mockito.when(flywayMigrationStrategy.resolveDbName(dataSource)).thenReturn(IdmFlywayMigrationStrategy.POSTGRESQL_DBNAME);
//
IdmMonitoringDto monitoring = new IdmMonitoringDto();
monitoring.setInstanceId("mock");
IdmMonitoringResultDto result = evaluator.evaluate(monitoring);
//
Assert.assertEquals(CoreResultCode.MONITORING_H2_DATABASE_SUCCESS.getCode(), result.getResult().getCode());
Assert.assertEquals(IdmFlywayMigrationStrategy.POSTGRESQL_DBNAME, result.getValue());
}
use of eu.bcvsolutions.idm.core.monitoring.api.dto.IdmMonitoringDto in project CzechIdMng by bcvsolutions.
the class H2DatabaseMonitoringEvaluatorUnitTest method testProductionWithH2.
@Test
public void testProductionWithH2() {
Mockito.when(applicationConfiguration.isProduction()).thenReturn(true);
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_ERROR.getCode(), result.getResult().getCode());
Assert.assertEquals(IdmFlywayMigrationStrategy.H2_DBNAME, result.getValue());
}
use of eu.bcvsolutions.idm.core.monitoring.api.dto.IdmMonitoringDto 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.IdmMonitoringDto 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());
}
Aggregations