Search in sources :

Example 6 with IdmMonitoringDto

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())));
}
Also used : IdmMonitoringFilter(eu.bcvsolutions.idm.core.monitoring.api.dto.filter.IdmMonitoringFilter) MockMvcRequestBuilders.put(org.springframework.test.web.servlet.request.MockMvcRequestBuilders.put) IdmMonitoringDto(eu.bcvsolutions.idm.core.monitoring.api.dto.IdmMonitoringDto) IdmMonitoringService(eu.bcvsolutions.idm.core.monitoring.api.service.IdmMonitoringService) H2DatabaseMonitoringEvaluator(eu.bcvsolutions.idm.core.monitoring.service.impl.H2DatabaseMonitoringEvaluator) Autowired(org.springframework.beans.factory.annotation.Autowired) DemoAdminMonitoringEvaluator(eu.bcvsolutions.idm.core.monitoring.service.impl.DemoAdminMonitoringEvaluator) Test(org.junit.Test) UUID(java.util.UUID) ConfigurationService(eu.bcvsolutions.idm.core.api.service.ConfigurationService) TestMonitoringEvaluator(eu.bcvsolutions.idm.core.monitoring.service.impl.TestMonitoringEvaluator) AbstractReadWriteDtoControllerRestTest(eu.bcvsolutions.idm.core.api.rest.AbstractReadWriteDtoControllerRestTest) AutowireHelper(eu.bcvsolutions.idm.core.api.utils.AutowireHelper) List(java.util.List) AbstractReadWriteDtoController(eu.bcvsolutions.idm.core.api.rest.AbstractReadWriteDtoController) IdmMonitoringFilter(eu.bcvsolutions.idm.core.monitoring.api.dto.filter.IdmMonitoringFilter) SecurityMockMvcRequestPostProcessors.authentication(org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestPostProcessors.authentication) MockMvcResultMatchers.status(org.springframework.test.web.servlet.result.MockMvcResultMatchers.status) TestHelper(eu.bcvsolutions.idm.test.api.TestHelper) Assert(org.junit.Assert) DemoAdminMonitoringEvaluator(eu.bcvsolutions.idm.core.monitoring.service.impl.DemoAdminMonitoringEvaluator) IdmMonitoringDto(eu.bcvsolutions.idm.core.monitoring.api.dto.IdmMonitoringDto) TestMonitoringEvaluator(eu.bcvsolutions.idm.core.monitoring.service.impl.TestMonitoringEvaluator) Test(org.junit.Test) AbstractReadWriteDtoControllerRestTest(eu.bcvsolutions.idm.core.api.rest.AbstractReadWriteDtoControllerRestTest)

Example 7 with IdmMonitoringDto

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);
}
Also used : IdmMonitoringDto(eu.bcvsolutions.idm.core.monitoring.api.dto.IdmMonitoringDto) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) BeanNotOfRequiredTypeException(org.springframework.beans.factory.BeanNotOfRequiredTypeException) Test(org.junit.Test) AbstractUnitTest(eu.bcvsolutions.idm.test.api.AbstractUnitTest)

Example 8 with IdmMonitoringDto

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());
}
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 9 with IdmMonitoringDto

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

Example 10 with IdmMonitoringDto

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

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