Search in sources :

Example 11 with AuditLog

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)));
}
Also used : AuditLog(org.ovirt.engine.core.common.businessentities.AuditLog) Date(java.util.Date) Test(org.junit.Test)

Example 12 with AuditLog

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());
}
Also used : Date(java.util.Date) AuditLog(org.ovirt.engine.core.common.businessentities.AuditLog) Test(org.junit.Test)

Example 13 with AuditLog

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());
    }
}
Also used : AuditLog(org.ovirt.engine.core.common.businessentities.AuditLog)

Example 14 with AuditLog

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);
}
Also used : AuditLog(org.ovirt.engine.core.common.businessentities.AuditLog) Test(org.junit.Test)

Example 15 with AuditLog

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;
}
Also used : AuditLog(org.ovirt.engine.core.common.businessentities.AuditLog) Date(java.util.Date)

Aggregations

AuditLog (org.ovirt.engine.core.common.businessentities.AuditLog)31 Test (org.junit.Test)13 Date (java.util.Date)6 Guid (org.ovirt.engine.core.compat.Guid)4 AuditLogSeverity (org.ovirt.engine.core.common.AuditLogSeverity)2 AbstractFullDateTimeColumn (org.ovirt.engine.ui.common.widget.table.column.AbstractFullDateTimeColumn)2 AuditLogSeverityColumn (org.ovirt.engine.ui.common.widget.table.column.AuditLogSeverityColumn)2 HasClickHandlers (com.google.gwt.event.dom.client.HasClickHandlers)1 EventBus (com.google.gwt.event.shared.EventBus)1 SafeHtmlUtils (com.google.gwt.safehtml.shared.SafeHtmlUtils)1 FlowPanel (com.google.gwt.user.client.ui.FlowPanel)1 HasData (com.google.gwt.view.client.HasData)1 Inject (com.google.inject.Inject)1 Provider (com.google.inject.Provider)1 Named (com.google.inject.name.Named)1 PresenterWidget (com.gwtplatform.mvp.client.PresenterWidget)1 View (com.gwtplatform.mvp.client.View)1 RevealRootPopupContentEvent (com.gwtplatform.mvp.client.proxy.RevealRootPopupContentEvent)1 Date (java.sql.Date)1 Collection (java.util.Collection)1