Skip to content
Permalink
Browse files

feat(api): HZN-1357 use AlarmId for Situation

  • Loading branch information...
smith-opennms committed Aug 21, 2018
1 parent e98cfa4 commit 3d9f17200e0850948c2b54dcfc33148d82a4b05b
Showing with 9 additions and 8 deletions.
  1. +6 −5 src/dao/SituationFeedbackDAO.ts
  2. +2 −2 test/dao/SituationFeedbackDAO.spec.ts
  3. +1 −1 test/rest/MockHTTP23.ts
@@ -29,13 +29,13 @@ export class SituationFeedbackDAO extends BaseDAO {
* Retrieve feedback.
*
* @version ReST v1
* @param {string} situationKey - The reductionKey of the Situation to use when querying.
* @param {number} situationId - The alarmId of the Situation to use when querying.
* @return An array of [[OnmsSituationFeedback]] objects.
*/
public async getFeedback(situationKey: string): Promise<OnmsSituationFeedback[]> {
public async getFeedback(situationId: number): Promise<OnmsSituationFeedback[]> {
const options = new OnmsHTTPOptions();
options.headers.accept = 'application/json';
return this.http.get(this.pathToEndpoint() + '/' + encodeURIComponent(situationKey), options).then((result) => {
return this.http.get(this.pathToEndpoint() + '/' + situationId, options).then((result) => {
const data = this.getData(result);
if (!Array.isArray(data)) {
if (!data) {
@@ -53,12 +53,13 @@ export class SituationFeedbackDAO extends BaseDAO {
* Submit Correlation Feedback for a Situation.
*
* @version ReST v1
* @param {number} situationId - The alarmId of the Situation to use when querying.
* @param {OnmsSituationFeedback[]} feedback - The [[OnmsSituationFeedback]].
*/
public async saveFeedback(feedback: OnmsSituationFeedback[], situationKey: string): Promise<void> {
public async saveFeedback(feedback: OnmsSituationFeedback[], situationId: number): Promise<void> {
const parameters = {} as IHash<string>;
parameters.body = JSON.stringify(feedback);
return this.post(this.pathToEndpoint() + '/' + situationKey, parameters);
return this.post(this.pathToEndpoint() + '/' + situationId, parameters);
}

/**
@@ -42,8 +42,8 @@ describe('SituationfeedbackDAO with v1 API', () => {
done();
});
});
it('SituationFeedbackDAO.get(FEEDBACK_F)', () => {
return dao.getFeedback('uei.opennms.org/alarms/trigger:localhost:0.0.0.0:FEEDBACK_F').then((feedback) => {
it('SituationFeedbackDAO.get(210)', () => {
return dao.getFeedback(210).then((feedback) => {
expect(feedback).toHaveLength(4);
expect(feedback[0].alarmKey).toEqual('uei.opennms.org/alarms/trigger:localhost:0.0.0.0:FEEDBACK_C');
expect(feedback[0].fingerprint).toEqual('NDg3ZjdiMjJmNjgzMTJkMmMxYmJjOTNiMWFlYTQ0NWI=');
@@ -32,7 +32,7 @@ export class MockHTTP23 extends AbstractHTTP {
result.type = 'application/json';
return Promise.resolve(result);
}
case 'rest/situation-feedback/uei.opennms.org%2Falarms%2Ftrigger%3Alocalhost%3A0.0.0.0%3AFEEDBACK_F': {
case 'rest/situation-feedback/210': {
const result = OnmsResult.ok(require('./23.0.0/get/rest/situation-feedback/feedback.json'));
result.type = 'application/json';
return Promise.resolve(result);

0 comments on commit 3d9f172

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