From 429e6bd4bb084a568c74d5412729e5e8c09d4c9a Mon Sep 17 00:00:00 2001 From: Sanjay Tripathi Date: Tue, 4 Jun 2013 16:03:53 +0530 Subject: [PATCH] CLOUDSTACK-1768: Ability to delete Events and Alerts: Delete by a time period is required. User should be able to delete/archive alerts and events by selecting a time period or by choosing the alerts and events older than a date. Added the ability to choose a time period too. --- .../apache/cloudstack/api/ApiConstants.java | 1 - .../admin/resource/ArchiveAlertsCmd.java | 24 ++++++++---- .../admin/resource/DeleteAlertsCmd.java | 23 +++++++++--- .../command/user/event/ArchiveEventsCmd.java | 24 ++++++++---- .../command/user/event/DeleteEventsCmd.java | 21 ++++++++--- .../src/com/cloud/alert/dao/AlertDao.java | 4 +- .../src/com/cloud/alert/dao/AlertDaoImpl.java | 37 +++++++++++-------- .../src/com/cloud/event/dao/EventDao.java | 2 +- .../src/com/cloud/event/dao/EventDaoImpl.java | 11 ++++-- server/src/com/cloud/api/ApiDispatcher.java | 11 ++++-- .../cloud/server/ManagementServerImpl.java | 8 ++-- .../cloud/alert/AlertControlsUnitTest.java | 8 ++-- .../cloud/event/EventControlsUnitTest.java | 2 +- 13 files changed, 116 insertions(+), 60 deletions(-) diff --git a/api/src/org/apache/cloudstack/api/ApiConstants.java b/api/src/org/apache/cloudstack/api/ApiConstants.java index e2857b8165e..83999b6d8f3 100755 --- a/api/src/org/apache/cloudstack/api/ApiConstants.java +++ b/api/src/org/apache/cloudstack/api/ApiConstants.java @@ -498,7 +498,6 @@ public class ApiConstants { public static final String UCS_BLADE_DN = "bladedn"; public static final String UCS_BLADE_ID = "bladeid"; public static final String VM_GUEST_IP = "vmguestip"; - public static final String OLDER_THAN = "olderthan"; public static final String HEALTHCHECK_RESPONSE_TIMEOUT = "responsetimeout"; public static final String HEALTHCHECK_INTERVAL_TIME = "intervaltime"; public static final String HEALTHCHECK_HEALTHY_THRESHOLD = "healthythreshold"; diff --git a/api/src/org/apache/cloudstack/api/command/admin/resource/ArchiveAlertsCmd.java b/api/src/org/apache/cloudstack/api/command/admin/resource/ArchiveAlertsCmd.java index 2a1a47a13ed..eed914e04a2 100644 --- a/api/src/org/apache/cloudstack/api/command/admin/resource/ArchiveAlertsCmd.java +++ b/api/src/org/apache/cloudstack/api/command/admin/resource/ArchiveAlertsCmd.java @@ -26,7 +26,6 @@ import org.apache.cloudstack.api.BaseCmd; import org.apache.cloudstack.api.Parameter; import org.apache.cloudstack.api.ServerApiException; import org.apache.cloudstack.api.response.AlertResponse; -import org.apache.cloudstack.api.response.ConditionResponse; import org.apache.cloudstack.api.response.SuccessResponse; import org.apache.log4j.Logger; @@ -48,8 +47,13 @@ public class ArchiveAlertsCmd extends BaseCmd { description = "the IDs of the alerts") private List ids; - @Parameter(name=ApiConstants.OLDER_THAN, type=CommandType.DATE, description="archive alerts older than this date (use format \"yyyy-MM-dd\")") - private Date olderThan; + @Parameter(name=ApiConstants.END_DATE, type=CommandType.DATE, description="end date range to archive alerts" + + " (including) this date (use format \"yyyy-MM-dd\" or the new format \"yyyy-MM-ddThh:mm:ss\")") + private Date endDate; + + @Parameter(name=ApiConstants.START_DATE, type=CommandType.DATE, description="start date range to archive alerts" + + " (including) this date (use format \"yyyy-MM-dd\" or the new format \"yyyy-MM-ddThh:mm:ss\")") + private Date startDate; @Parameter(name = ApiConstants.TYPE, type = CommandType.STRING, description = "archive by alert type") private String type; @@ -62,8 +66,12 @@ public class ArchiveAlertsCmd extends BaseCmd { return ids; } - public Date getOlderThan() { - return olderThan; + public Date getEndDate() { + return endDate; + } + + public Date getStartDate() { + return startDate; } public String getType() { @@ -86,8 +94,10 @@ public class ArchiveAlertsCmd extends BaseCmd { @Override public void execute() { - if(ids == null && type == null && olderThan == null) { - throw new InvalidParameterValueException("either ids, type or olderthan must be specified"); + if(ids == null && type == null && endDate == null) { + throw new InvalidParameterValueException("either ids, type, startdate or enddate must be specified"); + } else if (startDate != null && endDate == null) { + throw new InvalidParameterValueException("enddate must be specified with startdate parameter"); } boolean result = _mgr.archiveAlerts(this); if (result) { diff --git a/api/src/org/apache/cloudstack/api/command/admin/resource/DeleteAlertsCmd.java b/api/src/org/apache/cloudstack/api/command/admin/resource/DeleteAlertsCmd.java index f03793c4f6d..b0deaa9f638 100644 --- a/api/src/org/apache/cloudstack/api/command/admin/resource/DeleteAlertsCmd.java +++ b/api/src/org/apache/cloudstack/api/command/admin/resource/DeleteAlertsCmd.java @@ -47,8 +47,13 @@ public class DeleteAlertsCmd extends BaseCmd { description = "the IDs of the alerts") private List ids; - @Parameter(name=ApiConstants.OLDER_THAN, type=CommandType.DATE, description="delete alerts older than (including) this date (use format \"yyyy-MM-dd\")") - private Date olderThan; + @Parameter(name=ApiConstants.END_DATE, type=CommandType.DATE, description="end date range to delete alerts" + + " (including) this date (use format \"yyyy-MM-dd\" or the new format \"yyyy-MM-ddThh:mm:ss\")") + private Date endDate; + + @Parameter(name=ApiConstants.START_DATE, type=CommandType.DATE, description="start date range to delete alerts" + + " (including) this date (use format \"yyyy-MM-dd\" or the new format \"yyyy-MM-ddThh:mm:ss\")") + private Date startDate; @Parameter(name = ApiConstants.TYPE, type = CommandType.STRING, description = "delete by alert type") private String type; @@ -61,8 +66,12 @@ public class DeleteAlertsCmd extends BaseCmd { return ids; } - public Date getOlderThan() { - return olderThan; + public Date getEndDate() { + return endDate; + } + + public Date getStartDate() { + return startDate; } public String getType() { @@ -85,8 +94,10 @@ public class DeleteAlertsCmd extends BaseCmd { @Override public void execute() { - if(ids == null && type == null && olderThan == null) { - throw new InvalidParameterValueException("either ids, type or olderthan must be specified"); + if(ids == null && type == null && endDate == null) { + throw new InvalidParameterValueException("either ids, type or enddate must be specified"); + } else if (startDate != null && endDate == null) { + throw new InvalidParameterValueException("enddate must be specified with startdate parameter"); } boolean result = _mgr.deleteAlerts(this); if (result) { diff --git a/api/src/org/apache/cloudstack/api/command/user/event/ArchiveEventsCmd.java b/api/src/org/apache/cloudstack/api/command/user/event/ArchiveEventsCmd.java index 481607c9f0b..c5594e26ed6 100644 --- a/api/src/org/apache/cloudstack/api/command/user/event/ArchiveEventsCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/event/ArchiveEventsCmd.java @@ -25,7 +25,6 @@ import org.apache.cloudstack.api.ApiErrorCode; import org.apache.cloudstack.api.BaseCmd; import org.apache.cloudstack.api.Parameter; import org.apache.cloudstack.api.ServerApiException; -import org.apache.cloudstack.api.response.AlertResponse; import org.apache.cloudstack.api.response.EventResponse; import org.apache.cloudstack.api.response.SuccessResponse; import org.apache.log4j.Logger; @@ -49,8 +48,13 @@ public class ArchiveEventsCmd extends BaseCmd { description = "the IDs of the events") private List ids; - @Parameter(name=ApiConstants.OLDER_THAN, type=CommandType.DATE, description="archive events older than (including) this date (use format \"yyyy-MM-dd\" or the new format \"yyyy-MM-dd HH:mm:ss\")") - private Date olderThan; + @Parameter(name=ApiConstants.END_DATE, type=CommandType.DATE, description="end date range to archive events" + + " (including) this date (use format \"yyyy-MM-dd\" or the new format \"yyyy-MM-ddThh:mm:ss\")") + private Date endDate; + + @Parameter(name=ApiConstants.START_DATE, type=CommandType.DATE, description="start date range to archive events" + + " (including) this date (use format \"yyyy-MM-dd\" or the new format \"yyyy-MM-ddThh:mm:ss\")") + private Date startDate; @Parameter(name = ApiConstants.TYPE, type = CommandType.STRING, description = "archive by event type") private String type; @@ -63,8 +67,12 @@ public class ArchiveEventsCmd extends BaseCmd { return ids; } - public Date getOlderThan() { - return olderThan; + public Date getEndDate() { + return endDate; + } + + public Date getStartDate() { + return startDate; } public String getType() { @@ -91,8 +99,10 @@ public class ArchiveEventsCmd extends BaseCmd { @Override public void execute() { - if(ids == null && type == null && olderThan == null) { - throw new InvalidParameterValueException("either ids, type or olderthan must be specified"); + if(ids == null && type == null && endDate == null) { + throw new InvalidParameterValueException("either ids, type or enddate must be specified"); + } else if (startDate != null && endDate == null) { + throw new InvalidParameterValueException("enddate must be specified with startdate parameter"); } boolean result = _mgr.archiveEvents(this); if (result) { diff --git a/api/src/org/apache/cloudstack/api/command/user/event/DeleteEventsCmd.java b/api/src/org/apache/cloudstack/api/command/user/event/DeleteEventsCmd.java index a03e6d9f7df..548c2f3fd17 100644 --- a/api/src/org/apache/cloudstack/api/command/user/event/DeleteEventsCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/event/DeleteEventsCmd.java @@ -48,8 +48,13 @@ public class DeleteEventsCmd extends BaseCmd { description = "the IDs of the events") private List ids; - @Parameter(name=ApiConstants.OLDER_THAN, type=CommandType.DATE, description="delete events older than (including) this date (use format \"yyyy-MM-dd\" or the new format \"yyyy-MM-dd HH:mm:ss\")") - private Date olderThan; + @Parameter(name=ApiConstants.END_DATE, type=CommandType.DATE, description="end date range to delete events" + + " (including) this date (use format \"yyyy-MM-dd\" or the new format \"yyyy-MM-ddThh:mm:ss\")") + private Date endDate; + + @Parameter(name=ApiConstants.START_DATE, type=CommandType.DATE, description="start date range to delete events" + + " (including) this date (use format \"yyyy-MM-dd\" or the new format \"yyyy-MM-ddThh:mm:ss\")") + private Date startDate; @Parameter(name = ApiConstants.TYPE, type = CommandType.STRING, description = "delete by event type") private String type; @@ -62,8 +67,12 @@ public class DeleteEventsCmd extends BaseCmd { return ids; } - public Date getOlderThan() { - return olderThan; + public Date getEndDate() { + return endDate; + } + + public Date getStartDate() { + return startDate; } public String getType() { @@ -90,8 +99,10 @@ public class DeleteEventsCmd extends BaseCmd { @Override public void execute() { - if(ids == null && type == null && olderThan == null) { + if(ids == null && type == null && endDate == null) { throw new InvalidParameterValueException("either ids, type or enddate must be specified"); + } else if (startDate != null && endDate == null) { + throw new InvalidParameterValueException("enddate must be specified with startdate parameter"); } boolean result = _mgr.deleteEvents(this); if (result) { diff --git a/engine/schema/src/com/cloud/alert/dao/AlertDao.java b/engine/schema/src/com/cloud/alert/dao/AlertDao.java index fda814d051d..1aa1fe0f92c 100755 --- a/engine/schema/src/com/cloud/alert/dao/AlertDao.java +++ b/engine/schema/src/com/cloud/alert/dao/AlertDao.java @@ -27,7 +27,7 @@ public interface AlertDao extends GenericDao { // This is for backward compatibility AlertVO getLastAlert(short type, long dataCenterId, Long podId); - public boolean deleteAlert(List Ids, String type, Date olderThan, Long zoneId); - public boolean archiveAlert(List Ids, String type, Date olderThan, Long zoneId); + public boolean deleteAlert(List Ids, String type, Date startDate, Date endDate, Long zoneId); + public boolean archiveAlert(List Ids, String type, Date startDate, Date endDate, Long zoneId); public List listOlderAlerts(Date oldTime); } diff --git a/engine/schema/src/com/cloud/alert/dao/AlertDaoImpl.java b/engine/schema/src/com/cloud/alert/dao/AlertDaoImpl.java index 18115a5e499..7c0a56224f3 100755 --- a/engine/schema/src/com/cloud/alert/dao/AlertDaoImpl.java +++ b/engine/schema/src/com/cloud/alert/dao/AlertDaoImpl.java @@ -41,7 +41,8 @@ public class AlertDaoImpl extends GenericDaoBase implements Alert AlertSearchByIdsAndType = createSearchBuilder(); AlertSearchByIdsAndType.and("id", AlertSearchByIdsAndType.entity().getId(), Op.IN); AlertSearchByIdsAndType.and("type", AlertSearchByIdsAndType.entity().getType(), Op.EQ); - AlertSearchByIdsAndType.and("createdDateL", AlertSearchByIdsAndType.entity().getCreatedDate(), Op.LT); + AlertSearchByIdsAndType.and("createdDateB", AlertSearchByIdsAndType.entity().getCreatedDate(), Op.BETWEEN); + AlertSearchByIdsAndType.and("createdDateL", AlertSearchByIdsAndType.entity().getCreatedDate(), Op.LTEQ); AlertSearchByIdsAndType.and("data_center_id", AlertSearchByIdsAndType.entity().getDataCenterId(), Op.EQ); AlertSearchByIdsAndType.and("archived", AlertSearchByIdsAndType.entity().getArchived(), Op.EQ); AlertSearchByIdsAndType.done(); @@ -89,7 +90,7 @@ public class AlertDaoImpl extends GenericDaoBase implements Alert } @Override - public boolean archiveAlert(List Ids, String type, Date olderThan, Long zoneId) { + public boolean archiveAlert(List Ids, String type, Date startDate, Date endDate, Long zoneId) { SearchCriteria sc = AlertSearchByIdsAndType.create(); if (Ids != null) { @@ -101,8 +102,10 @@ public class AlertDaoImpl extends GenericDaoBase implements Alert if(zoneId != null) { sc.setParameters("data_center_id", zoneId); } - if(olderThan != null) { - sc.setParameters("createdDateL", olderThan); + if (startDate != null && endDate != null) { + sc.setParameters("createdDateB", startDate, endDate); + } else if (endDate != null) { + sc.setParameters("createdDateL", endDate); } sc.setParameters("archived", false); @@ -112,20 +115,22 @@ public class AlertDaoImpl extends GenericDaoBase implements Alert result = false; return result; } - Transaction txn = Transaction.currentTxn(); - txn.start(); - for (AlertVO alert : alerts) { - alert = lockRow(alert.getId(), true); - alert.setArchived(true); - update(alert.getId(), alert); - txn.commit(); + if (alerts != null && !alerts.isEmpty()) { + Transaction txn = Transaction.currentTxn(); + txn.start(); + for (AlertVO alert : alerts) { + alert = lockRow(alert.getId(), true); + alert.setArchived(true); + update(alert.getId(), alert); + txn.commit(); + } + txn.close(); } - txn.close(); return result; } @Override - public boolean deleteAlert(List ids, String type, Date olderThan, Long zoneId) { + public boolean deleteAlert(List ids, String type, Date startDate, Date endDate, Long zoneId) { SearchCriteria sc = AlertSearchByIdsAndType.create(); if (ids != null) { @@ -137,8 +142,10 @@ public class AlertDaoImpl extends GenericDaoBase implements Alert if(zoneId != null) { sc.setParameters("data_center_id", zoneId); } - if(olderThan != null) { - sc.setParameters("createdDateL", olderThan); + if (startDate != null && endDate != null) { + sc.setParameters("createdDateB", startDate, endDate); + } else if (endDate != null) { + sc.setParameters("createdDateL", endDate); } sc.setParameters("archived", false); diff --git a/engine/schema/src/com/cloud/event/dao/EventDao.java b/engine/schema/src/com/cloud/event/dao/EventDao.java index 9454ce717de..c50451b03e4 100644 --- a/engine/schema/src/com/cloud/event/dao/EventDao.java +++ b/engine/schema/src/com/cloud/event/dao/EventDao.java @@ -31,7 +31,7 @@ public interface EventDao extends GenericDao { EventVO findCompletedEvent(long startId); - public List listToArchiveOrDeleteEvents(List ids, String type, Date olderThan, List accountIds); + public List listToArchiveOrDeleteEvents(List ids, String type, Date startDate, Date endDate, List accountIds); public void archiveEvents(List events); diff --git a/engine/schema/src/com/cloud/event/dao/EventDaoImpl.java b/engine/schema/src/com/cloud/event/dao/EventDaoImpl.java index cefe1078dbd..e5615db3433 100644 --- a/engine/schema/src/com/cloud/event/dao/EventDaoImpl.java +++ b/engine/schema/src/com/cloud/event/dao/EventDaoImpl.java @@ -51,7 +51,8 @@ public class EventDaoImpl extends GenericDaoBase implements Event ToArchiveOrDeleteEventSearch.and("id", ToArchiveOrDeleteEventSearch.entity().getId(), Op.IN); ToArchiveOrDeleteEventSearch.and("type", ToArchiveOrDeleteEventSearch.entity().getType(), Op.EQ); ToArchiveOrDeleteEventSearch.and("accountIds", ToArchiveOrDeleteEventSearch.entity().getAccountId(), Op.IN); - ToArchiveOrDeleteEventSearch.and("createDateL", ToArchiveOrDeleteEventSearch.entity().getCreateDate(), Op.LT); + ToArchiveOrDeleteEventSearch.and("createdDateB", ToArchiveOrDeleteEventSearch.entity().getCreateDate(), Op.BETWEEN); + ToArchiveOrDeleteEventSearch.and("createdDateL", ToArchiveOrDeleteEventSearch.entity().getCreateDate(), Op.LTEQ); ToArchiveOrDeleteEventSearch.and("archived", ToArchiveOrDeleteEventSearch.entity().getArchived(), Op.EQ); ToArchiveOrDeleteEventSearch.done(); } @@ -80,7 +81,7 @@ public class EventDaoImpl extends GenericDaoBase implements Event } @Override - public List listToArchiveOrDeleteEvents(List ids, String type, Date olderThan, List accountIds) { + public List listToArchiveOrDeleteEvents(List ids, String type, Date startDate, Date endDate, List accountIds) { SearchCriteria sc = ToArchiveOrDeleteEventSearch.create(); if (ids != null) { sc.setParameters("id", ids.toArray(new Object[ids.size()])); @@ -88,8 +89,10 @@ public class EventDaoImpl extends GenericDaoBase implements Event if (type != null) { sc.setParameters("type", type); } - if (olderThan != null) { - sc.setParameters("createDateL", olderThan); + if (startDate != null && endDate != null) { + sc.setParameters("createdDateB", startDate, endDate); + } else if (endDate != null) { + sc.setParameters("createdDateL", endDate); } if (accountIds != null && !accountIds.isEmpty()) { sc.setParameters("accountIds", accountIds.toArray(new Object[accountIds.size()])); diff --git a/server/src/com/cloud/api/ApiDispatcher.java b/server/src/com/cloud/api/ApiDispatcher.java index b7d08e2c872..b8862569106 100755 --- a/server/src/com/cloud/api/ApiDispatcher.java +++ b/server/src/com/cloud/api/ApiDispatcher.java @@ -49,6 +49,9 @@ import org.apache.cloudstack.api.InternalIdentity; import org.apache.cloudstack.api.Parameter; import org.apache.cloudstack.api.ServerApiException; import org.apache.cloudstack.api.Validate; +import org.apache.cloudstack.api.command.admin.resource.ArchiveAlertsCmd; +import org.apache.cloudstack.api.command.admin.resource.DeleteAlertsCmd; +import org.apache.cloudstack.api.command.admin.resource.ListAlertsCmd; import org.apache.cloudstack.api.command.user.event.ArchiveEventsCmd; import org.apache.cloudstack.api.command.user.event.DeleteEventsCmd; import org.apache.cloudstack.api.command.user.event.ListEventsCmd; @@ -381,7 +384,11 @@ public class ApiDispatcher { // This piece of code is for maintaining backward compatibility // and support both the date formats(Bug 9724) // Do the date messaging for ListEventsCmd only - if (cmdObj instanceof ListEventsCmd || cmdObj instanceof DeleteEventsCmd || cmdObj instanceof ArchiveEventsCmd) { + if (cmdObj instanceof ListEventsCmd || cmdObj instanceof DeleteEventsCmd + || cmdObj instanceof ArchiveEventsCmd + || cmdObj instanceof ArchiveAlertsCmd + || cmdObj instanceof DeleteAlertsCmd + ) { boolean isObjInNewDateFormat = isObjInNewDateFormat(paramObj.toString()); if (isObjInNewDateFormat) { DateFormat newFormat = BaseCmd.NEW_INPUT_FORMAT; @@ -396,8 +403,6 @@ public class ApiDispatcher { date = messageDate(date, 0, 0, 0); } else if (field.getName().equals("endDate")) { date = messageDate(date, 23, 59, 59); - } else if (field.getName().equals("olderThan")) { - date = messageDate(date, 0, 0, 0); } field.set(cmdObj, date); } diff --git a/server/src/com/cloud/server/ManagementServerImpl.java b/server/src/com/cloud/server/ManagementServerImpl.java index 7795bb3970e..a0b9daa9c84 100755 --- a/server/src/com/cloud/server/ManagementServerImpl.java +++ b/server/src/com/cloud/server/ManagementServerImpl.java @@ -848,7 +848,7 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe permittedAccountIds = _accountDao.getAccountIdsForDomains(permittedDomainIds); } - List events = _eventDao.listToArchiveOrDeleteEvents(ids, cmd.getType(), cmd.getOlderThan(), permittedAccountIds); + List events = _eventDao.listToArchiveOrDeleteEvents(ids, cmd.getType(), cmd.getStartDate(), cmd.getEndDate(), permittedAccountIds); ControlledEntity[] sameOwnerEvents = events.toArray(new ControlledEntity[events.size()]); _accountMgr.checkAccess(UserContext.current().getCaller(), null, true, sameOwnerEvents); @@ -875,7 +875,7 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe permittedAccountIds = _accountDao.getAccountIdsForDomains(permittedDomainIds); } - List events = _eventDao.listToArchiveOrDeleteEvents(ids, cmd.getType(), cmd.getOlderThan(), permittedAccountIds); + List events = _eventDao.listToArchiveOrDeleteEvents(ids, cmd.getType(), cmd.getStartDate(), cmd.getEndDate(), permittedAccountIds); ControlledEntity[] sameOwnerEvents = events.toArray(new ControlledEntity[events.size()]); _accountMgr.checkAccess(UserContext.current().getCaller(), null, true, sameOwnerEvents); @@ -2236,14 +2236,14 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe @Override public boolean archiveAlerts(ArchiveAlertsCmd cmd) { Long zoneId = _accountMgr.checkAccessAndSpecifyAuthority(UserContext.current().getCaller(), null); - boolean result = _alertDao.archiveAlert(cmd.getIds(), cmd.getType(), cmd.getOlderThan(), zoneId); + boolean result = _alertDao.archiveAlert(cmd.getIds(), cmd.getType(), cmd.getStartDate(), cmd.getEndDate(), zoneId); return result; } @Override public boolean deleteAlerts(DeleteAlertsCmd cmd) { Long zoneId = _accountMgr.checkAccessAndSpecifyAuthority(UserContext.current().getCaller(), null); - boolean result = _alertDao.deleteAlert(cmd.getIds(), cmd.getType(), cmd.getOlderThan(), zoneId); + boolean result = _alertDao.deleteAlert(cmd.getIds(), cmd.getType(), cmd.getStartDate(), cmd.getEndDate(), zoneId); return result; } diff --git a/server/test/com/cloud/alert/AlertControlsUnitTest.java b/server/test/com/cloud/alert/AlertControlsUnitTest.java index c1e4c5487f1..2b30246986a 100644 --- a/server/test/com/cloud/alert/AlertControlsUnitTest.java +++ b/server/test/com/cloud/alert/AlertControlsUnitTest.java @@ -53,8 +53,8 @@ public class AlertControlsUnitTest extends TestCase { _mgmtServer._alertDao = _alertDao; _mgmtServer._accountMgr = _accountMgr; doReturn(3L).when(_accountMgr).checkAccessAndSpecifyAuthority(any(Account.class), anyLong()); - when(_alertDao.archiveAlert(anyList(), anyString(), any(Date.class), anyLong())).thenReturn(true); - when(_alertDao.deleteAlert(anyList(), anyString(), any(Date.class), anyLong())).thenReturn(true); + when(_alertDao.archiveAlert(anyList(), anyString(), any(Date.class), any(Date.class), anyLong())).thenReturn(true); + when(_alertDao.deleteAlert(anyList(), anyString(), any(Date.class), any(Date.class), anyLong())).thenReturn(true); } @After @@ -72,12 +72,12 @@ public class AlertControlsUnitTest extends TestCase { protected void archiveAlerts() { // archive alerts String msg = "Archive Alerts: TEST FAILED"; - assertNotNull(msg, _mgmtServer._alertDao.archiveAlert(null, "system alert",null, 2L)); + assertNotNull(msg, _mgmtServer._alertDao.archiveAlert(null, "system alert",null, null, 2L)); } protected void deleteAlerts() { // delete alerts String msg = "Delete Alerts: TEST FAILED"; - assertNotNull(msg, _mgmtServer._alertDao.deleteAlert(null, "system alert",null, 2L)); + assertNotNull(msg, _mgmtServer._alertDao.deleteAlert(null, "system alert",null, null, 2L)); } } diff --git a/server/test/com/cloud/event/EventControlsUnitTest.java b/server/test/com/cloud/event/EventControlsUnitTest.java index e2a86cdb4be..f9003a9a4d5 100644 --- a/server/test/com/cloud/event/EventControlsUnitTest.java +++ b/server/test/com/cloud/event/EventControlsUnitTest.java @@ -57,7 +57,7 @@ public class EventControlsUnitTest extends TestCase{ _mgmtServer._eventDao = _eventDao; _mgmtServer._accountMgr = _accountMgr; doNothing().when(_accountMgr).checkAccess(any(Account.class), any(AccessType.class), any(Boolean.class), any(ControlledEntity.class)); - when(_eventDao.listToArchiveOrDeleteEvents(anyList(), anyString(), any(Date.class), anyList())).thenReturn(_events); + when(_eventDao.listToArchiveOrDeleteEvents(anyList(), anyString(), any(Date.class), any(Date.class), anyList())).thenReturn(_events); } @After