use of eu.bcvsolutions.idm.core.monitoring.api.dto.IdmMonitoringDto in project CzechIdMng by bcvsolutions.
the class IdmMonitoringControllerRestTest method testFindByText.
@Test
public void testFindByText() {
IdmMonitoringDto monitoring = prepareDto();
monitoring.setEvaluatorType(getHelper().createName());
monitoring.setInstanceId("mock");
IdmMonitoringDto monitoringOne = createDto(monitoring);
//
monitoring = prepareDto();
monitoring.setEvaluatorType(TestMonitoringEvaluator.class.getCanonicalName());
monitoring.setDescription(monitoringOne.getEvaluatorType());
monitoring.setInstanceId("mock");
IdmMonitoringDto monitoringTwo = createDto(monitoring);
//
monitoring = prepareDto();
monitoring.setEvaluatorType(DemoAdminMonitoringEvaluator.class.getCanonicalName());
monitoring.setDescription(monitoringOne.getEvaluatorType());
monitoring.setInstanceId("mock");
IdmMonitoringDto monitoringThree = createDto(monitoring);
//
// other
createDto();
//
IdmMonitoringFilter filter = new IdmMonitoringFilter();
filter.setText(monitoringOne.getEvaluatorType());
List<IdmMonitoringDto> results = find(filter);
//
Assert.assertEquals(3, results.size());
Assert.assertTrue(results.stream().anyMatch(r -> r.getId().equals(monitoringOne.getId())));
Assert.assertTrue(results.stream().anyMatch(r -> r.getId().equals(monitoringTwo.getId())));
Assert.assertTrue(results.stream().anyMatch(r -> r.getId().equals(monitoringThree.getId())));
}
use of eu.bcvsolutions.idm.core.monitoring.api.dto.IdmMonitoringDto in project CzechIdMng by bcvsolutions.
the class DatabaseTableMonitoringEvaluatorUnitTest method testBeanException.
@Test(expected = ResultCodeException.class)
public void testBeanException() {
Mockito.when(context.getBean("mock")).thenThrow(new BeanNotOfRequiredTypeException("mock", IdmIdentityDto.class, IdmIdentityDto.class));
//
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 testWarning.
@Test
public void testWarning() {
Mockito.when(context.getBean("mock")).thenReturn(identityService);
Mockito.when(identityService.count(ArgumentMatchers.any())).thenReturn(DatabaseTableMonitoringEvaluator.DEFAULT_THRESHOLD + 1);
Mockito.when(identityService.getEntityClass()).thenReturn(IdmIdentity.class);
Mockito.when(identityService.getDtoClass()).thenReturn(IdmIdentityDto.class);
//
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.assertEquals(NotificationLevel.WARNING, result.getLevel());
Assert.assertEquals(String.valueOf(DatabaseTableMonitoringEvaluator.DEFAULT_THRESHOLD + 1), result.getValue());
}
use of eu.bcvsolutions.idm.core.monitoring.api.dto.IdmMonitoringDto in project CzechIdMng by bcvsolutions.
the class DemoAdminMonitoringEvaluatorUnitTest method testProductionWithDemoAdmin.
@Test
public void testProductionWithDemoAdmin() {
Mockito.when(applicationConfiguration.isDevelopment()).thenReturn(false);
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.assertEquals(NotificationLevel.ERROR, result.getLevel());
}
use of eu.bcvsolutions.idm.core.monitoring.api.dto.IdmMonitoringDto in project CzechIdMng by bcvsolutions.
the class DemoAdminMonitoringEvaluatorUnitTest method testProductionWithoutDemoAdmin.
@Test
public void testProductionWithoutDemoAdmin() {
Mockito.when(lookupService.lookupDto(IdmIdentityDto.class, InitAdminIdentityProcessor.ADMIN_USERNAME)).thenReturn(null);
//
IdmMonitoringDto monitoring = new IdmMonitoringDto();
monitoring.setInstanceId("mock");
IdmMonitoringResultDto result = evaluator.evaluate(monitoring);
//
Assert.assertEquals(CoreResultCode.MONITORING_DEMO_ADMIN_NOT_FOUND.getCode(), result.getResult().getCode());
}
Aggregations