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