@Override public Object getQueryableId() { return getAuditLogId(); }
public void dismissAlert(AuditLog auditLog) { RemoveAuditLogByIdParameters params = new RemoveAuditLogByIdParameters(auditLog.getAuditLogId()); Frontend.getInstance().runAction(ActionType.RemoveAuditLogById, params); }
@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; } }
public void dismissEvent(AuditLog auditLog) { if (auditLog == null) { return; } RemoveAuditLogByIdParameters params = new RemoveAuditLogByIdParameters(auditLog.getAuditLogId()); Frontend.getInstance().runAction(ActionType.RemoveAuditLogById, params, result -> EventListModel.this.refresh()); }
protected org.ovirt.engine.core.common.businessentities.AuditLog getEntity(int index) { AuditLog auditLogMock = mock(org.ovirt.engine.core.common.businessentities.AuditLog.class); when(auditLogMock.getAuditLogId()).thenReturn(LOG_IDS[index]); when(auditLogMock.getSeverity()).thenReturn(AuditLogSeverity.ALERT); when(auditLogMock.getMessage()).thenReturn(MESSAGES[index]); when(auditLogMock.getOrigin()).thenReturn(ORIGIN_NAMES[index]); when(auditLogMock.getCustomEventId()).thenReturn(CUSTOMER_EVENT_IDS[index]); when(auditLogMock.getLogType()).thenReturn(AuditLogType.EXTERNAL_ALERT); when(auditLogMock.getLogTime()).thenReturn(new Date()); return auditLogMock; }
/** * Ensures that removing an AuditLog works as expected. */ @Test public void testRemove() { dao.remove(existingAuditLog.getAuditLogId()); AuditLog result = dao.get(existingAuditLog.getAuditLogId()); assertTrue(result.isDeleted()); }
/** * Ensures that saving a AuditLog works as expected. */ @Test public void testSave() { dao.save(newAuditLog); AuditLog result = dao.get(newAuditLog.getAuditLogId()); assertNotNull(result); assertEquals(newAuditLog, result); }
/** * 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))); }
/** * Checks if multiple alerts of the same type for the same host are saved if repeatable is set to {@code true} */ @Test public void testMultipleAlertsWithSameTypeAndHostAreSavedIfRepeatableTrue() { 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"); entry.setRepeatable(true); // 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 save 2nd alert entry.setLogTime(new Date()); dao.save(entry); savedAlert = dao.get(entry.getAuditLogId()); assertNotNull(savedAlert); // test if 2nd alert was also stored in db assertEquals(2L, getAlertCount(entry, dao.getAll(null, false))); }
@Mapping(from = AuditLog.class, to = Event.class) public static Event map(AuditLog entity, Event event) { Event model = event != null ? event : new Event(); model.setId(String.valueOf(entity.getAuditLogId())); model.setIndex((int) entity.getAuditLogId()); model.setCode(entity.getLogType().getValue()); model.setSeverity(map(entity.getSeverity(), null));
@Test public void testSaveExternalEvent() { AuditLog newExternalEvent = new AuditLog(); newExternalEvent.setLogType(AuditLogType.EXTERNAL_EVENT_NORMAL); newExternalEvent.setExternal(true); newExternalEvent.setOrigin("XYZ"); newExternalEvent.setCustomEventId(123123123); newExternalEvent.setCustomData("Some text here"); newExternalEvent.setMessage("And here"); newExternalEvent.setEventFloodInSec(100); dao.save(newExternalEvent); AuditLog result = dao.get(newExternalEvent.getAuditLogId()); assertNotNull(result); assertTrue(result.getAuditLogId() > 0); assertEquals(newExternalEvent.getOrigin(), result.getOrigin()); assertEquals(newExternalEvent.getCustomEventId(), result.getCustomEventId()); assertEquals(newExternalEvent.getCustomData(), result.getCustomData()); assertEquals(newExternalEvent.getMessage(), result.getMessage()); assertEquals(newExternalEvent.getEventFloodInSec(), result.getEventFloodInSec()); }
private MapSqlParameterSource getSqlMapper(AuditLog event) { return getCustomMapSqlParameterSource() .addValue("audit_log_id", event.getAuditLogId()) .addValue("log_time", event.getLogTime()) .addValue("log_type", event.getLogType())