Skip to content
Snippets Groups Projects
Commit 415b2963 authored by Thiemo Belmega's avatar Thiemo Belmega
Browse files

Add supercategory and subcategories to Category.class

parent 4cd5356f
No related branches found
No related tags found
No related merge requests found
......@@ -8,9 +8,13 @@ import static de.unipotsdam.cs.toolup.database.DatabaseController.TABLE_NAME_APP
public class Category extends BusinessObject {
private String superCategory;
private Collection<String> subCategories;
public Category(String uuid, String title, String description, Set<String> relatedApplications) {
super(uuid, title, description);
this.relations.put(TABLE_NAME_APPLICATION, relatedApplications);
this.subCategories = new HashSet<>();
}
public Category(String uuid) {
......@@ -20,4 +24,20 @@ public class Category extends BusinessObject {
public Collection<String> getRelatedApplications() {
return new HashSet<>(this.relations.get(TABLE_NAME_APPLICATION));
}
public String getSuperCategory() {
return superCategory;
}
public void setSuperCategory(String superCategory) {
this.superCategory = superCategory;
}
public Collection<String> getSubCategories() {
return new HashSet<>(subCategories);
}
public void addSubCategories(Collection<String> subcategories) {
this.subCategories.addAll(subcategories);
}
}
package de.unipotsdam.cs.toolup.model;
import org.testng.annotations.Test;
import java.util.Arrays;
import java.util.Collection;
import static de.unipotsdam.cs.toolup.util.AssertionUtil.assertCollectionEquals;
import static org.testng.Assert.assertEquals;
public class CategoryTest extends BusinessObjectTest {
@Test
public void testThatCategoryMayHaveSuperCategory() {
//arrange
Category cat = new Category(CATEGORY_TEST_ID_11, null, null, null);
String superCategoryId = CATEGORY_TEST_ID_13;
//act
cat.setSuperCategory(superCategoryId);
//assert
assertEquals(superCategoryId, cat.getSuperCategory());
}
@Test
public void testThatCategoryMayHaveSubCategories() {
//arrange
Category cat = new Category(CATEGORY_TEST_ID_13, null, null, null);
Collection<String> subcategories = Arrays.asList(CATEGORY_TEST_ID_11, CATEGORY_TEST_ID_12);
//act
cat.addSubCategories(subcategories);
//assert
assertCollectionEquals(subcategories, cat.getSubCategories());
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment