use of alma.acs.alarmsystem.generated.Category in project ACS by ACS-Community.
the class CategoryManager method addCategory.
/**
* Add a new Category. If there is a Category with the same name that the given Category, the new Category cannot be added
* @param c The Category to be added
* @return True If the Category is added , False otherwise
* @throws IllegalOperationException If the Category to add already exists
* @throws NullPointerException If the Category is null
*/
public boolean addCategory(Category c) throws IllegalOperationException, NullPointerException {
if (c == null || c.getPath() == null)
throw new NullPointerException("The category to be added (or its name) is null");
for (Category ctg : _categoryList) if (ctg.getPath().compareTo(c.getPath()) == 0)
throw new IllegalOperationException("The Category already exists");
c.setIsDefault(false);
_categoryList.add(c);
ObjectState os = _objState.get(c.getPath());
if (os == null) {
os = new ObjectState(true);
os.create();
_objState.put(c.getPath(), os);
} else
os.update();
return true;
}
use of alma.acs.alarmsystem.generated.Category in project ACS by ACS-Community.
the class CategoryManagerTest method testAddCategory.
public void testAddCategory() throws IllegalOperationException {
List<Category> categories1 = cm.getAllCategories();
assertNotNull(categories1);
Category c = new Category();
c.setPath("NEW CATEGORY");
cm.addCategory(c);
List<Category> categories2 = cm.getAllCategories();
assertNotNull(categories2);
assertEquals(categories1.size(), categories2.size());
boolean check = false;
for (Iterator<Category> iterator = categories2.iterator(); iterator.hasNext(); ) {
Category ctg = (Category) iterator.next();
if (ctg.getPath().compareTo("NEW CATEGORY") == 0) {
check = true;
}
}
assertTrue(check);
check = false;
try {
cm.addCategory(c);
} catch (IllegalOperationException e) {
check = true;
}
assertTrue(check);
}
use of alma.acs.alarmsystem.generated.Category in project ACS by ACS-Community.
the class CategoryManagerTest method testGetAllCategories.
public void testGetAllCategories() {
CategoryManager cm = _alarmSystemManager.getCategoryManager();
assertNotNull(cm);
cm.loadFromCDB();
List<Category> categories = cm.getAllCategories();
assertNotNull(categories);
for (Category category : categories) assertNotNull(category);
}
use of alma.acs.alarmsystem.generated.Category in project ACS by ACS-Community.
the class CategoryManagerTest method testGetCategoryByPath.
public void testGetCategoryByPath() {
CategoryManager cm = _alarmSystemManager.getCategoryManager();
cm.loadFromCDB();
List<Category> categories = cm.getAllCategories();
Category category2 = null;
for (Category category : categories) {
category2 = cm.getCategoryByPath(category.getPath());
assertNotNull(category2);
assertEquals(category, category2);
}
}
use of alma.acs.alarmsystem.generated.Category in project ACS by ACS-Community.
the class ACSCategoryDAOImplTest method testUpdateCategory.
public void testUpdateCategory() {
//boolean exception;
Category c1;
c1 = new Category();
c1.setPath("Foobar");
c1.setDescription("Foobar Category2");
c1.setIsDefault(false);
Alarms alarms = new Alarms();
alarms.addFaultFamily("ffTest");
c1.setAlarms(alarms);
Categories cats = _categoryDAO.getCategories();
_categoryDAO.updateCategory(cats, c1);
}
Aggregations