@Test public void removeDeletedSideFromRecipe_Pass() { Recipe side = new Recipe(2, 1, "Test Side", 4, 100, true, null, "", null); List<Recipe> list = svc.getRecipeList(); testRecipe.addSide(side); list.add(side); try { OutputStream out = new FileOutputStream(svc.getPath() + "recipes.dat"); OutputStream buffer = new BufferedOutputStream(out); ObjectOutput output = new ObjectOutputStream(buffer); try { output.writeObject(list); } finally { output.close(); } } catch (IOException ex) { ex.printStackTrace(); } addTestRecipe(); deleteRecipe(side); int expected = 0; int actual = svc.getSides(testRecipe).size(); assertEquals(expected, actual); }
@Test public void testGetSides() { Recipe side = new Recipe(2, 1, "Test Side", 4, 100, true, null, "", null); List<Recipe> list = svc.getRecipeList(); testRecipe.addSide(side); list.add(side); try { OutputStream out = new FileOutputStream(svc.getPath() + "recipes.dat"); OutputStream buffer = new BufferedOutputStream(out); ObjectOutput output = new ObjectOutputStream(buffer); try { output.writeObject(list); } finally { output.close(); } } catch (IOException ex) { ex.printStackTrace(); } addTestRecipe(); List<Recipe> expected = new ArrayList(); list = svc.getRecipeList(); for (Recipe recipe : list) { if (recipe.getId() == side.getId()) { expected.add(recipe); } } List<Recipe> actual = svc.getSides(testRecipe); assertEquals(expected, actual); deleteRecipe(side); }