Skip to content
Permalink
Browse files

feat(api): OCE-REST updte tests

  • Loading branch information...
smith-opennms committed Sep 5, 2018
1 parent d3bb9e9 commit abd86d199a18c8cc6942aef67aac9605743de695
Showing with 186 additions and 0 deletions.
  1. +24 −0 test/dao/AlarmDAO.spec.ts
  2. +157 −0 test/rest/23.0.0/get/api/v2/alarms/243.json
  3. +5 −0 test/rest/MockHTTP23.ts
@@ -302,3 +302,27 @@ describe('AlarmDAO with AlarmSummaryDTO', () => {
});
});
});

describe('Extended Situation tests', () => {
beforeEach((done) => {
auth = new OnmsAuthConfig(SERVER_USER, SERVER_PASSWORD);
server = new OnmsServer(SERVER_NAME, SERVER_URL, auth);
mockHTTP = new MockHTTP23(server);
opennms = new Client(mockHTTP);
dao = new AlarmDAO(mockHTTP);
Client.getMetadata(server, mockHTTP).then((metadata) => {
server.metadata = metadata;
done();
});
});
it('AlarmDAO.get(situations)', () => {
const filter = new Filter();
filter.withOrRestriction(new Restriction('isSituation', Comparators.EQ, 'true'));
return dao.find(filter).then((alarms) => {
expect(alarms.length).toEqual(1);
expect(alarms[0].id).toEqual(243);
expect(alarms[0].relatedAlarms.length).toEqual(3);
expect(alarms[0].affectedNodeCount).toEqual(1);
});
});
});
@@ -0,0 +1,157 @@
{
"totalCount": 1,
"count": 1,
"offset": 0,
"alarm": [
{
"id": 243,
"uei": "uei.opennms.org/alarms/trigger",
"location": "Default",
"nodeId": 1,
"nodeLabel": "locally",
"reductionKey": "uei.opennms.org/alarms/trigger:localhost:0.0.0.0:FEEDBACK_F",
"type": 1,
"count": 1,
"severity": "CRITICAL",
"firstEventTime": 1536070358000,
"description": "A problem has been triggered.",
"logMessage": "A problem has been triggered on localhost/0.0.0.0/FEEDBACK_F.",
"suppressedUntil": 1536070358000,
"suppressedTime": 1536070358000,
"lastEvent": {
"id": 18766,
"uei": "uei.opennms.org/alarms/trigger",
"label": "Alarm: Generic Trigger",
"time": 1536070358000,
"host": "LAPTOP-CPLHKS5S.localdomain",
"source": "perl_send_event",
"parameters": [
{
"name": "cat1",
"value": "ENVIRONMENTAL",
"type": "string"
},
{
"name": "cat2",
"value": "HUMIDITY",
"type": "string"
},
{
"name": "hexcode",
"value": "0xfff06131",
"type": "string"
},
{
"name": "ip",
"value": "0.0.0.0",
"type": "string"
},
{
"name": "node",
"value": "localhost",
"type": "string"
},
{
"name": "related-reductionKey",
"value": "uei.opennms.org/alarms/trigger:localhost:0.0.0.0:FEEDBACK_A",
"type": "string"
},
{
"name": "service",
"value": "FEEDBACK_F",
"type": "string"
},
{
"name": "type",
"value": "ENV",
"type": "string"
}
],
"createTime": 1536070358205,
"description": "A problem has been triggered.",
"logMessage": "A problem has been triggered on localhost/0.0.0.0/FEEDBACK_F.",
"severity": "CRITICAL",
"log": "Y",
"display": "Y",
"nodeId": 1,
"nodeLabel": "locally",
"location": "Default"
},
"parameters": [
{
"name": "cat1",
"value": "ENVIRONMENTAL",
"type": "string"
},
{
"name": "cat2",
"value": "HUMIDITY",
"type": "string"
},
{
"name": "hexcode",
"value": "0xfff06131",
"type": "string"
},
{
"name": "ip",
"value": "0.0.0.0",
"type": "string"
},
{
"name": "node",
"value": "localhost",
"type": "string"
},
{
"name": "related-reductionKey",
"value": "uei.opennms.org/alarms/trigger:localhost:0.0.0.0:FEEDBACK_A",
"type": "string"
},
{
"name": "service",
"value": "FEEDBACK_F",
"type": "string"
},
{
"name": "type",
"value": "ENV",
"type": "string"
}
],
"lastEventTime": 1536070358000,
"x733ProbableCause": 0,
"ifIndex": null,
"relatedAlarms": [
{
"id": 240,
"type": 2,
"severity": "CRITICAL",
"reductionKey": "uei.opennms.org/alarms/trigger:localhost:0.0.0.0:FEEDBACK_A",
"description": "A problem has been triggered.",
"label": "Alarm: Generic Trigger",
"logMessage": "A problem has been triggered on localhost/0.0.0.0/FEEDBACK_A."
},
{
"id": 241,
"type": 2,
"severity": "CRITICAL",
"reductionKey": "uei.opennms.org/alarms/trigger:localhost:0.0.0.0:FEEDBACK_B",
"description": "A problem has been triggered.",
"label": "Alarm: Generic Trigger",
"logMessage": "A problem has been triggered on localhost/0.0.0.0/FEEDBACK_B."
},
{
"id": 242,
"type": 2,
"severity": "CRITICAL",
"reductionKey": "uei.opennms.org/alarms/trigger:localhost:0.0.0.0:FEEDBACK_C",
"description": "A problem has been triggered.",
"label": "Alarm: Generic Trigger",
"logMessage": "A problem has been triggered on localhost/0.0.0.0/FEEDBACK_C."
}
],
"affectedNodeCount": 1
}
]
}
@@ -37,6 +37,11 @@ export class MockHTTP23 extends AbstractHTTP {
result.type = 'application/json';
return Promise.resolve(result);
}
case 'api/v2/alarms?limit=1000&_s=isSituation%3D%3Dtrue': {
const result = OnmsResult.ok(require('./23.0.0/get/api/v2/alarms/243.json'));
result.type = 'application/json';
return Promise.resolve(result);
}
}

throw new Error('Not yet implemented: GET ' + urlObj.toString());

0 comments on commit abd86d1

Please sign in to comment.
You can’t perform that action at this time.