Skip to content

Commit

Permalink
Merge pull request #1 from lucasponce/AddNotes
Browse files Browse the repository at this point in the history
Add support for Alert notes
  • Loading branch information
jshaughn committed Oct 16, 2015
2 parents cb6c340 + 791c587 commit 6c8e722
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 7 deletions.
45 changes: 38 additions & 7 deletions src/rest/hawkRest-alert-provider.spec.rest.js
Original file line number Diff line number Diff line change
Expand Up @@ -707,14 +707,41 @@ describe('Provider: Hawkular Alerts live REST =>', function() {
if ( alerts.length != 1 ) {
return $q.reject('Alert not found');
}
var alert = alerts[0];
alert = alerts[0];
return HawkularAlert.Alert.get({alertId:alert.alertId}).$promise;
},
// Error, fetch
function (errorFetch) {
errorFn(errorfetch);
return $q.reject('Error on Alert Fetch');
}
).then(
// Success, get
function(singleAlert) {
debug && dump(JSON.stringify(singleAlert));
if ( null == singleAlert ) {
return $q.reject('Alert not found');
}
alert = singleAlert;
return HawkularAlert.Alert.note({alertId: alert.alertId, user: 'user1', text: 'user1notes'}).$promise;
},
// Error, get
function (errorFetch) {
errorFn(errorFetch);
return $q.reject('Error on Alert Get');
}
).then(
// Sucess, note
function() {
debug && dump('Note should be added');
return HawkularAlert.Alert.get({alertId:alert.alertId}).$promise;
},
// Error, note
function (errorFetch) {
errorFn(errorFetch);
return $q.reject('Error on Alert Get');
}

).then(
// Success, get
function(singleAlert) {
Expand All @@ -738,6 +765,8 @@ describe('Provider: Hawkular Alerts live REST =>', function() {

it ('should get list of single alert', function() {
expect(alert.status).toEqual('OPEN');
expect(alert.notes[0].user).toEqual('user1');
expect(alert.notes[0].text).toEqual('user1notes');
});

});
Expand Down Expand Up @@ -833,8 +862,9 @@ describe('Provider: Hawkular Alerts live REST =>', function() {
it ('should get acknowledged alert', function() {
expect(alert.status).toEqual('ACKNOWLEDGED');
expect(alert.ackBy).toEqual('ackBy');
expect(alert.notes[0].text).toEqual('ackNotes');
expect(alert.notes[1].text).toEqual('ackManyNotes');
expect(alert.notes[0].text).toEqual('user1notes');
expect(alert.notes[1].text).toEqual('ackNotes');
expect(alert.notes[2].text).toEqual('ackManyNotes');
});

});
Expand Down Expand Up @@ -931,10 +961,11 @@ describe('Provider: Hawkular Alerts live REST =>', function() {
it ('should get resolved alert', function() {
expect(alert.status).toEqual('RESOLVED');
expect(alert.resolvedBy).toEqual('resolvedBy');
expect(alert.notes[0].text).toEqual('ackNotes');
expect(alert.notes[1].text).toEqual('ackManyNotes');
expect(alert.notes[2].text).toEqual('resolvedNotes');
expect(alert.notes[3].text).toEqual('resolvedManyNotes');
expect(alert.notes[0].text).toEqual('user1notes');
expect(alert.notes[1].text).toEqual('ackNotes');
expect(alert.notes[2].text).toEqual('ackManyNotes');
expect(alert.notes[3].text).toEqual('resolvedNotes');
expect(alert.notes[4].text).toEqual('resolvedManyNotes');
});

});
Expand Down
8 changes: 8 additions & 0 deletions src/rest/hawkRest-alert-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,14 @@ module hawkularRest {
method: 'PUT',
url: prefix + '/hawkular/alerts/resolve'
},
note: {
method: 'PUT',
url: prefix + '/hawkular/alerts/note/:alertId',
params: {
user: '@user',
text: '@text'
}
},
send: {
method: 'POST',
url: prefix + '/hawkular/alerts/data'
Expand Down

0 comments on commit 6c8e722

Please sign in to comment.