Search in sources :

Example 41 with IdmMonitoringResultDto

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

the class DatabaseTableMonitoringEvaluatorUnitTest method testSuccess.

@Test
public void testSuccess() {
    Mockito.when(context.getBean("mock")).thenReturn(identityService);
    Mockito.when(identityService.count(ArgumentMatchers.any())).thenReturn(DatabaseTableMonitoringEvaluator.DEFAULT_THRESHOLD);
    // 
    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.assertNull(result.getLevel());
    Assert.assertEquals(String.valueOf(DatabaseTableMonitoringEvaluator.DEFAULT_THRESHOLD), 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 42 with IdmMonitoringResultDto

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

the class DemoAdminMonitoringEvaluatorUnitTest method testProductionWithoutDemoAdminCredentials.

@Test
public void testProductionWithoutDemoAdminCredentials() {
    Mockito.when(lookupService.lookupDto(IdmIdentityDto.class, InitAdminIdentityProcessor.ADMIN_USERNAME)).thenReturn(new IdmIdentityDto(InitAdminIdentityProcessor.ADMIN_USERNAME));
    Mockito.when(authenticationManager.validate(ArgumentMatchers.any())).thenReturn(false);
    // 
    IdmMonitoringDto monitoring = new IdmMonitoringDto();
    monitoring.setInstanceId("mock");
    IdmMonitoringResultDto result = evaluator.evaluate(monitoring);
    // 
    Assert.assertEquals(CoreResultCode.OK.getCode(), result.getResult().getCode());
}
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)

Example 43 with IdmMonitoringResultDto

use of eu.bcvsolutions.idm.core.monitoring.api.dto.IdmMonitoringResultDto 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());
}
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)

Example 44 with IdmMonitoringResultDto

use of eu.bcvsolutions.idm.core.monitoring.api.dto.IdmMonitoringResultDto 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());
}
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 45 with IdmMonitoringResultDto

use of eu.bcvsolutions.idm.core.monitoring.api.dto.IdmMonitoringResultDto 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());
}
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)

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