Now with a 22-recipe survey_dataset.xml.

Unit test shows an example of checking that Honey cake contains gluten, eggs and spice but not red meat, shellfish or poultry.
This commit is contained in:
Woody Folsom
2012-03-09 21:04:45 -05:00
parent fc3709dda7
commit a021dc2fc0
6 changed files with 2978 additions and 10 deletions

View File

@@ -0,0 +1,36 @@
package net.woodyfolsom.cs6601.p2;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import static org.hamcrest.CoreMatchers.*;
import java.io.File;
import net.woodyfolsom.cs6601.p2.Ingredient.TYPE;
import net.woodyfolsom.cs6601.p2.Recipe;
import net.woodyfolsom.cs6601.p2.RecipeBook;
import net.woodyfolsom.cs6601.p2.RecipeBookReader;
import org.junit.Test;
public class SurveyDatasetReaderTest {
@Test
public void testReadSurveyDataset() {
RecipeBook recipeBook = RecipeBookReader.readRecipeBook(new File("data/survey_dataset.xml"));
assertNotNull(recipeBook);
assertThat(recipeBook.getSize(), is(equalTo(22)));
Recipe recipe = recipeBook.getRecipe(0);
System.out.println(recipe.getHead().getTitle());
assertThat(recipe.getHead().getTitle(), is(equalTo("Honey cake")));
assertTrue(recipe.getIngredients().contains(TYPE.EGGS));
assertTrue(recipe.getIngredients().contains(TYPE.GLUTEN));
assertTrue(recipe.getIngredients().contains(TYPE.SPICE));
assertFalse(recipe.getIngredients().contains(TYPE.RED_MEAT));
assertFalse(recipe.getIngredients().contains(TYPE.POULTRY));
assertFalse(recipe.getIngredients().contains(TYPE.SHELLFISH));
}
}