Search in sources :

Example 41 with ProductPackageAmountNotMatch

use of SQLDatabase.SQLDatabaseException.ProductPackageAmountNotMatch 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());
}
Also used : SmartCode(BasicCommonClasses.SmartCode) ProductNotExistInCatalog(SQLDatabase.SQLDatabaseException.ProductNotExistInCatalog) ProductPackageAmountNotMatch(SQLDatabase.SQLDatabaseException.ProductPackageAmountNotMatch) CriticalError(SQLDatabase.SQLDatabaseException.CriticalError) ClientNotConnected(SQLDatabase.SQLDatabaseException.ClientNotConnected) ProductPackage(BasicCommonClasses.ProductPackage) Gson(com.google.gson.Gson) CommandWrapper(ClientServerApi.CommandWrapper) ProductPackageNotExist(SQLDatabase.SQLDatabaseException.ProductPackageNotExist) CommandExecuter(CommandHandler.CommandExecuter) Location(BasicCommonClasses.Location) Test(org.junit.Test)

Example 42 with ProductPackageAmountNotMatch

use of SQLDatabase.SQLDatabaseException.ProductPackageAmountNotMatch in project SmartCity-Market by TechnionYP5777.

the class AddProductToGroceryListTest method addProductToGroceryListCriticalErrorTest.

@Test
public void addProductToGroceryListCriticalErrorTest() {
    int cartID = 1;
    ProductPackage productPackage = new ProductPackage(new SmartCode(1, null), 1, new Location(0, 0, PlaceInMarket.WAREHOUSE));
    String command = new CommandWrapper(cartID, CommandDescriptor.ADD_PRODUCT_TO_GROCERY_LIST, new Gson().toJson(productPackage, ProductPackage.class)).serialize();
    CommandExecuter commandExecuter = new CommandExecuter(command);
    CommandWrapper out;
    try {
        Mockito.doThrow(new CriticalError()).when(sqlDatabaseConnection).addProductToGroceryList(cartID, productPackage);
    } catch (ClientNotConnected | ProductNotExistInCatalog | ProductPackageAmountNotMatch | ProductPackageNotExist e) {
        fail();
    } catch (CriticalError __) {
    /* Successful */
    }
    out = commandExecuter.execute(sqlDatabaseConnection);
    assertEquals(ResultDescriptor.SM_ERR, out.getResultDescriptor());
}
Also used : SmartCode(BasicCommonClasses.SmartCode) ProductNotExistInCatalog(SQLDatabase.SQLDatabaseException.ProductNotExistInCatalog) ProductPackageAmountNotMatch(SQLDatabase.SQLDatabaseException.ProductPackageAmountNotMatch) CriticalError(SQLDatabase.SQLDatabaseException.CriticalError) ClientNotConnected(SQLDatabase.SQLDatabaseException.ClientNotConnected) ProductPackage(BasicCommonClasses.ProductPackage) Gson(com.google.gson.Gson) CommandWrapper(ClientServerApi.CommandWrapper) ProductPackageNotExist(SQLDatabase.SQLDatabaseException.ProductPackageNotExist) CommandExecuter(CommandHandler.CommandExecuter) Location(BasicCommonClasses.Location) Test(org.junit.Test)

Example 43 with ProductPackageAmountNotMatch

use of SQLDatabase.SQLDatabaseException.ProductPackageAmountNotMatch in project SmartCity-Market by TechnionYP5777.

the class AddProductToGroceryListTest method addProductToGroceryListProductPackageAmountNotMatchTest.

@Test
public void addProductToGroceryListProductPackageAmountNotMatchTest() {
    int cartID = 1;
    ProductPackage productPackage = new ProductPackage(new SmartCode(1, null), 1, new Location(0, 0, PlaceInMarket.WAREHOUSE));
    String command = new CommandWrapper(cartID, CommandDescriptor.ADD_PRODUCT_TO_GROCERY_LIST, new Gson().toJson(productPackage, ProductPackage.class)).serialize();
    CommandExecuter commandExecuter = new CommandExecuter(command);
    CommandWrapper out;
    try {
        Mockito.doThrow(new ProductPackageAmountNotMatch()).when(sqlDatabaseConnection).addProductToGroceryList(cartID, productPackage);
    } catch (ClientNotConnected | CriticalError | ProductNotExistInCatalog | ProductPackageNotExist e) {
        fail();
    } catch (ProductPackageAmountNotMatch __) {
    /* Successful */
    }
    out = commandExecuter.execute(sqlDatabaseConnection);
    assertEquals(ResultDescriptor.SM_PRODUCT_PACKAGE_AMOUNT_BIGGER_THEN_AVAILABLE, out.getResultDescriptor());
}
Also used : SmartCode(BasicCommonClasses.SmartCode) ProductPackageAmountNotMatch(SQLDatabase.SQLDatabaseException.ProductPackageAmountNotMatch) ProductNotExistInCatalog(SQLDatabase.SQLDatabaseException.ProductNotExistInCatalog) CriticalError(SQLDatabase.SQLDatabaseException.CriticalError) ClientNotConnected(SQLDatabase.SQLDatabaseException.ClientNotConnected) ProductPackage(BasicCommonClasses.ProductPackage) Gson(com.google.gson.Gson) CommandWrapper(ClientServerApi.CommandWrapper) ProductPackageNotExist(SQLDatabase.SQLDatabaseException.ProductPackageNotExist) CommandExecuter(CommandHandler.CommandExecuter) Location(BasicCommonClasses.Location) Test(org.junit.Test)

Aggregations

ProductPackage (BasicCommonClasses.ProductPackage)43 ClientNotConnected (SQLDatabase.SQLDatabaseException.ClientNotConnected)43 CriticalError (SQLDatabase.SQLDatabaseException.CriticalError)43 ProductNotExistInCatalog (SQLDatabase.SQLDatabaseException.ProductNotExistInCatalog)43 ProductPackageAmountNotMatch (SQLDatabase.SQLDatabaseException.ProductPackageAmountNotMatch)43 ProductPackageNotExist (SQLDatabase.SQLDatabaseException.ProductPackageNotExist)43 SmartCode (BasicCommonClasses.SmartCode)39 Test (org.junit.Test)39 CommandWrapper (ClientServerApi.CommandWrapper)27 Location (BasicCommonClasses.Location)23 CommandExecuter (CommandHandler.CommandExecuter)23 Gson (com.google.gson.Gson)23 SQLDatabaseConnection (SQLDatabase.SQLDatabaseConnection)16 AuthenticationError (SQLDatabase.SQLDatabaseException.AuthenticationError)8 ClientAlreadyConnected (SQLDatabase.SQLDatabaseException.ClientAlreadyConnected)8 NumberOfConnectionsExceeded (SQLDatabase.SQLDatabaseException.NumberOfConnectionsExceeded)8 GroceryListIsEmpty (SQLDatabase.SQLDatabaseException.GroceryListIsEmpty)2