use of SQLDatabase.SQLDatabaseException.IngredientNotExist in project SmartCity-Market by TechnionYP5777.
the class RemoveIngredientTest method removeIngredientIngredientStillUsedTest.
@Test
public void removeIngredientIngredientStillUsedTest() {
String command = new CommandWrapper(senderID, CommandDescriptor.REMOVE_INGREDIENT, new Gson().toJson(ingredient, Ingredient.class)).serialize();
CommandExecuter commandExecuter = new CommandExecuter(command);
CommandWrapper out;
try {
Mockito.doThrow(new IngredientStillUsed()).when(sqlDatabaseConnection).removeIngredient(senderID, ingredient);
} catch (CriticalError | ClientNotConnected | IngredientNotExist e1) {
fail();
} catch (IngredientStillUsed e) {
/* success */
}
out = commandExecuter.execute(sqlDatabaseConnection);
assertEquals(ResultDescriptor.SM_INGREDIENT_STILL_IN_USE, out.getResultDescriptor());
}
use of SQLDatabase.SQLDatabaseException.IngredientNotExist in project SmartCity-Market by TechnionYP5777.
the class RemoveIngredientTest method removeIngredientCriticalErrorTest.
@Test
public void removeIngredientCriticalErrorTest() {
String command = new CommandWrapper(senderID, CommandDescriptor.REMOVE_INGREDIENT, new Gson().toJson(ingredient, Ingredient.class)).serialize();
CommandExecuter commandExecuter = new CommandExecuter(command);
CommandWrapper out;
try {
Mockito.doThrow(new CriticalError()).when(sqlDatabaseConnection).removeIngredient(senderID, ingredient);
} catch (ClientNotConnected | IngredientNotExist | IngredientStillUsed e1) {
fail();
} catch (CriticalError e) {
/* success */
}
out = commandExecuter.execute(sqlDatabaseConnection);
assertEquals(ResultDescriptor.SM_ERR, out.getResultDescriptor());
}
use of SQLDatabase.SQLDatabaseException.IngredientNotExist in project SmartCity-Market by TechnionYP5777.
the class RemoveIngredientTest method removeIngredientClientNotConnectedTest.
@Test
public void removeIngredientClientNotConnectedTest() {
String command = new CommandWrapper(senderID, CommandDescriptor.REMOVE_INGREDIENT, new Gson().toJson(ingredient, Ingredient.class)).serialize();
CommandExecuter commandExecuter = new CommandExecuter(command);
CommandWrapper out;
try {
Mockito.doThrow(new ClientNotConnected()).when(sqlDatabaseConnection).removeIngredient(senderID, ingredient);
} catch (CriticalError | IngredientNotExist | IngredientStillUsed e1) {
fail();
} catch (ClientNotConnected e) {
/* success */
}
out = commandExecuter.execute(sqlDatabaseConnection);
assertEquals(ResultDescriptor.SM_SENDER_IS_NOT_CONNECTED, out.getResultDescriptor());
}
use of SQLDatabase.SQLDatabaseException.IngredientNotExist in project SmartCity-Market by TechnionYP5777.
the class EditProductFromCatalogTest method editCatalogProductManufacturerNotExistTest.
@Test
public void editCatalogProductManufacturerNotExistTest() {
int senderID = 1;
CatalogProduct catalogProduct = new CatalogProduct(0, "Shoko", null, null, null, 4, null, null);
String command = new CommandWrapper(senderID, CommandDescriptor.EDIT_PRODUCT_FROM_CATALOG, new Gson().toJson(catalogProduct, CatalogProduct.class)).serialize();
CommandExecuter commandExecuter = new CommandExecuter(command);
CommandWrapper out;
try {
Mockito.doThrow(new ManufacturerNotExist()).when(sqlDatabaseConnection).editProductInCatalog(senderID, catalogProduct);
} catch (CriticalError | ClientNotConnected | ProductNotExistInCatalog | IngredientNotExist e1) {
fail();
} catch (ManufacturerNotExist __) {
/* Success */
}
out = commandExecuter.execute(sqlDatabaseConnection);
assertEquals(ResultDescriptor.SM_INVALID_PARAMETER, out.getResultDescriptor());
}
use of SQLDatabase.SQLDatabaseException.IngredientNotExist in project SmartCity-Market by TechnionYP5777.
the class EditProductFromCatalogTest method editCatalogProductIngredientNotExistTest.
@Test
public void editCatalogProductIngredientNotExistTest() {
int senderID = 1;
CatalogProduct catalogProduct = new CatalogProduct(0, "Shoko", null, null, null, 4, null, null);
String command = new CommandWrapper(senderID, CommandDescriptor.EDIT_PRODUCT_FROM_CATALOG, new Gson().toJson(catalogProduct, CatalogProduct.class)).serialize();
CommandExecuter commandExecuter = new CommandExecuter(command);
CommandWrapper out;
try {
Mockito.doThrow(new IngredientNotExist()).when(sqlDatabaseConnection).editProductInCatalog(senderID, catalogProduct);
} catch (CriticalError | ClientNotConnected | ProductNotExistInCatalog | ManufacturerNotExist e1) {
fail();
} catch (IngredientNotExist __) {
/* Success */
}
out = commandExecuter.execute(sqlDatabaseConnection);
assertEquals(ResultDescriptor.SM_INVALID_PARAMETER, out.getResultDescriptor());
}
Aggregations