package [Link].csc326.
coffeemaker;
import static [Link];
import static [Link];
import static [Link];
import static [Link];
import static [Link].*;
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
/**
* Unit tests for CoffeeMaker class.
*
* @author Sarah Heckman
*
* Extended by Mike Whalen
*/
public class CoffeeMakerTest
{
//-----------------------------------------------------------------------
// DATA MEMBERS
//-----------------------------------------------------------------------
private Recipe recipe1;
private Recipe recipe2;
private Recipe recipe3;
private Recipe recipe4;
private Recipe recipe5;
private Recipe [] stubRecipies;
private CoffeeMaker coffeeMaker;
private RecipeBook recipeBookStub;
@Before
public void setUp() throws RecipeException
{
Inventory inv = new Inventory();
recipeBookStub = mock([Link]);
coffeeMaker = new CoffeeMaker(recipeBookStub, inv);
//Set up for recipe1
recipe1 = spy(new Recipe());
[Link]("Coffee");
[Link]("1");
[Link]("2");
[Link]("3");
[Link]("4");
[Link]("50");
//Set up for recipe2
recipe2 = new Recipe();
[Link]("Mocha");
[Link]("20");
[Link]("30");
[Link]("19");
[Link]("18");
[Link]("75");
//Set up for recipe3
recipe3 = new Recipe();
[Link]("Latte");
[Link]("0");
[Link]("3");
[Link]("3");
[Link]("1");
[Link]("100");
stubRecipies = new Recipe [] {recipe1, recipe2, recipe3};
when([Link]()).thenReturn(stubRecipies);
//when([Link]()).th
// when([Link](microsoftStock)).thenReturn(1000.00)
}
@Test
public void testAddInventoryWithStringVal()
{
coffeeMaker = new CoffeeMaker(recipeBookStub, new Inventory());
try
{
[Link]("sdf", "ifgjdi", "asdf", "sdfdgfgh");
assertTrue(true);
}
catch (InventoryException e)
{
// TODO Auto-generated catch block
assertFalse(false);
}
}
@Test
public void testAddInventoryWithStringVal1()
{
coffeeMaker = new CoffeeMaker(recipeBookStub, new Inventory());
try
{
[Link]("-44", "4", "6", "3");
assertTrue(true);
}
catch (InventoryException e)
{
// TODO Auto-generated catch block
assertFalse(false);
}
}
@Test
public void testAddInventoryWithStringVal2()
{
coffeeMaker = new CoffeeMaker(recipeBookStub, new Inventory());
try
{
[Link]("44", "-4", "6", "3");
assertTrue(true);
}
catch (InventoryException e)
{
// TODO Auto-generated catch block
assertFalse(false);
}
}
@Test
public void testAddInventoryWithStringVal3()
{
coffeeMaker = new CoffeeMaker(recipeBookStub, new Inventory());
try
{
[Link]("44", "4", "-6", "3");
assertTrue(true);
}
catch (InventoryException e)
{
// TODO Auto-generated catch block
assertFalse(false);
}
}
@Test
public void testAddInventoryWithStringVal4()
{
coffeeMaker = new CoffeeMaker(recipeBookStub, new Inventory());
try
{
[Link]("44", "4", "6", "-33");
assertTrue(true);
}
catch (InventoryException e)
{
// TODO Auto-generated catch block
assertFalse(false);
}
}
@Test
public void testAddInventoryWithStringVal5()
{
coffeeMaker = new CoffeeMaker(recipeBookStub, new Inventory());
try
{
[Link]("4", "ifgjdi", "asdf", "sdfdgfgh");
assertTrue(true);
}
catch (InventoryException e)
{
// TODO Auto-generated catch block
assertFalse(false);
}
}
@Test
public void testAddInventoryWithStringVal6()
{
coffeeMaker = new CoffeeMaker(recipeBookStub, new Inventory());
try
{
[Link]("4", "4", "asdf", "sdfdgfgh");
assertTrue(true);
}
catch (InventoryException e)
{
// TODO Auto-generated catch block
assertFalse(false);
}
}
@Test
public void testAddInventoryWithStringVal7()
{
coffeeMaker = new CoffeeMaker(recipeBookStub, new Inventory());
try
{
[Link]("4", "5", "5", "sdfdgfgh");
assertTrue(true);
}
catch (InventoryException e)
{
// TODO Auto-generated catch block
assertFalse(false);
}
}
@Test
public void testAddInventoryWithOutOfBound()
{
coffeeMaker = new CoffeeMaker(recipeBookStub, new Inventory());
try
{
[Link]("444444444444444444444444444444444444444444444444444444444
44444444444444444444444444444444444444444444444",
"1111111111111111111111111111111111111111111111111111111111111111111111111111111111
11",
"111111111111111111122222222222211111111111111111111111111222222222222222222222",
"3333333333333333333333333333333333333333333333333333444444444444444444444444444444
43");
assertTrue(true);
}
catch (InventoryException e)
{
// TODO Auto-generated catch block
assertFalse(false);
}
}
@Test
public void testAddInventoryWithWrongVal()
{
coffeeMaker = new CoffeeMaker(recipeBookStub, new Inventory());
try
{
[Link]("-55", "-10", "-19", "-9");
assertTrue(true);
}
catch (InventoryException e)
{
// TODO Auto-generated catch block
assertFalse(false);
}
}
//ccoff,milk,sugar,choco
@Test
public void testAddInventoryWithValCheckCoffe()
{
Inventory inv= new Inventory();
coffeeMaker = new CoffeeMaker(recipeBookStub, inv);
try
{
[Link]("4", "9", "5", "3");
assertEquals(19, [Link]());
}
catch (InventoryException e)
{
// TODO Auto-generated catch block
assertFalse(false);
}
}
@Test
public void testAddInventoryWithValCheckMilk()
{
Inventory inv= new Inventory();
coffeeMaker = new CoffeeMaker(recipeBookStub,inv);
try
{
[Link]("4", "10", "5", "3");
assertEquals(25, [Link]());
}
catch (InventoryException e)
{
// TODO Auto-generated catch block
assertFalse(false);
}
}
@Test
public void testAddInventoryWithValCheckSugar()
{
Inventory inv= new Inventory();
coffeeMaker = new CoffeeMaker(recipeBookStub, inv);
try
{
[Link]("4", "9", "5", "3");
assertEquals(20, [Link]());
}
catch (InventoryException e)
{
// TODO Auto-generated catch block
assertFalse(false);
}
}
@Test
public void testAddInventoryWithValCheckChoco()
{
Inventory inv= new Inventory();
coffeeMaker = new CoffeeMaker(recipeBookStub, inv);
try
{
[Link]("4", "9", "5", "3");
assertEquals(18, [Link]());
}
catch (InventoryException e)
{
// TODO Auto-generated catch block
assertFalse(false);
}
}
@Test
public void testCheckInventory1()
{
}
@Test
public void testPurchaseWithRightAmmountToCheckChange() throws
RecipeException
{
coffeeMaker = new CoffeeMaker(recipeBookStub, new Inventory());
assertEquals(0,[Link](0, 50));
}
@Test
public void testPurchaseWithRightAmmountToCheckChange1() throws
RecipeException
{
coffeeMaker = new CoffeeMaker(recipeBookStub, new Inventory());
assertEquals(-5,[Link](0, -5));
}
@Test
public void testPurchaseWithRightAmmountToCheckInventoryRemainings()
throws RecipeException
{
coffeeMaker = new CoffeeMaker(recipeBookStub, new Inventory());
//Inventory inv = new Inventory();
[Link](0, 50);
assertEquals("Coffee: 13\n" +
"Milk: 12\n" +
"Sugar: 11\n" +
"Chocolate: 14\n",[Link]());
}
@Test
public void testPurchaseWithRightAmmountToCheckInventoryRemainings1()
throws RecipeException
{
coffeeMaker = new CoffeeMaker(recipeBookStub, new Inventory());
//Inventory inv = new Inventory();
[Link](0, -5);
assertEquals("Coffee: 15\n" +
"Milk: 15\n" +
"Sugar: 15\n" +
"Chocolate: 15\n",[Link]());
}
@Test
public void testPurchaseToCheckRecipeExists() throws RecipeException
{
coffeeMaker = new CoffeeMaker(recipeBookStub, new Inventory());
//Inventory inv = new Inventory();
assertEquals(5,[Link](6, 5));
}
@Test
public void testPurchaseToCheckRecipeExists1() throws RecipeException
{
coffeeMaker = new CoffeeMaker(recipeBookStub, new Inventory());
//Inventory inv = new Inventory();
assertEquals(5,[Link](0, 55));
}