use of org.ovirt.engine.core.common.businessentities.AuditLog in project ovirt-engine by oVirt.
the class AuditLogDaoTest method testMultipleAlertsWithSameTypeAndHostAreIgnored.
/**
* Checks if multiple alerts of the same type for the same host are ignored if repeatable is set to {@code false}
*/
@Test
public void testMultipleAlertsWithSameTypeAndHostAreIgnored() {
AuditLog entry = new AuditLog(AuditLogType.VDS_ALERT_FENCE_DISABLED_BY_CLUSTER_POLICY, AuditLogSeverity.ALERT);
entry.setVdsId(FixturesTool.VDS_RHEL6_NFS_SPM);
entry.setVdsName(FixturesTool.GLUSTER_SERVER_NAME3);
entry.setMessage("Testing alert");
// test if no alert of the same type for the same host exists
assertEquals(0L, getAlertCount(entry, dao.getAll(null, false)));
dao.save(entry);
AuditLog savedAlert = dao.get(entry.getAuditLogId());
assertNotNull(savedAlert);
// test if 1st alert was stored in db
assertEquals(1L, getAlertCount(entry, dao.getAll(null, false)));
// try to store 2nd alert in db
entry.setLogTime(new Date());
dao.save(entry);
savedAlert = dao.get(entry.getAuditLogId());
assertNotNull(savedAlert);
// test if 2nd alert was ignored
assertEquals(1L, getAlertCount(entry, dao.getAll(null, false)));
}
use of org.ovirt.engine.core.common.businessentities.AuditLog in project ovirt-engine by oVirt.
the class AuditLogDaoTest method testGetAllAfterDate.
/**
* Test date filtering
*/
@Test
public void testGetAllAfterDate() throws Exception {
Date cutoff = EXPECTED_DATE_FORMAT.parse("2010-12-20 13:00:00");
List<AuditLog> result = dao.getAllAfterDate(cutoff);
assertNotNull(result);
assertEquals(AFTER_DATE_COUNT, result.size());
cutoff = EXPECTED_DATE_FORMAT.parse("2010-12-20 14:00:00");
result = dao.getAllAfterDate(cutoff);
assertNotNull(result);
assertEquals(0, result.size());
}
use of org.ovirt.engine.core.common.businessentities.AuditLog in project ovirt-engine by oVirt.
the class AuditLogDaoTest method assertGetByNameResults.
private static void assertGetByNameResults(List<AuditLog> results, int expectedResults) {
assertNotNull("Results object should not be null", results);
assertEquals("Wrong number of results", expectedResults, results.size());
for (AuditLog auditLog : results) {
assertEquals("Wrong name of VM in result", VM_NAME, auditLog.getVmName());
assertEquals("Wrong template name of VM in result", VM_TEMPLATE_NAME, auditLog.getVmTemplateName());
}
}
use of org.ovirt.engine.core.common.businessentities.AuditLog in project ovirt-engine by oVirt.
the class AuditLogDaoTest method testGetByOriginAndCustomEventId.
/**
* Ensures that, for External Events, then retrieving a AuditLog works as expected.
*/
@Test
public void testGetByOriginAndCustomEventId() {
AuditLog result = dao.getByOriginAndCustomEventId("EMC", 1);
assertNotNull(result);
assertEquals(externalAuditLog, result);
}
use of org.ovirt.engine.core.common.businessentities.AuditLog in project ovirt-engine by oVirt.
the class BackendEventResourceTest method getEntity.
@Override
protected AuditLog getEntity(int index) {
AuditLog auditLog = mock(AuditLog.class);
when(auditLog.getAuditLogId()).thenReturn(LOG_IDS[index]);
when(auditLog.getLogType()).thenReturn(AuditLogType.EXTERNAL_ALERT);
when(auditLog.getSeverity()).thenReturn(AuditLogSeverity.ALERT);
when(auditLog.getLogTime()).thenReturn(new Date());
return auditLog;
}
Aggregations