/
AlertFindByResource_test.java
72 lines (59 loc) · 2.71 KB
/
AlertFindByResource_test.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
package org.hyperic.hq.hqapi1.test;
import org.hyperic.hq.hqapi1.types.AlertDefinition;
import org.hyperic.hq.hqapi1.types.AlertsResponse;
import org.hyperic.hq.hqapi1.types.StatusResponse;
import org.hyperic.hq.hqapi1.types.Resource;
import org.hyperic.hq.hqapi1.types.Alert;
import org.hyperic.hq.hqapi1.AlertApi;
public class AlertFindByResource_test extends AlertTestBase {
public AlertFindByResource_test(String name) {
super(name);
}
public void testFindValid() throws Exception {
Resource r = getLocalPlatformResource(false, false);
AlertDefinition d = generateAlerts(r);
AlertApi api = getAlertApi();
AlertsResponse response = api.findAlerts(r, 0, System.currentTimeMillis(),
10, 1, false, false);
hqAssertSuccess(response);
assertTrue(response.getAlert().size() <= 10);
assertTrue(response.getAlert().size() > 0);
for (Alert a : response.getAlert()) {
validateAlert(a);
}
// Cleanup
StatusResponse deleteResponse = getApi().getAlertDefinitionApi().
deleteAlertDefinition(d.getId());
hqAssertSuccess(deleteResponse);
}
public void testFindInvalidSeverity() throws Exception {
Resource r = getLocalPlatformResource(false, false);
AlertApi api = getAlertApi();
AlertsResponse response = api.findAlerts(r, 0, System.currentTimeMillis(),
10, 4, false, false);
hqAssertFailureInvalidParameters(response);
}
public void testFindInvalidCount() throws Exception {
Resource r = getLocalPlatformResource(false, false);
AlertApi api = getAlertApi();
AlertsResponse response = api.findAlerts(r, 0, System.currentTimeMillis(),
-5, 2, false, false);
hqAssertFailureInvalidParameters(response);
}
public void testFindInvalidRange() throws Exception {
Resource r = getLocalPlatformResource(false, false);
AlertApi api = getAlertApi();
AlertsResponse response = api.findAlerts(r, System.currentTimeMillis(), 0,
10, 2, false, false);
hqAssertFailureInvalidParameters(response);
}
public void testFindInvalidResource() throws Exception {
Resource r = new Resource();
r.setId(Integer.MAX_VALUE);
r.setName("Invalid resource");
AlertApi api = getAlertApi();
AlertsResponse response = api.findAlerts(r, 0, System.currentTimeMillis(),
10, 1, false, false);
hqAssertFailureObjectNotFound(response);
}
}