Search in sources :

Example 21 with IdmMonitoringDto

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

the class LongRunningTaskMonitoringEvaluatorUnitTest method testErrorWithNumberOfDays.

@Test
public void testErrorWithNumberOfDays() {
    Mockito.when(longRunningTaskService.count(ArgumentMatchers.any())).thenReturn(10L);
    // 
    IdmMonitoringDto monitoring = new IdmMonitoringDto();
    monitoring.setInstanceId("mock");
    monitoring.getEvaluatorProperties().put(AbstractDailyMonitoringEvaluator.PARAMETER_NUMBER_OF_DAYS, 2);
    IdmMonitoringResultDto result = evaluator.evaluate(monitoring);
    // 
    Assert.assertEquals(CoreResultCode.MONITORING_LONG_RUNNING_TASK_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 22 with IdmMonitoringDto

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

the class LongRunningTaskMonitoringEvaluatorUnitTest method testOk.

@Test
public void testOk() {
    Mockito.when(longRunningTaskService.count(ArgumentMatchers.any())).thenReturn(0L);
    // 
    IdmMonitoringDto monitoring = new IdmMonitoringDto();
    monitoring.setInstanceId("mock");
    monitoring.getEvaluatorProperties().put(AbstractDailyMonitoringEvaluator.PARAMETER_NUMBER_OF_DAYS, 2);
    IdmMonitoringResultDto result = evaluator.evaluate(monitoring);
    // 
    Assert.assertEquals(CoreResultCode.OK.getCode(), result.getResult().getCode());
}
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 23 with IdmMonitoringDto

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

the class SyncConfigMonitoringAutoConfigurationProcessorIntegrationTest method testAutoConfigure.

@Test
public void testAutoConfigure() {
    SysSystemDto system = getHelper().createTestResourceSystem(true);
    SysSystemMappingFilter mappingFilter = new SysSystemMappingFilter();
    mappingFilter.setSystemId(system.getId());
    List<SysSystemMappingDto> mappings = systemMappingService.find(mappingFilter, null).getContent();
    SysSystemMappingDto mapping = mappings.get(0);
    SysSystemAttributeMappingFilter attributeMappingFilter = new SysSystemAttributeMappingFilter();
    attributeMappingFilter.setSystemMappingId(mapping.getId());
    List<SysSystemAttributeMappingDto> attributes = schemaAttributeMappingService.find(attributeMappingFilter, null).getContent();
    SysSystemAttributeMappingDto nameAttribute = attributes.stream().filter(attribute -> {
        return attribute.getName().equals(TestHelper.ATTRIBUTE_MAPPING_NAME);
    }).findFirst().get();
    // Create default synchronization config.
    AbstractSysSyncConfigDto syncConfigCustom = new SysSyncIdentityConfigDto();
    syncConfigCustom.setCustomFilter(true);
    syncConfigCustom.setSystemMapping(mapping.getId());
    syncConfigCustom.setCorrelationAttribute(nameAttribute.getId());
    syncConfigCustom.setName(getHelper().createName());
    AbstractSysSyncConfigDto syncConfig = syncConfigService.save(syncConfigCustom);
    String evaluatorType = AutowireHelper.getTargetType(synchronizationMonitoringEvaluator);
    IdmMonitoringFilter filter = new IdmMonitoringFilter();
    filter.setEvaluatorType(evaluatorType);
    IdmMonitoringDto monitoring = monitoringService.find(filter, null).stream().filter(m -> {
        return syncConfig.getId().equals(m.getEvaluatorProperties().get(SynchronizationMonitoringEvaluator.PARAMETER_SYNCHRONIZATION));
    }).findFirst().orElse(null);
    Assert.assertNotNull(monitoring);
    syncConfigService.delete(syncConfig);
    monitoring = monitoringService.find(filter, null).stream().filter(m -> {
        return syncConfig.getId().equals(m.getEvaluatorProperties().get(SynchronizationMonitoringEvaluator.PARAMETER_SYNCHRONIZATION));
    }).findFirst().orElse(null);
    Assert.assertNull(monitoring);
}
Also used : IdmMonitoringFilter(eu.bcvsolutions.idm.core.monitoring.api.dto.filter.IdmMonitoringFilter) SysSystemMappingFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSystemMappingFilter) IdmMonitoringDto(eu.bcvsolutions.idm.core.monitoring.api.dto.IdmMonitoringDto) IdmMonitoringService(eu.bcvsolutions.idm.core.monitoring.api.service.IdmMonitoringService) Autowired(org.springframework.beans.factory.annotation.Autowired) Test(org.junit.Test) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) SynchronizationMonitoringEvaluator(eu.bcvsolutions.idm.acc.monitoring.SynchronizationMonitoringEvaluator) SysSyncIdentityConfigDto(eu.bcvsolutions.idm.acc.dto.SysSyncIdentityConfigDto) AutowireHelper(eu.bcvsolutions.idm.core.api.utils.AutowireHelper) SysSystemAttributeMappingFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSystemAttributeMappingFilter) List(java.util.List) SysSystemMappingService(eu.bcvsolutions.idm.acc.service.api.SysSystemMappingService) IdmMonitoringFilter(eu.bcvsolutions.idm.core.monitoring.api.dto.filter.IdmMonitoringFilter) SysSystemAttributeMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemAttributeMappingDto) SysSystemMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) SysSyncConfigService(eu.bcvsolutions.idm.acc.service.api.SysSyncConfigService) TestHelper(eu.bcvsolutions.idm.acc.TestHelper) Assert(org.junit.Assert) SysSystemAttributeMappingService(eu.bcvsolutions.idm.acc.service.api.SysSystemAttributeMappingService) AbstractSysSyncConfigDto(eu.bcvsolutions.idm.acc.dto.AbstractSysSyncConfigDto) SysSyncIdentityConfigDto(eu.bcvsolutions.idm.acc.dto.SysSyncIdentityConfigDto) SysSystemAttributeMappingFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSystemAttributeMappingFilter) IdmMonitoringDto(eu.bcvsolutions.idm.core.monitoring.api.dto.IdmMonitoringDto) SysSystemAttributeMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemAttributeMappingDto) SysSystemMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) AbstractSysSyncConfigDto(eu.bcvsolutions.idm.acc.dto.AbstractSysSyncConfigDto) SysSystemMappingFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSystemMappingFilter) Test(org.junit.Test) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)

Example 24 with IdmMonitoringDto

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

the class SynchronizationMonitoringEvaluatorIntegrationTest method testSynchronizationOk.

@Test
public void testSynchronizationOk() {
    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);
    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_OK.getCode(), result.getResult().getCode());
    Assert.assertEquals(String.valueOf(2), 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 25 with IdmMonitoringDto

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

the class SynchronizationMonitoringEvaluatorIntegrationTest method testSynchronizationNotEnabled.

@Test
public void testSynchronizationNotEnabled() {
    UUID syncId = UUID.randomUUID();
    SysSyncConfigDto config = new SysSyncConfigDto();
    config.setEnabled(false);
    config.setName("mock");
    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_DISABLED.getCode(), result.getResult().getCode());
}
Also used : 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) 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)

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