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

CategoryBean provides super and sub categories

parent 465be5ce
No related branches found
No related tags found
No related merge requests found
......@@ -14,10 +14,14 @@ import java.util.Map;
public class CategoryBean extends BusinessObjectBean{
private Collection<String> applications;
private String superCategory;
private Collection<String> subCategories;
public CategoryBean(Category cat) {
super(cat);
this.applications = cat.getRelatedApplications();
this.superCategory = cat.getSuperCategory();
this.subCategories = cat.getSubCategories();
}
......@@ -36,6 +40,14 @@ public class CategoryBean extends BusinessObjectBean{
}
return result;
}
public String getSuperCategory() {
return superCategory;
}
public Collection<String> getSubCategories() {
return subCategories;
}
}
......
......@@ -9,7 +9,7 @@ import java.util.Collection;
import static de.unipotsdam.cs.toolup.model.BusinessObjectTest.*;
import static de.unipotsdam.cs.toolup.util.AssertionUtil.assertCollectionEquals;
import static org.testng.Assert.assertEquals;
import static org.testng.AssertJUnit.assertEquals;
public class DatabaseControllerForCategoryTest extends AbstractDatabaseTest {
......
......@@ -5,10 +5,11 @@ import org.testng.annotations.Test;
import java.util.Arrays;
import java.util.Collection;
import static de.unipotsdam.cs.toolup.model.BusinessObjectTest.*;
import static de.unipotsdam.cs.toolup.util.AssertionUtil.assertCollectionEquals;
import static org.testng.Assert.assertEquals;
import static org.testng.AssertJUnit.assertEquals;
public class CategoryTest extends BusinessObjectTest {
public class CategoryTest {
@Test
public void testThatCategoryMayHaveSuperCategory() {
......
package de.unipotsdam.cs.toolup.ws.beans;
import org.testng.annotations.Test;
import java.util.Arrays;
import java.util.Collection;
import static de.unipotsdam.cs.toolup.model.BusinessObjectTest.*;
import static de.unipotsdam.cs.toolup.util.AssertionUtil.assertCollectionEquals;
import static org.testng.AssertJUnit.assertEquals;
public class CategoryBeanTest {
@Test
public void testThatCategoryBeanHasSuperCategoryField() throws Exception {
//arrange
String expectedSuperCategoryId = CATEGORY_TEST_ID_13;
//act
CategoryBean bean = CategoryBean.getBean(CATEGORY_TEST_ID_11);
//assert
assertEquals(expectedSuperCategoryId, bean.getSuperCategory());
}
@Test
public void testThatCategoryBeanHasSubCategoriesField() throws Exception {
//arrange
Collection<String> expectedSubcategoryIDs = Arrays.asList(CATEGORY_TEST_ID_11, CATEGORY_TEST_ID_12);
//act
CategoryBean bean = CategoryBean.getBean(CATEGORY_TEST_ID_13);
//assert
assertCollectionEquals(expectedSubcategoryIDs, bean.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