i want to add an object in DB than check if the object is already there so we can't add it twice. I used JUNIT to test it:
@org.junit.Test (expected = ExistingProduct.class)
public void AddExisting()
{
Register aRegister = new Register();
Product aProduct = new Product();
aProduct.setPIN("079400027252");
aRegister.AddProduct(aProduct);
Product sameProduct = new Product();
sameProduct.setPIN("079400027252");
aRegister.AddProduct(sameProduct); //this throw the exception
aRegister.deleteProduct("079400027252"); //CAN'T REACH HERE
}
The problem is that i can't delete the product since the instruction that's called before will throw a exception thus end the test.