use of eu.bcvsolutions.idm.core.monitoring.api.dto.IdmMonitoringDto in project CzechIdMng by bcvsolutions.
the class IdmMonitoringResultControllerRestTest method testExecute.
@Test
public void testExecute() throws Exception {
IdmMonitoringDto monitoring = new IdmMonitoringDto();
monitoring.setCheckPeriod(0L);
monitoring.setEvaluatorType(AutowireHelper.getTargetType(h2DatabaseMonitoringEvaluator));
monitoring.setInstanceId(configurationService.getInstanceId());
monitoring = monitoringService.save(monitoring);
//
IdmMonitoringResultDto dto = new IdmMonitoringResultDto();
dto.setMonitoring(monitoring.getId());
dto.setEvaluatorType(AutowireHelper.getTargetType(h2DatabaseMonitoringEvaluator));
dto.setInstanceId(configurationService.getInstanceId());
dto.setResult(new OperationResultDto(OperationState.BLOCKED));
dto = monitoringResultService.save(dto);
//
String response = getMockMvc().perform(put(String.format("%s/execute", getDetailUrl(dto.getId()))).with(authentication(getAdminAuthentication())).contentType(TestHelper.HAL_CONTENT_TYPE)).andExpect(status().isCreated()).andReturn().getResponse().getContentAsString();
Assert.assertNotNull(response);
//
getMockMvc().perform(put(String.format("%s/execute", getDetailUrl(UUID.randomUUID()))).with(authentication(getAdminAuthentication())).contentType(TestHelper.HAL_CONTENT_TYPE)).andExpect(status().isNotFound());
}
use of eu.bcvsolutions.idm.core.monitoring.api.dto.IdmMonitoringDto in project CzechIdMng by bcvsolutions.
the class IdmMonitoringResultControllerRestTest method testFindByText.
@Test
public void testFindByText() {
IdmMonitoringResultDto result = prepareDto();
IdmMonitoringDto monitoringOne = new IdmMonitoringDto();
monitoringOne.setEvaluatorType(getHelper().createName());
monitoringOne.setInstanceId("mock");
monitoringOne = monitoringService.save(monitoringOne);
result.setMonitoring(monitoringOne.getId());
IdmIdentityDto owner = getHelper().createIdentity((GuardedString) null);
result.setOwnerId(owner.getId());
result.setOwnerType(IdmIdentity.class.getCanonicalName());
IdmMonitoringResultDto resultOne = createDto(result);
//
result = prepareDto();
IdmMonitoringDto monitoringTwo = new IdmMonitoringDto();
monitoringTwo.setEvaluatorType(TestMonitoringEvaluator.class.getCanonicalName());
monitoringTwo.setDescription(monitoringOne.getEvaluatorType());
monitoringTwo.setInstanceId("mock");
monitoringTwo = monitoringService.save(monitoringTwo);
result.setMonitoring(monitoringTwo.getId());
result.setEvaluatorType(TestMonitoringEvaluator.class.getCanonicalName());
IdmMonitoringResultDto resultTwo = createDto(result);
//
// other
createDto();
//
IdmMonitoringResultFilter filter = new IdmMonitoringResultFilter();
filter.setText(monitoringOne.getEvaluatorType());
List<IdmMonitoringResultDto> results = find(filter);
//
Assert.assertEquals(2, results.size());
Assert.assertTrue(results.stream().anyMatch(r -> r.getId().equals(resultOne.getId())));
Assert.assertTrue(results.stream().anyMatch(r -> r.getId().equals(resultTwo.getId())));
}
use of eu.bcvsolutions.idm.core.monitoring.api.dto.IdmMonitoringDto in project CzechIdMng by bcvsolutions.
the class LoggingEventMonitoringEvaluatorUnitTest method testErrorWithNumberOfDays.
@Test
public void testErrorWithNumberOfDays() {
Mockito.when(loggingEventService.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_LOGGING_EVENT_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 LoggingEventMonitoringEvaluatorUnitTest method testOk.
@Test
public void testOk() {
Mockito.when(loggingEventService.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 LongRunningTaskMonitoringEvaluatorUnitTest method testError.
@Test
public void testError() {
Mockito.when(longRunningTaskService.count(ArgumentMatchers.any())).thenReturn(10L);
//
IdmMonitoringDto monitoring = new IdmMonitoringDto();
monitoring.setInstanceId("mock");
IdmMonitoringResultDto result = evaluator.evaluate(monitoring);
//
Assert.assertEquals(CoreResultCode.MONITORING_LONG_RUNNING_TASK_ERROR.getCode(), result.getResult().getCode());
Assert.assertNull(result.getLevel());
}
Aggregations