use of BasicCommonClasses.SmartCode in project SmartCity-Market by TechnionYP5777.
the class PlaceProductPackageOnShelvesTest method placeProductPackageOnShelvesProductPackageAmountNotMatchTest.
@Test
public void placeProductPackageOnShelvesProductPackageAmountNotMatchTest() {
int senderID = 1;
ProductPackage productPackage = new ProductPackage(new SmartCode(1, null), 1, new Location(0, 0, PlaceInMarket.WAREHOUSE));
String command = new CommandWrapper(senderID, CommandDescriptor.PLACE_PRODUCT_PACKAGE_ON_SHELVES, new Gson().toJson(productPackage, ProductPackage.class)).serialize();
CommandExecuter commandExecuter = new CommandExecuter(command);
CommandWrapper out;
try {
Mockito.doThrow(new ProductPackageAmountNotMatch()).when(sqlDatabaseConnection).placeProductPackageOnShelves(senderID, productPackage);
} catch (CriticalError | ClientNotConnected | ProductNotExistInCatalog | ProductPackageNotExist e) {
fail();
} catch (ProductPackageAmountNotMatch __) {
/* Success */
}
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 PlaceProductPackageOnShelvesTest method placeProductPackageOnShelvesProductPackageNotExistTest.
@Test
public void placeProductPackageOnShelvesProductPackageNotExistTest() {
int senderID = 1;
ProductPackage productPackage = new ProductPackage(new SmartCode(1, null), 1, new Location(0, 0, PlaceInMarket.WAREHOUSE));
String command = new CommandWrapper(senderID, CommandDescriptor.PLACE_PRODUCT_PACKAGE_ON_SHELVES, new Gson().toJson(productPackage, ProductPackage.class)).serialize();
CommandExecuter commandExecuter = new CommandExecuter(command);
CommandWrapper out;
try {
Mockito.doThrow(new ProductPackageNotExist()).when(sqlDatabaseConnection).placeProductPackageOnShelves(senderID, productPackage);
} catch (CriticalError | ClientNotConnected | ProductNotExistInCatalog | ProductPackageAmountNotMatch e) {
fail();
} catch (ProductPackageNotExist __) {
/* Success */
}
out = commandExecuter.execute(sqlDatabaseConnection);
assertEquals(ResultDescriptor.SM_PRODUCT_PACKAGE_DOES_NOT_EXIST, out.getResultDescriptor());
}
use of BasicCommonClasses.SmartCode in project SmartCity-Market by TechnionYP5777.
the class PlaceProductPackageOnShelvesTest method placeProductPackageOnShelvesIllegalCatalogProductTest.
@Test
public void placeProductPackageOnShelvesIllegalCatalogProductTest() {
assertEquals(ResultDescriptor.SM_ERR, (new CommandExecuter(new CommandWrapper(1, CommandDescriptor.PLACE_PRODUCT_PACKAGE_ON_SHELVES, new Gson().toJson("", String.class)).serialize())).execute(sqlDatabaseConnection).getResultDescriptor());
assertEquals(ResultDescriptor.SM_INVALID_PARAMETER, (new CommandExecuter(new CommandWrapper(1, CommandDescriptor.PLACE_PRODUCT_PACKAGE_ON_SHELVES, new Gson().toJson(new ProductPackage(new SmartCode(1, null), -1, new Location(0, 0, PlaceInMarket.WAREHOUSE)), ProductPackage.class)).serialize())).execute(sqlDatabaseConnection).getResultDescriptor());
}
use of BasicCommonClasses.SmartCode in project SmartCity-Market by TechnionYP5777.
the class SmartcodeParserTest method testBarcode.
@Test
public void testBarcode() {
SmartCode barcode = SmartcodeParser.formCode("7290000688077");
assert barcode != null;
assertNull(barcode.getExpirationDate());
assertEquals(7290000688077L, barcode.getBarcode());
}
use of BasicCommonClasses.SmartCode in project SmartCity-Market by TechnionYP5777.
the class SmartcodeParserTest method testSmartode.
@Test
public void testSmartode() {
SmartCode barcode = SmartcodeParser.formCode("]C117010203217290000688077");
assert barcode != null;
assertEquals(LocalDate.of(2001, 02, 03), barcode.getExpirationDate());
assertEquals(7290000688077L, barcode.getBarcode());
}
Aggregations