/** * 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))); }
/** * Set the properties of a given {@link AuditLog} entity to be persisted as a representative of the current event * * @param auditLog * an entity which was initially set with main {@link AuditLogableBase} data. */ default void setPropertiesForAuditLog(AuditLog auditLog) { auditLog.setStorageDomainId(getStorageDomainId()); auditLog.setStorageDomainName(getStorageDomainName()); auditLog.setStoragePoolId(getStoragePoolId()); auditLog.setStoragePoolName(getStoragePoolName()); auditLog.setClusterId(getClusterId()); auditLog.setClusterName(getClusterName()); auditLog.setCorrelationId(getCorrelationId()); auditLog.setJobId(getJobId()); auditLog.setGlusterVolumeId(getGlusterVolumeId()); auditLog.setGlusterVolumeName(getGlusterVolumeName()); auditLog.setExternal(isExternal()); auditLog.setQuotaId(getQuotaIdForLog()); auditLog.setQuotaName(getQuotaNameForLog()); auditLog.setCallStack(getCallStack()); auditLog.setBrickId(getBrickId()); auditLog.setBrickPath(getBrickPath()); auditLog.setRepeatable(isRepeatable()); }