use of BasicCommonClasses.ProductPackage in project SmartCity-Market by TechnionYP5777.
the class SQLDatabaseConnectionTest method testRemoveMoreThanHaveFromWarehouse.
@Test
public void testRemoveMoreThanHaveFromWarehouse() {
SQLDatabaseConnection sqlConnection = new SQLDatabaseConnection();
ProductPackage productPackage = new ProductPackage(new SmartCode(barcodeDebug, date112000), 10, locationWarehouse);
try {
sqlConnection.addProductPackageToWarehouse(null, productPackage);
assertEquals("10", sqlConnection.getProductPackageAmonutInWarehouse(null, productPackage));
} catch (CriticalError | ClientNotConnected | ProductNotExistInCatalog e) {
fail();
}
productPackage.setAmount(11);
try {
sqlConnection.removeProductPackageFromWarehouse(null, productPackage);
fail();
} catch (ProductPackageAmountNotMatch e) {
} catch (CriticalError | ClientNotConnected | ProductNotExistInCatalog | ProductPackageNotExist e) {
fail();
}
productPackage.setAmount(10);
try {
sqlConnection.removeProductPackageFromWarehouse(null, productPackage);
assertEquals("0", sqlConnection.getProductPackageAmonutInWarehouse(null, productPackage));
} catch (CriticalError | ClientNotConnected | ProductNotExistInCatalog | ProductPackageAmountNotMatch | ProductPackageNotExist e) {
fail();
}
}
use of BasicCommonClasses.ProductPackage in project SmartCity-Market by TechnionYP5777.
the class SQLDatabaseConnectionTest method testRemovePakageFromWarehouseTwice.
@Test
public void testRemovePakageFromWarehouseTwice() {
SQLDatabaseConnection sqlConnection = new SQLDatabaseConnection();
ProductPackage productPackage = new ProductPackage(new SmartCode(barcodeDebug, date112000), 10, locationWarehouse);
try {
sqlConnection.addProductPackageToWarehouse(null, productPackage);
assertEquals("10", sqlConnection.getProductPackageAmonutInWarehouse(null, productPackage));
productPackage.setAmount(5);
sqlConnection.removeProductPackageFromWarehouse(null, productPackage);
assertEquals("5", sqlConnection.getProductPackageAmonutInWarehouse(null, productPackage));
sqlConnection.removeProductPackageFromWarehouse(null, productPackage);
assertEquals("0", sqlConnection.getProductPackageAmonutInWarehouse(null, productPackage));
} catch (CriticalError | ClientNotConnected | ProductNotExistInCatalog | ProductPackageAmountNotMatch | ProductPackageNotExist e) {
fail();
}
}
use of BasicCommonClasses.ProductPackage in project SmartCity-Market by TechnionYP5777.
the class SQLDatabaseConnectionTest method testRemoveNotExistedPakageFromWarehouse.
@Test
public void testRemoveNotExistedPakageFromWarehouse() {
SQLDatabaseConnection sqlConnection = new SQLDatabaseConnection();
ProductPackage productPackage = new ProductPackage(new SmartCode(barcodeDebug, date112000), 10, locationWarehouse);
try {
sqlConnection.removeProductPackageFromWarehouse(null, productPackage);
fail();
} catch (ProductPackageNotExist e) {
} catch (CriticalError | ClientNotConnected | ProductNotExistInCatalog | ProductPackageAmountNotMatch e) {
fail();
}
}
Aggregations