Permalink
Browse files

feat(dao): add user parameter to unack (JS-19)

  • Loading branch information...
RangerRick committed Aug 16, 2017
1 parent abdfc0b commit 90c128d7c5eeda912c434aed4f2c387c90e52b22
Showing with 26 additions and 1 deletion.
  1. +4 −1 src/dao/AlarmDAO.ts
  2. +12 −0 test/dao/AlarmDAO.spec.ts
  3. +5 −0 test/rest/MockHTTP19.ts
  4. +5 −0 test/rest/MockHTTP21.ts
View
@@ -122,10 +122,13 @@ export class AlarmDAO extends AbstractDAO<number, OnmsAlarm> {
* @version ReST v1+
* @param {number|OnmsAlarm} alarm - The [[OnmsAlarm]] or alarm ID.
*/
public async unacknowledge(alarm: number|OnmsAlarm): Promise<void> {
public async unacknowledge(alarm: number|OnmsAlarm, user?: string): Promise<void> {
const alarmId = (typeof(alarm) === 'number' ? alarm : alarm.id);
const parameters = {} as IHash<string>;
parameters.ack = 'false';
if (user !== undefined) {
parameters.ackUser = user;
}
return this.put(this.pathToAlarmsEndpoint() + '/' + alarmId, parameters);
}
View
@@ -69,6 +69,12 @@ describe('AlarmDAO with v1 API', () => {
return dao[method](alarm);
});
}
it('AlarmDAO.acknowledge(id=404725, user=ranger)', () => {
return dao.acknowledge(404725, 'ranger');
});
it('AlarmDAO.unacknowledge(id=404725, user=ranger)', () => {
return dao.unacknowledge(404725, 'ranger');
});
it('AlarmDAO.setTTicketId(alarmId=404725, ticketId=abcde)', () => {
return dao.setTTicketId(404725, 'abcde');
@@ -199,6 +205,12 @@ describe('AlarmDAO with v2 API', () => {
return dao[method](alarm);
});
}
it('AlarmDAO.acknowledge(id=404725, user=ranger)', () => {
return dao.acknowledge(404725, 'ranger');
});
it('AlarmDAO.unacknowledge(id=404725, user=ranger)', () => {
return dao.unacknowledge(404725, 'ranger');
});
it('AlarmDAO.setTTicketId(alarmId=404725, ticketId=abcde)', () => {
return dao.setTTicketId(404725, 'abcde');
View
@@ -87,6 +87,11 @@ export class MockHTTP19 extends AbstractHTTP {
result.type = 'text/plain';
return Promise.resolve(result);
}
case 'rest/alarms/404725?ack=false&ackUser=ranger': {
const result = OnmsResult.ok('');
result.type = 'text/plain';
return Promise.resolve(result);
}
case 'rest/alarms/404725?ack=false': {
const result = OnmsResult.ok('');
result.type = 'text/plain';
View
@@ -99,6 +99,11 @@ export class MockHTTP21 extends AbstractHTTP {
result.type = 'text/plain';
return Promise.resolve(result);
}
case 'api/v2/alarms/404725?ack=false&ackUser=ranger': {
const result = OnmsResult.ok('');
result.type = 'text/plain';
return Promise.resolve(result);
}
case 'api/v2/alarms/404725?ack=false': {
const result = OnmsResult.ok('');
result.type = 'text/plain';

0 comments on commit 90c128d

Please sign in to comment.