Search in sources :

Example 66 with CriticalError

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

the class SQLDatabaseConnectionTest method testGetWorkersList.

@Test
public void testGetWorkersList() {
    SQLDatabaseConnection sqlConnection = new SQLDatabaseConnection();
    String result = null;
    //test add worker
    try {
        result = sqlConnection.getWorkersList(null);
    } catch (CriticalError | ClientNotConnected e) {
        fail();
    }
    assert result != null;
    HashMap<String, Boolean> map = Serialization.deserializeWorkersHashMap(result);
    assert map != null;
}
Also used : SQLDatabaseConnection(SQLDatabase.SQLDatabaseConnection) CriticalError(SQLDatabase.SQLDatabaseException.CriticalError) ClientNotConnected(SQLDatabase.SQLDatabaseException.ClientNotConnected) Test(org.junit.Test)

Example 67 with CriticalError

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

the class SQLDatabaseConnectionTest method testNotExistedCustomerCantLogout.

@Test
public void testNotExistedCustomerCantLogout() {
    SQLDatabaseConnection sqlConnection = new SQLDatabaseConnection();
    int sessionID = 34624;
    try {
        sqlConnection.logout(sessionID, customerName);
    } catch (CriticalError e1) {
        fail();
    } catch (ClientNotConnected e) {
    }
}
Also used : SQLDatabaseConnection(SQLDatabase.SQLDatabaseConnection) CriticalError(SQLDatabase.SQLDatabaseException.CriticalError) ClientNotConnected(SQLDatabase.SQLDatabaseException.ClientNotConnected) Test(org.junit.Test)

Example 68 with CriticalError

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

the class SQLDatabaseConnectionTest method testAddRemoveManufacturer.

@Test
public void testAddRemoveManufacturer() {
    SQLDatabaseConnection sqlConnection = new SQLDatabaseConnection();
    final String manufacturerName = "manydebug";
    String result = null;
    Manufacturer manufacturer = null;
    //test add ingredient
    try {
        String tempID = sqlConnection.addManufacturer(null, manufacturerName);
        manufacturer = Serialization.deserialize(tempID, Manufacturer.class);
        result = sqlConnection.getManufacturersList(null);
    } catch (CriticalError | ClientNotConnected e) {
        fail();
    }
    assert result != null;
    HashSet<Manufacturer> set = Serialization.deserializeManufacturersHashSet(result);
    assert set != null;
    assert set.contains(manufacturer);
    //test remove ingredient
    try {
        sqlConnection.removeManufacturer(null, manufacturer);
        result = sqlConnection.getManufacturersList(null);
    } catch (CriticalError | ClientNotConnected | ManufacturerNotExist | ManufacturerStillUsed e) {
        fail();
    }
    assert result != null;
    set = Serialization.deserializeManufacturersHashSet(result);
    assert set != null;
    assert !set.contains(manufacturer);
}
Also used : ManufacturerNotExist(SQLDatabase.SQLDatabaseException.ManufacturerNotExist) SQLDatabaseConnection(SQLDatabase.SQLDatabaseConnection) CriticalError(SQLDatabase.SQLDatabaseException.CriticalError) ClientNotConnected(SQLDatabase.SQLDatabaseException.ClientNotConnected) Manufacturer(BasicCommonClasses.Manufacturer) ManufacturerStillUsed(SQLDatabase.SQLDatabaseException.ManufacturerStillUsed) Test(org.junit.Test)

Example 69 with CriticalError

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

the class SQLDatabaseConnectionTest method testCantRemoveNotExistedWorker.

@Test
public void testCantRemoveNotExistedWorker() {
    SQLDatabaseConnection sqlConnection = new SQLDatabaseConnection();
    try {
        sqlConnection.removeWorker(null, workerName);
        fail();
    } catch (CriticalError | ClientNotConnected e) {
        fail();
    } catch (ClientNotExist e) {
    }
}
Also used : SQLDatabaseConnection(SQLDatabase.SQLDatabaseConnection) CriticalError(SQLDatabase.SQLDatabaseException.CriticalError) ClientNotConnected(SQLDatabase.SQLDatabaseException.ClientNotConnected) ClientNotExist(SQLDatabase.SQLDatabaseException.ClientNotExist) Test(org.junit.Test)

Example 70 with CriticalError

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

the class SQLDatabaseConnectionTest method testNotExistedCustomerCantLogin.

@Test
public void testNotExistedCustomerCantLogin() {
    SQLDatabaseConnection sqlConnection = new SQLDatabaseConnection();
    try {
        sqlConnection.loginCustomer(customerName, customerName);
        fail();
    } catch (ClientAlreadyConnected | CriticalError | NumberOfConnectionsExceeded e1) {
        fail();
    } catch (AuthenticationError e) {
    }
}
Also used : AuthenticationError(SQLDatabase.SQLDatabaseException.AuthenticationError) SQLDatabaseConnection(SQLDatabase.SQLDatabaseConnection) CriticalError(SQLDatabase.SQLDatabaseException.CriticalError) NumberOfConnectionsExceeded(SQLDatabase.SQLDatabaseException.NumberOfConnectionsExceeded) ClientAlreadyConnected(SQLDatabase.SQLDatabaseException.ClientAlreadyConnected) Test(org.junit.Test)

Aggregations

CriticalError (SQLDatabase.SQLDatabaseException.CriticalError)225 Test (org.junit.Test)186 ClientNotConnected (SQLDatabase.SQLDatabaseException.ClientNotConnected)172 CommandWrapper (ClientServerApi.CommandWrapper)162 CommandExecuter (CommandHandler.CommandExecuter)128 Gson (com.google.gson.Gson)118 ProductNotExistInCatalog (SQLDatabase.SQLDatabaseException.ProductNotExistInCatalog)81 SmartCode (BasicCommonClasses.SmartCode)63 SQLDatabaseConnection (SQLDatabase.SQLDatabaseConnection)61 ProductPackage (BasicCommonClasses.ProductPackage)55 IngredientNotExist (SQLDatabase.SQLDatabaseException.IngredientNotExist)45 ProductPackageAmountNotMatch (SQLDatabase.SQLDatabaseException.ProductPackageAmountNotMatch)43 ProductPackageNotExist (SQLDatabase.SQLDatabaseException.ProductPackageNotExist)43 ClientNotExist (SQLDatabase.SQLDatabaseException.ClientNotExist)40 Location (BasicCommonClasses.Location)35 ManufacturerNotExist (SQLDatabase.SQLDatabaseException.ManufacturerNotExist)31 AuthenticationError (SQLDatabase.SQLDatabaseException.AuthenticationError)27 ClientAlreadyConnected (SQLDatabase.SQLDatabaseException.ClientAlreadyConnected)27 NumberOfConnectionsExceeded (SQLDatabase.SQLDatabaseException.NumberOfConnectionsExceeded)27 CatalogProduct (BasicCommonClasses.CatalogProduct)22