Skip to content

Commit

Permalink
feat(alarms): HELM-114: alarm property for whether it is a situation
Browse files Browse the repository at this point in the history
  • Loading branch information
Benjamin Reed committed Dec 3, 2018
1 parent 940f11c commit a54b627
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/model/OnmsAlarm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
3 changes: 3 additions & 0 deletions test/dao/AlarmDAO.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
});
Expand Down

0 comments on commit a54b627

Please sign in to comment.