Skip to content
Snippets Groups Projects
Commit c9bb6ab9 authored by Karsch Lukas's avatar Karsch Lukas
Browse files

added InvalidCategoryException.java;

added tests to categories: they should not be created with a name that is "", null and only be created with a color code where 0 <= code <= 0xFFFFFF
parent f251659e
Branches
No related tags found
No related merge requests found
package mi.hdm.exceptions;
public class InvalidCategoryException extends RuntimeException{
public InvalidCategoryException(String message) {
super(message);
}
}
package mi.hdm.recipes;
import mi.hdm.exceptions.InvalidCategoryException;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
......@@ -61,4 +62,24 @@ public class CategoryTest {
//expect
assertEquals(0, underTest.getAllCategories().size());
}
@Test(expected = InvalidCategoryException.class)
public void canNotAddCategoryWithEmptyName() {
Category emptyName = new Category("", 0x1000);
}
@Test(expected = InvalidCategoryException.class)
public void canNotAddCategoryWithNullName() {
Category emptyName = new Category(null, 0x1000);
}
@Test(expected = InvalidCategoryException.class)
public void canNotAddCategoryWithNegativeCode() {
Category emptyName = new Category("foo", -100);
}
@Test(expected = InvalidCategoryException.class)
public void canNotAddCategoryWithCodeTooHigh() {
Category emptyName = new Category("foo", Integer.MAX_VALUE);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment