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