use of alma.alarmsystem.clients.alarm.AlarmFilter in project ACS by ACS-Community.
the class AlarmFilterTest method testFaultCodeFiltering.
public void testFaultCodeFiltering() throws Exception {
// Test the min only
AlarmFilter filter = new AlarmFilter(null, null, 5, null);
assertNotNull("Invalid null filter", filter);
// These pass
assertTrue(filter.matches("FF0", "member", 5));
assertTrue(filter.matches("FF ", "mem ", 6));
assertTrue(filter.matches("FF2", "memb1r", 1254));
// These do not pass
assertFalse(filter.matches("FF", "mMMaaa", 4));
assertFalse(filter.matches("FF", "member", 0));
// Test the max only
filter = new AlarmFilter(null, null, null, 10);
assertNotNull("Invalid null filter", filter);
// These pass
assertTrue(filter.matches("FF0", "member", 10));
assertTrue(filter.matches("FF ", "mem ", 6));
assertTrue(filter.matches("FF2", "memb1r", 0));
// These do not pass
assertFalse(filter.matches("FF", "mMMaaa", 40));
assertFalse(filter.matches("FF", "member", 11));
// Test the [min,max] only
filter = new AlarmFilter(null, null, 21, 100);
assertNotNull("Invalid null filter", filter);
// These pass
assertTrue(filter.matches("FF0", "member", 100));
assertTrue(filter.matches("FF ", "mem ", 21));
assertTrue(filter.matches("FF2", "memb1r", 50));
// These do not pass
assertFalse(filter.matches("FF", "mMMaaa", 0));
assertFalse(filter.matches("FF", "member", 200));
assertFalse(filter.matches("FF", "mMMaaa", 20));
assertFalse(filter.matches("FF", "member", 101));
// Filters with the same min and max
filter = new AlarmFilter(null, null, 10, 10);
assertNotNull("Invalid null filter", filter);
// These pass
assertTrue(filter.matches("FF0", "member", 10));
// These do not pass
assertFalse(filter.matches("FF", "mMMaaa", 9));
assertFalse(filter.matches("FF", "member", 11));
assertFalse(filter.matches("FF", "mMMaaa", 0));
assertFalse(filter.matches("FF", "member", 1354));
}
use of alma.alarmsystem.clients.alarm.AlarmFilter in project ACS by ACS-Community.
the class AlarmFilterTest method testInvalidInstantiation.
/**
* It is not possible to instantiate a filter without constraints
*/
public void testInvalidInstantiation() throws Exception {
try {
AlarmFilter filter = new AlarmFilter(null, null, null, null);
System.out.println("THis line must not be in the output");
} catch (Throwable t) {
// This is ok
}
try {
AlarmFilter filter = new AlarmFilter(null, null, 10, 5);
System.out.println("Neither this line must be in the output");
} catch (Throwable t) {
// This is ok
}
}
use of alma.alarmsystem.clients.alarm.AlarmFilter in project ACS by ACS-Community.
the class AlarmCategoryClientTest method setUp.
/**
* @see extends ComponentClientTestCase
*/
public void setUp() throws Exception {
super.setUp();
categoryClient = new AlarmCategoryClient(getContainerServices());
assertNotNull(categoryClient);
AlarmFilter filter = new AlarmFilter(null, null, 2, 2);
filteredLister = new AlarmListenerForTesting("Filtered_listener");
assertNotNull(filteredLister);
categoryClient.addAlarmListener(this);
categoryClient.addAlarmListener(filteredLister, filter);
statListener = new AlrmStatListenerForTesting();
assertNotNull(statListener);
categoryClient.addStatsListener(statListener);
alarmsReceived = new Vector<Alarm>();
}
use of alma.alarmsystem.clients.alarm.AlarmFilter in project ACS by ACS-Community.
the class AlarmFilterTest method testFaultFamilyFiltering.
public void testFaultFamilyFiltering() throws Exception {
AlarmFilter filter = new AlarmFilter("[a-z]+", null, null, null);
assertNotNull("Invalid null filter", filter);
// These all pass
assertTrue(filter.matches("test", "Whatever", 1));
assertTrue(filter.matches("alarm", "Whatever", 1));
assertTrue(filter.matches("onealarm", "99", 0));
// These must be rejected
assertFalse(filter.matches("Test", "Whatever", 1));
assertFalse(filter.matches("test2", "alone", 123));
assertFalse(filter.matches("No alarm", "A99G", 0));
}
use of alma.alarmsystem.clients.alarm.AlarmFilter in project ACS by ACS-Community.
the class AlarmFilterTest method testFiltering.
/**
* Test a complete filtering
*/
public void testFiltering() throws Exception {
// Test the min only
AlarmFilter filter = new AlarmFilter("[A-Z]+", "[a-z]+[0-9]+", 5, 10);
assertNotNull("Invalid null filter", filter);
// These pass
assertTrue(filter.matches("FF", "member1", 7));
assertTrue(filter.matches("FAMILY", "member2", 5));
assertTrue(filter.matches("THEFAMILY", "alarm982", 10));
// These do not pass
assertFalse(filter.matches("F1", "member2", 0));
assertFalse(filter.matches("FF", "member", 7));
assertFalse(filter.matches("ALARM", "memberq2222", 122));
assertFalse(filter.matches("FF", "2member2", 32));
assertFalse(filter.matches("ALARM family", "member2", 1001));
}
Aggregations