Search in sources :

Example 1 with H2DatabaseMonitoringEvaluator

use of eu.bcvsolutions.idm.core.monitoring.service.impl.H2DatabaseMonitoringEvaluator in project CzechIdMng by bcvsolutions.

the class MonitoringReportExecutorIntegrationTest method testExecutor.

@Test
@Transactional
public void testExecutor() throws IOException {
    IdmMonitoringDto monitoring = new IdmMonitoringDto();
    monitoring.setCheckPeriod(0L);
    monitoring.setEvaluatorType(AutowireHelper.getTargetType(h2DatabaseMonitoringEvaluator));
    monitoring.setInstanceId(configurationService.getInstanceId());
    monitoring = monitoringService.save(monitoring);
    monitoringManager.execute(monitoring);
    // 
    // generate report
    RptReportDto report = reportExecutor.generate(new RptReportDto(UUID.randomUUID()));
    Assert.assertNotNull(report.getData());
    List<RptMonitoringResultDto> results = mapper.readValue(attachmentManager.getAttachmentData(report.getData()), new TypeReference<List<RptMonitoringResultDto>>() {
    });
    // 
    // test
    Assert.assertFalse(results.isEmpty());
    Assert.assertTrue(results.stream().anyMatch(r -> r.getEvaluatorType().equals(AutowireHelper.getTargetType(h2DatabaseMonitoringEvaluator))));
    // 
    attachmentManager.deleteAttachments(report);
}
Also used : MonitoringManager(eu.bcvsolutions.idm.core.monitoring.api.service.MonitoringManager) IdmMonitoringDto(eu.bcvsolutions.idm.core.monitoring.api.dto.IdmMonitoringDto) IdmMonitoringService(eu.bcvsolutions.idm.core.monitoring.api.service.IdmMonitoringService) RptMonitoringResultDto(eu.bcvsolutions.idm.rpt.dto.RptMonitoringResultDto) AttachmentManager(eu.bcvsolutions.idm.core.ecm.api.service.AttachmentManager) H2DatabaseMonitoringEvaluator(eu.bcvsolutions.idm.core.monitoring.service.impl.H2DatabaseMonitoringEvaluator) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Autowired(org.springframework.beans.factory.annotation.Autowired) IOException(java.io.IOException) Test(org.junit.Test) UUID(java.util.UUID) ConfigurationService(eu.bcvsolutions.idm.core.api.service.ConfigurationService) RptReportDto(eu.bcvsolutions.idm.rpt.api.dto.RptReportDto) AutowireHelper(eu.bcvsolutions.idm.core.api.utils.AutowireHelper) List(java.util.List) After(org.junit.After) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Assert(org.junit.Assert) TypeReference(com.fasterxml.jackson.core.type.TypeReference) Before(org.junit.Before) Transactional(org.springframework.transaction.annotation.Transactional) IdmMonitoringDto(eu.bcvsolutions.idm.core.monitoring.api.dto.IdmMonitoringDto) RptMonitoringResultDto(eu.bcvsolutions.idm.rpt.dto.RptMonitoringResultDto) List(java.util.List) RptReportDto(eu.bcvsolutions.idm.rpt.api.dto.RptReportDto) Test(org.junit.Test) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

TypeReference (com.fasterxml.jackson.core.type.TypeReference)1 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 ConfigurationService (eu.bcvsolutions.idm.core.api.service.ConfigurationService)1 AutowireHelper (eu.bcvsolutions.idm.core.api.utils.AutowireHelper)1 AttachmentManager (eu.bcvsolutions.idm.core.ecm.api.service.AttachmentManager)1 IdmMonitoringDto (eu.bcvsolutions.idm.core.monitoring.api.dto.IdmMonitoringDto)1 IdmMonitoringService (eu.bcvsolutions.idm.core.monitoring.api.service.IdmMonitoringService)1 MonitoringManager (eu.bcvsolutions.idm.core.monitoring.api.service.MonitoringManager)1 H2DatabaseMonitoringEvaluator (eu.bcvsolutions.idm.core.monitoring.service.impl.H2DatabaseMonitoringEvaluator)1 RptReportDto (eu.bcvsolutions.idm.rpt.api.dto.RptReportDto)1 RptMonitoringResultDto (eu.bcvsolutions.idm.rpt.dto.RptMonitoringResultDto)1 AbstractIntegrationTest (eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)1 IOException (java.io.IOException)1 List (java.util.List)1 UUID (java.util.UUID)1 After (org.junit.After)1 Assert (org.junit.Assert)1 Before (org.junit.Before)1 Test (org.junit.Test)1 Autowired (org.springframework.beans.factory.annotation.Autowired)1