### Question:
MongoDbWidget extends WidgetImpl { @Override public List<Category> getCategories() { ensureCategoryIds(); List<Category> categories = super.getCategories(); if(categories == null || categories.isEmpty()) { categories = createCategoriesFromIds(); } return categories; } MongoDbWidget();  MongoDbWidget(String id); List<String> getCategoryIds(); void setCategoryIds(List<String> categoryIds); CategoryRepository getCategoryRepository(); void setCategoryRepository(CategoryRepository categoryRepository); @Override List<Category> getCategories(); @Override boolean equals(Object o); @Override int hashCode();  }### Answer:
@Test public void getCategories_Null(){ List<Category> categoryList = new ArrayList<Category>(); widget.setCategories(categoryList); assertNotNull(widget.getCategories()); }
@Test public void getCategories_Null_Categories_Full(){ List<Category> categoryList = new ArrayList<Category>(); categoryList.add(new CategoryImpl()); widget.setCategories(categoryList); assertThat(categoryList, is(sameInstance(widget.getCategories()))); }