use of BasicCommonClasses.SmartCode in project SmartCity-Market by TechnionYP5777.
the class ProductPackageTest method ProductPackageTestMethod.
@Test
public void ProductPackageTestMethod() {
LocalDate ld = LocalDate.of(2016, 12, 11);
SmartCode sc = new SmartCode(123, ld);
Location lo = new Location(1, 1, PlaceInMarket.WAREHOUSE);
ProductPackage pp = new ProductPackage(sc, 2, lo);
if (!sc.equals(pp.getSmartCode()) || pp.getAmount() != 2 || !lo.equals(pp.getLocation()))
fail();
sc.setBarcode(111);
lo.setX(2);
pp.setSmartCode(sc);
pp.setAmount(1);
pp.setLocation(lo);
if (!sc.equals(pp.getSmartCode()) || pp.getAmount() != 1 || !lo.equals(pp.getLocation()))
fail();
LocalDate ld2 = LocalDate.of(2015, 12, 12);
SmartCode sc2 = new SmartCode(111, ld2);
ProductPackage pp2 = new ProductPackage(sc2, 1, lo);
if (pp2.equals(pp))
fail();
sc2.setExpirationDate(sc.getExpirationDate());
pp.setSmartCode(sc2);
if (!pp2.equals(pp))
fail();
}
use of BasicCommonClasses.SmartCode in project SmartCity-Market by TechnionYP5777.
the class SmartCodeTest method SmartCodeTestMethod.
@Test
public void SmartCodeTestMethod() {
LocalDate ld = LocalDate.of(2016, 12, 11);
SmartCode sc = new SmartCode(123, ld);
if (sc.getBarcode() != 123 || !sc.getExpirationDate().equals(ld))
fail();
sc.setBarcode(111);
ld.plusDays(1);
sc.setExpirationDate(ld);
if (sc.getBarcode() != 111 || !sc.getExpirationDate().equals(ld))
fail();
LocalDate ld2 = LocalDate.of(2015, 12, 12);
SmartCode sc2 = new SmartCode(111, ld2);
if (sc2.equals(sc))
fail();
sc2.setExpirationDate(sc.getExpirationDate());
if (!sc2.equals(sc))
fail();
}
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());
}
Aggregations