use of SQLDatabase.SQLDatabaseConnection in project SmartCity-Market by TechnionYP5777.
the class SQLDatabaseConnectionTest method testCantSetSecurityQAToNotExistedCustomer.
@Test
public void testCantSetSecurityQAToNotExistedCustomer() {
SQLDatabaseConnection sqlConnection = new SQLDatabaseConnection();
ForgotPasswordData p = new ForgotPasswordData("question", "answer");
try {
sqlConnection.setSecurityQACustomer(customerName, p);
fail();
} catch (CriticalError e1) {
fail();
} catch (ClientNotExist e2) {
}
}
use of SQLDatabase.SQLDatabaseConnection in project SmartCity-Market by TechnionYP5777.
the class SQLDatabaseConnectionTest method testRemoveMoreThanHaveFromCart.
// TODO: test manufacturers methods
@Test
public void testRemoveMoreThanHaveFromCart() {
SQLDatabaseConnection sqlConnection = new SQLDatabaseConnection();
ProductPackage productPackage = new ProductPackage(new SmartCode(barcodeDebug, date112000), 10, locationWarehouse);
int sessionCart = 0;
try {
sessionCart = sqlConnection.loginCustomer(ClientServerDefs.anonymousCustomerUsername, ClientServerDefs.anonymousCustomerPassword);
sqlConnection.addProductPackageToWarehouse(null, productPackage);
assertEquals("10", sqlConnection.getProductPackageAmonutInWarehouse(null, productPackage));
sqlConnection.placeProductPackageOnShelves(null, productPackage);
assertEquals("0", sqlConnection.getProductPackageAmonutInWarehouse(null, productPackage));
assertEquals("10", sqlConnection.getProductPackageAmonutOnShelves(null, productPackage));
sqlConnection.addProductToGroceryList(sessionCart, productPackage);
assertEquals("0", sqlConnection.getProductPackageAmonutInWarehouse(null, productPackage));
assertEquals("0", sqlConnection.getProductPackageAmonutOnShelves(null, productPackage));
} catch (CriticalError | ClientNotConnected | ProductNotExistInCatalog | AuthenticationError | ClientAlreadyConnected | NumberOfConnectionsExceeded | ProductPackageAmountNotMatch | ProductPackageNotExist e) {
fail();
}
productPackage.setAmount(11);
try {
sqlConnection.removeProductFromGroceryList(sessionCart, productPackage);
fail();
} catch (ProductPackageAmountNotMatch e) {
} catch (CriticalError | ClientNotConnected | ProductNotExistInCatalog | ProductPackageNotExist e) {
fail();
}
productPackage.setAmount(10);
try {
sqlConnection.removeProductFromGroceryList(sessionCart, productPackage);
sqlConnection.removeProductPackageFromShelves(null, productPackage);
assertEquals("0", sqlConnection.getProductPackageAmonutOnShelves(null, productPackage));
sqlConnection.logout(sessionCart, ClientServerDefs.anonymousCustomerUsername);
} catch (CriticalError | ClientNotConnected | ProductNotExistInCatalog | ProductPackageAmountNotMatch | ProductPackageNotExist e) {
fail();
}
}
use of SQLDatabase.SQLDatabaseConnection in project SmartCity-Market by TechnionYP5777.
the class SQLDatabaseConnectionTest method testGetManufacturersList.
@Test
public void testGetManufacturersList() {
SQLDatabaseConnection sqlConnection = new SQLDatabaseConnection();
String result = null;
try {
result = sqlConnection.getManufacturersList(null);
} catch (CriticalError | ClientNotConnected e) {
fail();
}
assert result != null;
HashSet<Manufacturer> set = Serialization.deserializeManufacturersHashSet(result);
assert set != null;
}
use of SQLDatabase.SQLDatabaseConnection in project SmartCity-Market by TechnionYP5777.
the class SQLDatabaseConnectionTest method testCustomerCanLoginLogout.
@Test
public void testCustomerCanLoginLogout() {
SQLDatabaseConnection sqlConnection = new SQLDatabaseConnection();
try {
sqlConnection.registerCustomer(customerName, customerName);
} catch (CriticalError | ClientAlreadyExist e) {
fail();
}
try {
int sessionID = sqlConnection.loginCustomer(customerName, customerName);
sqlConnection.logout(sessionID, customerName);
} catch (AuthenticationError | ClientAlreadyConnected | CriticalError | NumberOfConnectionsExceeded | ClientNotConnected e1) {
fail();
} finally {
try {
sqlConnection.removeCustomer(customerName);
} catch (CriticalError | ClientNotExist e) {
e.printStackTrace();
}
}
}
use of SQLDatabase.SQLDatabaseConnection in project SmartCity-Market by TechnionYP5777.
the class SQLDatabaseConnectionTest method testEditIngredient.
@Test
public void testEditIngredient() {
SQLDatabaseConnection sqlConnection = new SQLDatabaseConnection();
final String ingredientName = "glotendebug";
String result = null;
Ingredient ingredient = null;
//test add ingredient
try {
String tempID = sqlConnection.addIngredient(null, ingredientName);
ingredient = Serialization.deserialize(tempID, Ingredient.class);
ingredient.setName("newIngredient");
sqlConnection.editIngredient(null, ingredient);
result = sqlConnection.getIngredientsList();
} catch (CriticalError | ClientNotConnected | IngredientNotExist e) {
fail();
}
assert result != null;
HashSet<Ingredient> set = Serialization.deserializeIngredientHashSet(result);
assert set != null;
assert set.contains(ingredient);
//remove ingredient
try {
sqlConnection.removeIngredient(null, ingredient);
} catch (CriticalError | ClientNotConnected | IngredientNotExist | IngredientStillUsed e) {
fail();
}
}
Aggregations