### Question:
CategoryDatastore extends CommonDatastore<CategoryItem, Category> implements
        DatastoreHasSearch<CategoryItem>,
        DatastoreHasGet<CategoryItem>,
        DatastoreHasDelete,
        DatastoreHasAdd<CategoryItem>,
        DatastoreHasUpdate<CategoryItem> { @Override public CategoryItem add(final CategoryItem item) { try { final Category result = getProcessAPI().createCategory(item.getName(), item.getDescription()); return convertEngineToConsoleItem(result); } catch (final AlreadyExistsException e) { throw new APIForbiddenException(new _("Category with name %categoryName% already exists", new Arg("categoryName", item.getName())), e); } catch (final Exception e) { throw new APIException(e); } } CategoryDatastore(final APISession engineSession); long getNumberOfCategories(); long getNumberOfCategories(long processId); @Override ItemSearchResult<CategoryItem> search(final int page, final int resultsByPage, final String search, final String orders,
            final Map<String, String> filters); @Override CategoryItem add(final CategoryItem item); @Override CategoryItem get(final APIID id); @Override void delete(final List<APIID> ids); @Override CategoryItem update(final APIID id, final Map<String, String> attributes);  }### Answer:
@SuppressWarnings("unchecked") @Test(expected = APIForbiddenException.class) public void addingTwiceSameCategoryIsForbidden() throws Exception { when(processAPI.createCategory(anyString(), anyString())).thenThrow(new AlreadyExistsException("category already exists")); categoryDatastore.add(aCategoryItem().build()); }