use of SQLDatabase.SQLDatabaseException.IngredientNotExist in project SmartCity-Market by TechnionYP5777.
the class RegisterNewCustomerTest method registerNewCustomerProfileIngredientNotExistTest.
@Test
public void registerNewCustomerProfileIngredientNotExistTest() {
String command = new CommandWrapper(senderID, CommandDescriptor.REGISTER_NEW_CUSTOMER, new Gson().toJson(customerProfile, CustomerProfile.class)).serialize();
CommandExecuter commandExecuter = new CommandExecuter(command);
CommandWrapper out;
try {
Mockito.doNothing().when(sqlDatabaseConnection).registerCustomer(customerProfile.getUserName(), customerProfile.getPassword());
} catch (CriticalError | ClientAlreadyExist e) {
fail();
}
try {
Mockito.doThrow(new IngredientNotExist()).when(sqlDatabaseConnection).setCustomerProfile(customerProfile.getUserName(), customerProfile);
} catch (CriticalError | ClientNotExist e1) {
fail();
} catch (IngredientNotExist e) {
/* success */
}
try {
Mockito.doNothing().when(sqlDatabaseConnection).setSecurityQACustomer(customerProfile.getUserName(), customerProfile.getForgetPassword());
} catch (CriticalError | ClientNotExist e) {
fail();
}
out = commandExecuter.execute(sqlDatabaseConnection);
assertEquals(ResultDescriptor.SM_INVALID_PARAMETER, out.getResultDescriptor());
}
use of SQLDatabase.SQLDatabaseException.IngredientNotExist in project SmartCity-Market by TechnionYP5777.
the class RegisterNewCustomerTest method registerNewCustomerProfileSuccessfulTest.
@Test
public void registerNewCustomerProfileSuccessfulTest() {
String command = new CommandWrapper(senderID, CommandDescriptor.REGISTER_NEW_CUSTOMER, new Gson().toJson(customerProfile, CustomerProfile.class)).serialize();
CommandExecuter commandExecuter = new CommandExecuter(command);
CommandWrapper out;
try {
Mockito.doNothing().when(sqlDatabaseConnection).registerCustomer(customerProfile.getUserName(), customerProfile.getPassword());
} catch (CriticalError | ClientAlreadyExist e) {
fail();
}
try {
Mockito.doNothing().when(sqlDatabaseConnection).setCustomerProfile(customerProfile.getUserName(), customerProfile);
} catch (CriticalError | ClientNotExist | IngredientNotExist e1) {
fail();
}
try {
Mockito.doNothing().when(sqlDatabaseConnection).setSecurityQACustomer(customerProfile.getUserName(), customerProfile.getForgetPassword());
} catch (CriticalError | ClientNotExist e) {
fail();
}
out = commandExecuter.execute(sqlDatabaseConnection);
assertEquals(ResultDescriptor.SM_OK, out.getResultDescriptor());
}
use of SQLDatabase.SQLDatabaseException.IngredientNotExist in project SmartCity-Market by TechnionYP5777.
the class RegisterNewCustomerTest method registerNewCustomerProfileCriticalErrorTest1.
@Test
public void registerNewCustomerProfileCriticalErrorTest1() {
String command = new CommandWrapper(senderID, CommandDescriptor.REGISTER_NEW_CUSTOMER, new Gson().toJson(customerProfile, CustomerProfile.class)).serialize();
CommandExecuter commandExecuter = new CommandExecuter(command);
CommandWrapper out;
try {
Mockito.doThrow(new CriticalError()).when(sqlDatabaseConnection).registerCustomer(customerProfile.getUserName(), customerProfile.getPassword());
} catch (ClientAlreadyExist e) {
fail();
} catch (CriticalError e) {
/* success */
}
try {
Mockito.doNothing().when(sqlDatabaseConnection).setCustomerProfile(customerProfile.getUserName(), customerProfile);
} catch (CriticalError | ClientNotExist | IngredientNotExist e1) {
fail();
}
try {
Mockito.doNothing().when(sqlDatabaseConnection).setSecurityQACustomer(customerProfile.getUserName(), customerProfile.getForgetPassword());
} catch (CriticalError | ClientNotExist e) {
fail();
}
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 removeIngredientIngredientNotExistTest.
@Test
public void removeIngredientIngredientNotExistTest() {
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 IngredientNotExist()).when(sqlDatabaseConnection).removeIngredient(senderID, ingredient);
} catch (CriticalError | ClientNotConnected | IngredientStillUsed e1) {
fail();
} catch (IngredientNotExist e) {
/* success */
}
out = commandExecuter.execute(sqlDatabaseConnection);
assertEquals(ResultDescriptor.PARAM_ID_IS_NOT_EXIST, out.getResultDescriptor());
}
use of SQLDatabase.SQLDatabaseException.IngredientNotExist in project SmartCity-Market by TechnionYP5777.
the class EditProductFromCatalogTest method editCatalogProductNotExistInCatalogTest.
@Test
public void editCatalogProductNotExistInCatalogTest() {
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 ProductNotExistInCatalog()).when(sqlDatabaseConnection).editProductInCatalog(senderID, catalogProduct);
} catch (CriticalError | ClientNotConnected | IngredientNotExist | ManufacturerNotExist e1) {
fail();
} catch (ProductNotExistInCatalog __) {
/* Success */
}
out = commandExecuter.execute(sqlDatabaseConnection);
assertEquals(ResultDescriptor.SM_CATALOG_PRODUCT_DOES_NOT_EXIST, out.getResultDescriptor());
}
Aggregations