use of BasicCommonClasses.SmartCode in project SmartCity-Market by TechnionYP5777.
the class CustomerMainScreen method smartcodeScanned.
@Subscribe
public void smartcodeScanned(SmartcodeScanEvent ¢) {
SmartCode smartCode = ¢.getSmarCode();
scannedSmartCode = smartCode;
smartcodeScannedHandler();
}
use of BasicCommonClasses.SmartCode in project SmartCity-Market by TechnionYP5777.
the class RemoveProductFromCatalogTest method removeCatalogProductNotExistInCatalogTest.
@Test
public void removeCatalogProductNotExistInCatalogTest() {
int senderID = 1;
SmartCode smartCode = new SmartCode(1, null);
String command = new CommandWrapper(senderID, CommandDescriptor.REMOVE_PRODUCT_FROM_CATALOG, new Gson().toJson(smartCode, SmartCode.class)).serialize();
CommandExecuter commandExecuter = new CommandExecuter(command);
CommandWrapper out;
try {
Mockito.doThrow(new ProductNotExistInCatalog()).when(sqlDatabaseConnection).removeProductFromCatalog(senderID, smartCode);
} catch (CriticalError | ClientNotConnected | ProductStillForSale e) {
fail();
} catch (ProductNotExistInCatalog e) {
/* success */
}
out = commandExecuter.execute(sqlDatabaseConnection);
assertEquals(ResultDescriptor.SM_CATALOG_PRODUCT_DOES_NOT_EXIST, out.getResultDescriptor());
}
use of BasicCommonClasses.SmartCode in project SmartCity-Market by TechnionYP5777.
the class RemoveProductPackageFromGroceryListTest method removeProductPackageFromGroceryListCriticalErrorTest.
@Test
public void removeProductPackageFromGroceryListCriticalErrorTest() {
int cartID = 1;
ProductPackage productPackage = new ProductPackage(new SmartCode(1, null), 1, new Location(0, 0, PlaceInMarket.WAREHOUSE));
String command = new CommandWrapper(cartID, CommandDescriptor.REMOVE_PRODUCT_FROM_GROCERY_LIST, new Gson().toJson(productPackage, ProductPackage.class)).serialize();
CommandExecuter commandExecuter = new CommandExecuter(command);
CommandWrapper out;
try {
Mockito.doThrow(new CriticalError()).when(sqlDatabaseConnection).removeProductFromGroceryList(cartID, productPackage);
} catch (ClientNotConnected | ProductNotExistInCatalog | ProductPackageAmountNotMatch | ProductPackageNotExist e) {
fail();
} catch (CriticalError __) {
/* Successful */
}
out = commandExecuter.execute(sqlDatabaseConnection);
assertEquals(ResultDescriptor.SM_ERR, out.getResultDescriptor());
}
use of BasicCommonClasses.SmartCode in project SmartCity-Market by TechnionYP5777.
the class RemoveProductPackageFromGroceryListTest method removeProductPackageFromGroceryListProductPackageAmountNotMatchTest.
@Test
public void removeProductPackageFromGroceryListProductPackageAmountNotMatchTest() {
int cartID = 1;
ProductPackage productPackage = new ProductPackage(new SmartCode(1, null), 1, new Location(0, 0, PlaceInMarket.WAREHOUSE));
String command = new CommandWrapper(cartID, CommandDescriptor.REMOVE_PRODUCT_FROM_GROCERY_LIST, new Gson().toJson(productPackage, ProductPackage.class)).serialize();
CommandExecuter commandExecuter = new CommandExecuter(command);
CommandWrapper out;
try {
Mockito.doThrow(new ProductPackageAmountNotMatch()).when(sqlDatabaseConnection).removeProductFromGroceryList(cartID, productPackage);
} catch (CriticalError | ClientNotConnected | ProductNotExistInCatalog | ProductPackageNotExist e) {
fail();
} catch (ProductPackageAmountNotMatch __) {
/* Successful */
}
out = commandExecuter.execute(sqlDatabaseConnection);
assertEquals(ResultDescriptor.SM_PRODUCT_PACKAGE_AMOUNT_BIGGER_THEN_AVAILABLE, out.getResultDescriptor());
}
use of BasicCommonClasses.SmartCode in project SmartCity-Market by TechnionYP5777.
the class RemoveProductPackageFromGroceryListTest method removeProductPackageFromGroceryListProductPackageNotExistTest.
@Test
public void removeProductPackageFromGroceryListProductPackageNotExistTest() {
int cartID = 1;
ProductPackage productPackage = new ProductPackage(new SmartCode(1, null), 1, new Location(0, 0, PlaceInMarket.WAREHOUSE));
String command = new CommandWrapper(cartID, CommandDescriptor.REMOVE_PRODUCT_FROM_GROCERY_LIST, new Gson().toJson(productPackage, ProductPackage.class)).serialize();
CommandExecuter commandExecuter = new CommandExecuter(command);
CommandWrapper out;
try {
Mockito.doThrow(new ProductPackageNotExist()).when(sqlDatabaseConnection).removeProductFromGroceryList(cartID, productPackage);
} catch (CriticalError | ClientNotConnected | ProductNotExistInCatalog | ProductPackageAmountNotMatch e) {
fail();
} catch (ProductPackageNotExist __) {
/* Successful */
}
out = commandExecuter.execute(sqlDatabaseConnection);
assertEquals(ResultDescriptor.SM_PRODUCT_PACKAGE_DOES_NOT_EXIST, out.getResultDescriptor());
}
Aggregations