package beaform.entities;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotSame;

import org.junit.Test;

/**
 * Test for the formula tag.
 * @author Steven Post
 *
 */
@SuppressWarnings("static-method")
public class FormulaIngredientTest {

	@Test
	public void testEquals() {
		final FormulaIngredient ingr1 = new FormulaIngredient(new Formula("testFormula"), "10%");
		final FormulaIngredient ingr2 = new FormulaIngredient(new Formula("testFormula"), "10%");
		assertEquals("The ingredients are not equal", ingr1, ingr2);
	}

	@Test
	public void testEqualsSameObject() {
		final FormulaIngredient ingr = new FormulaIngredient(new Formula("testFormula"), "40%");
		assertEquals("The ingredients are not equal", ingr, ingr);
	}

	@Test
	public void testEqualsDifferentType() {
		final FormulaIngredient ingr = new FormulaIngredient(new Formula("testFormula1"), "50%");
		assertFalse("The ingredients are aqual", ingr.equals(new Object()));
	}

	@Test
	public void testNotEqual() {
		final FormulaIngredient tag1 = new FormulaIngredient(new Formula("testFormula1"), "test1");
		final FormulaIngredient tag2 = new FormulaIngredient(new Formula("testform", "long description", "100g"), "test1");
		assertFalse("The ingredients are equal", tag1.equals(tag2));
	}

	@Test
	public void testEqualsHash() {
		final FormulaIngredient tag1 = new FormulaIngredient(new Formula("testFormula1"), "20%");
		final FormulaIngredient tag2 = new FormulaIngredient(new Formula("testFormula1"), "20%");
		assertEquals("The ingredients are not equal", tag1.hashCode(), tag2.hashCode());
	}

	@Test
	public void testNotEqualsHash() {
		final FormulaIngredient tag1 = new FormulaIngredient(new Formula("testFormula1"), "30%");
		final FormulaIngredient tag2 = new FormulaIngredient(new Formula("testform", "long description", "100g"), "30%");
		assertNotSame("The ingredients are equal", Integer.valueOf(tag1.hashCode()), Integer.valueOf(tag2.hashCode()));
	}

	@Test
	public void testToString() {
		final FormulaIngredient tag = new FormulaIngredient(new Formula("testform", "long description", "100g"), "30%");
		assertEquals("Not the expected result for toString()", "testform [30%]", tag.toString());
	}

}

@@ -1073,35 +1073,36 @@
 rmulaIngredient 
-tag
+ingr
 1 = new FormulaI
@@ -1168,35 +1168,36 @@
 rmulaIngredient 
-tag
+ingr
 2 = new FormulaI
@@ -1312,19 +1312,20 @@
 equal%22, 
-tag
+ingr
 1.equals
@@ -1325,19 +1325,20 @@
 .equals(
-tag
+ingr
 2));%0A%09%7D%0A
@@ -1395,35 +1395,36 @@
 rmulaIngredient 
-tag
+ingr
 1 = new FormulaI
@@ -1488,35 +1488,36 @@
 rmulaIngredient 
-tag
+ingr
 2 = new FormulaI
@@ -1611,19 +1611,20 @@
 equal%22, 
-tag
+ingr
 1.hashCo
@@ -1629,19 +1629,20 @@
 Code(), 
-tag
+ingr
 2.hashCo
@@ -1720,19 +1720,20 @@
 redient 
-tag
+ingr
 1 = new 
@@ -1813,19 +1813,20 @@
 redient 
-tag
+ingr
 2 = new 
@@ -1965,19 +1965,20 @@
 valueOf(
-tag
+ingr
 1.hashCo
@@ -2000,19 +2000,20 @@
 valueOf(
-tag
+ingr
 2.hashCo
@@ -2087,19 +2087,20 @@
 redient 
-tag
+ingr
  = new F
@@ -2252,19 +2252,20 @@
 %5B30%25%5D%22, 
-tag
+ingr
 .toStrin

Rename variables in test to better represent their purpose