From a54b6270566c282b57c42a3f88d662a373ebe44c Mon Sep 17 00:00:00 2001 From: Benjamin Reed Date: Mon, 3 Dec 2018 14:21:23 -0500 Subject: [PATCH] feat(alarms): HELM-114: alarm property for whether it is a situation --- src/model/OnmsAlarm.ts | 5 +++++ test/dao/AlarmDAO.spec.ts | 3 +++ 2 files changed, 8 insertions(+) diff --git a/src/model/OnmsAlarm.ts b/src/model/OnmsAlarm.ts index 8c56c86cb..8b9d60d64 100644 --- a/src/model/OnmsAlarm.ts +++ b/src/model/OnmsAlarm.ts @@ -116,6 +116,11 @@ export class OnmsAlarm implements IHasUrlValue { /** link to the alarm details page on the source instance */ public detailsPage: string; + /** whether the alarm is a situation */ + public get isSituation() { + return this.relatedAlarms && this.relatedAlarms.length > 0; + } + public get urlValue() { return String(this.id); } diff --git a/test/dao/AlarmDAO.spec.ts b/test/dao/AlarmDAO.spec.ts index dcdc2e24a..7af6744b9 100644 --- a/test/dao/AlarmDAO.spec.ts +++ b/test/dao/AlarmDAO.spec.ts @@ -167,6 +167,7 @@ describe('AlarmDAO with v2 API', () => { expect(alarm.id).toEqual(6806); // Spot check some of the known properties expect(alarm.location).toEqual('Default'); + expect(alarm.isSituation).not.toBeTruthy(); expect(alarm.lastEvent.label).toEqual('OpenNMS-defined node event: nodeDown'); expect(alarm.lastEvent.location).toEqual('Default'); expect(alarm.detailsPage).toEqual('http://demo.opennms.org/opennms/alarm/detail.htm?id=6806'); @@ -293,6 +294,7 @@ describe('AlarmDAO with AlarmSummaryDTO', () => { return dao.find(filter).then((alarms) => { expect(alarms.length).toEqual(4); expect(alarms[0].id).toEqual(8); + expect(alarms[0].isSituation).toBeTruthy(); expect(alarms[0].relatedAlarms.length).toEqual(3); expect(alarms[0].relatedAlarms[0].id).toEqual(5); expect(alarms[0].relatedAlarms[0].type).toEqual(2); @@ -321,6 +323,7 @@ describe('Extended Situation tests', () => { return dao.find(filter).then((alarms) => { expect(alarms.length).toEqual(1); expect(alarms[0].id).toEqual(243); + expect(alarms[0].isSituation).toBeTruthy(); expect(alarms[0].relatedAlarms.length).toEqual(3); expect(alarms[0].affectedNodeCount).toEqual(1); });