use of BasicCommonClasses.Manufacturer in project SmartCity-Market by TechnionYP5777.
the class SQLDatabaseConnectionTest method testCantEditNotExistedManufacturer.
@Test
public void testCantEditNotExistedManufacturer() {
SQLDatabaseConnection sqlConnection = new SQLDatabaseConnection();
final String manufacturerName = "manydebug";
Manufacturer manufacturer = new Manufacturer(999, manufacturerName);
try {
sqlConnection.editManufacturer(null, manufacturer);
fail();
} catch (CriticalError | ClientNotConnected e) {
fail();
} catch (ManufacturerNotExist e) {
}
}
use of BasicCommonClasses.Manufacturer in project SmartCity-Market by TechnionYP5777.
the class SQLDatabaseConnectionTest method testCantRemoveNotExistedManufacturer.
@Test
public void testCantRemoveNotExistedManufacturer() {
SQLDatabaseConnection sqlConnection = new SQLDatabaseConnection();
final String manufacturerName = "manydebug";
Manufacturer manufacturer = new Manufacturer(999, manufacturerName);
try {
sqlConnection.removeManufacturer(null, manufacturer);
fail();
} catch (CriticalError | ClientNotConnected | ManufacturerStillUsed e) {
fail();
} catch (ManufacturerNotExist e) {
}
}
use of BasicCommonClasses.Manufacturer in project SmartCity-Market by TechnionYP5777.
the class SQLDatabaseConnectionTest method testAddRemoveManufacturer.
@Test
public void testAddRemoveManufacturer() {
SQLDatabaseConnection sqlConnection = new SQLDatabaseConnection();
final String manufacturerName = "manydebug";
String result = null;
Manufacturer manufacturer = null;
//test add ingredient
try {
String tempID = sqlConnection.addManufacturer(null, manufacturerName);
manufacturer = Serialization.deserialize(tempID, Manufacturer.class);
result = sqlConnection.getManufacturersList(null);
} catch (CriticalError | ClientNotConnected e) {
fail();
}
assert result != null;
HashSet<Manufacturer> set = Serialization.deserializeManufacturersHashSet(result);
assert set != null;
assert set.contains(manufacturer);
//test remove ingredient
try {
sqlConnection.removeManufacturer(null, manufacturer);
result = sqlConnection.getManufacturersList(null);
} catch (CriticalError | ClientNotConnected | ManufacturerNotExist | ManufacturerStillUsed e) {
fail();
}
assert result != null;
set = Serialization.deserializeManufacturersHashSet(result);
assert set != null;
assert !set.contains(manufacturer);
}
use of BasicCommonClasses.Manufacturer in project SmartCity-Market by TechnionYP5777.
the class SQLDatabaseConnectionTest method testSimpleAddRemoveProductFromCatalog.
@Test
public void testSimpleAddRemoveProductFromCatalog() {
SQLDatabaseConnection sqlConnection = new SQLDatabaseConnection();
HashSet<Ingredient> ingredients = new HashSet<Ingredient>();
HashSet<Location> locations = new HashSet<Location>();
CatalogProduct newProduct = new CatalogProduct(123L, "name", ingredients, new Manufacturer(1, "תנובה"), "", 20, "", locations);
try {
sqlConnection.addProductToCatalog(null, newProduct);
assertEquals(sqlConnection.getProductFromCatalog(null, newProduct.getBarcode()), new Gson().toJson(newProduct));
sqlConnection.removeProductFromCatalog(null, new SmartCode(newProduct.getBarcode(), null));
} catch (SQLDatabaseException e) {
fail();
}
try {
sqlConnection.getProductFromCatalog(null, newProduct.getBarcode());
fail();
} catch (ProductNotExistInCatalog e) {
} catch (CriticalError | ClientNotConnected e) {
fail();
}
}
use of BasicCommonClasses.Manufacturer in project SmartCity-Market by TechnionYP5777.
the class SQLDatabaseConnectionTest method testEditManufacturer.
@Test
public void testEditManufacturer() {
SQLDatabaseConnection sqlConnection = new SQLDatabaseConnection();
final String manufacturerName = "manydebug";
String result = null;
Manufacturer manufacturer = null;
try {
String tempID = sqlConnection.addManufacturer(null, manufacturerName);
manufacturer = Serialization.deserialize(tempID, Manufacturer.class);
manufacturer.setName("newManufacturer");
sqlConnection.editManufacturer(null, manufacturer);
result = sqlConnection.getManufacturersList(null);
} catch (CriticalError | ClientNotConnected | ManufacturerNotExist e) {
fail();
}
assert result != null;
HashSet<Manufacturer> set = Serialization.deserializeManufacturersHashSet(result);
assert set != null;
assert set.contains(manufacturer);
try {
sqlConnection.removeManufacturer(null, manufacturer);
} catch (CriticalError | ClientNotConnected | ManufacturerNotExist | ManufacturerStillUsed e) {
fail();
}
}
Aggregations