Search in sources :

Example 46 with IdmMonitoringDto

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

the class SynchronizationMonitoringEvaluatorIntegrationTest method testSynchronizationContainsError.

@Test
public void testSynchronizationContainsError() {
    UUID syncId = UUID.randomUUID();
    SysSyncConfigDto config = new SysSyncConfigDto();
    config.setName("mock");
    config.setLastSyncLog(new SysSyncLogDto());
    SysSyncActionLogDto action = new SysSyncActionLogDto();
    action.setOperationResult(OperationResultType.SUCCESS);
    action.setOperationCount(2);
    config.getLastSyncLog().getSyncActionLogs().add(action);
    config.getLastSyncLog().setContainsError(true);
    SysSystemMappingDto mapping = new SysSystemMappingDto();
    config.getEmbedded().put(SysSyncConfig_.systemMapping.getName(), mapping);
    SysSchemaObjectClassDto schema = new SysSchemaObjectClassDto();
    schema.setSystem(syncId);
    mapping.getEmbedded().put(SysSystemMapping_.objectClass.getName(), schema);
    SysSystemDto system = new SysSystemDto(UUID.randomUUID());
    system.setName("mock");
    // 
    SysSyncConfigFilter context = new SysSyncConfigFilter();
    context.setIncludeLastLog(Boolean.TRUE);
    Mockito.when(syncConfigService.get(ArgumentMatchers.any(), (SysSyncConfigFilter) ArgumentMatchers.any())).thenReturn(config);
    Mockito.when(systemService.get(syncId)).thenReturn(system);
    // 
    IdmMonitoringDto monitoring = new IdmMonitoringDto();
    monitoring.getEvaluatorProperties().put(SynchronizationMonitoringEvaluator.PARAMETER_SYNCHRONIZATION, syncId);
    IdmMonitoringResultDto result = evaluator.evaluate(monitoring);
    // 
    Assert.assertEquals(AccResultCode.MONITORING_SYNCHRONIZATION_CONTAINS_ERROR.getCode(), result.getResult().getCode());
    // ~ flag only
    Assert.assertEquals(String.valueOf(0), result.getValue());
}
Also used : SysSyncActionLogDto(eu.bcvsolutions.idm.acc.dto.SysSyncActionLogDto) IdmMonitoringDto(eu.bcvsolutions.idm.core.monitoring.api.dto.IdmMonitoringDto) SysSystemMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto) SysSyncConfigDto(eu.bcvsolutions.idm.acc.dto.SysSyncConfigDto) SysSchemaObjectClassDto(eu.bcvsolutions.idm.acc.dto.SysSchemaObjectClassDto) UUID(java.util.UUID) SysSyncConfigFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSyncConfigFilter) SysSyncLogDto(eu.bcvsolutions.idm.acc.dto.SysSyncLogDto) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) IdmMonitoringResultDto(eu.bcvsolutions.idm.core.monitoring.api.dto.IdmMonitoringResultDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 47 with IdmMonitoringDto

use of eu.bcvsolutions.idm.core.monitoring.api.dto.IdmMonitoringDto 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 48 with IdmMonitoringDto

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

the class DatabaseTableMonitoringEvaluatorUnitTest method testBeanNotReadService.

@Test(expected = ResultCodeException.class)
public void testBeanNotReadService() {
    Mockito.when(context.getBean("mock")).thenReturn(new IdmIdentityDto());
    // 
    IdmMonitoringDto monitoring = new IdmMonitoringDto();
    monitoring.getEvaluatorProperties().put(DatabaseTableMonitoringEvaluator.PARAMETER_READ_SERVICE_BEAN_NAME, "mock");
    evaluator.evaluate(monitoring);
}
Also used : IdmMonitoringDto(eu.bcvsolutions.idm.core.monitoring.api.dto.IdmMonitoringDto) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) Test(org.junit.Test) AbstractUnitTest(eu.bcvsolutions.idm.test.api.AbstractUnitTest)

Example 49 with IdmMonitoringDto

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

the class DatabaseTableMonitoringEvaluatorUnitTest method testBeanNotFoud.

@Test(expected = ResultCodeException.class)
public void testBeanNotFoud() {
    Mockito.when(context.getBean("mock")).thenReturn(null);
    // 
    IdmMonitoringDto monitoring = new IdmMonitoringDto();
    monitoring.getEvaluatorProperties().put(DatabaseTableMonitoringEvaluator.PARAMETER_READ_SERVICE_BEAN_NAME, "mock");
    evaluator.evaluate(monitoring);
}
Also used : IdmMonitoringDto(eu.bcvsolutions.idm.core.monitoring.api.dto.IdmMonitoringDto) Test(org.junit.Test) AbstractUnitTest(eu.bcvsolutions.idm.test.api.AbstractUnitTest)

Example 50 with IdmMonitoringDto

use of eu.bcvsolutions.idm.core.monitoring.api.dto.IdmMonitoringDto 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)

Aggregations

IdmMonitoringDto (eu.bcvsolutions.idm.core.monitoring.api.dto.IdmMonitoringDto)73 Test (org.junit.Test)46 IdmMonitoringResultDto (eu.bcvsolutions.idm.core.monitoring.api.dto.IdmMonitoringResultDto)45 AbstractUnitTest (eu.bcvsolutions.idm.test.api.AbstractUnitTest)24 AbstractIntegrationTest (eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)16 UUID (java.util.UUID)13 IdmMonitoringResultFilter (eu.bcvsolutions.idm.core.monitoring.api.dto.filter.IdmMonitoringResultFilter)10 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 IdmIdentityDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto)6 SysSchemaObjectClassDto (eu.bcvsolutions.idm.acc.dto.SysSchemaObjectClassDto)5 SysSyncConfigDto (eu.bcvsolutions.idm.acc.dto.SysSyncConfigDto)5 ConfigurationMap (eu.bcvsolutions.idm.core.api.domain.ConfigurationMap)5 OperationResultDto (eu.bcvsolutions.idm.core.api.dto.OperationResultDto)5 AbstractReadWriteDtoControllerRestTest (eu.bcvsolutions.idm.core.api.rest.AbstractReadWriteDtoControllerRestTest)5 IdmMonitoringFilter (eu.bcvsolutions.idm.core.monitoring.api.dto.filter.IdmMonitoringFilter)5 DefaultEventResult (eu.bcvsolutions.idm.core.api.event.DefaultEventResult)4 AutowireHelper (eu.bcvsolutions.idm.core.api.utils.AutowireHelper)4 IdmMonitoringService (eu.bcvsolutions.idm.core.monitoring.api.service.IdmMonitoringService)4