Search in sources :

Example 46 with ClientNotConnected

use of SQLDatabase.SQLDatabaseException.ClientNotConnected 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 47 with ClientNotConnected

use of SQLDatabase.SQLDatabaseException.ClientNotConnected 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 48 with ClientNotConnected

use of SQLDatabase.SQLDatabaseException.ClientNotConnected 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 49 with ClientNotConnected

use of SQLDatabase.SQLDatabaseException.ClientNotConnected 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 50 with ClientNotConnected

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

the class SQLDatabaseConnectionTest method testWorkerConnection.

@Test
public void testWorkerConnection() {
    SQLDatabaseConnection sqlConnection = new SQLDatabaseConnection();
    int session = 0;
    try {
        session = sqlConnection.loginWorker("admin", "admin");
    } catch (AuthenticationError | CriticalError | ClientAlreadyConnected | NumberOfConnectionsExceeded e) {
        fail();
    }
    try {
        sqlConnection.logout(session, "admin");
    } catch (CriticalError | ClientNotConnected e) {
        fail();
    }
}
Also used : AuthenticationError(SQLDatabase.SQLDatabaseException.AuthenticationError) SQLDatabaseConnection(SQLDatabase.SQLDatabaseConnection) CriticalError(SQLDatabase.SQLDatabaseException.CriticalError) ClientNotConnected(SQLDatabase.SQLDatabaseException.ClientNotConnected) NumberOfConnectionsExceeded(SQLDatabase.SQLDatabaseException.NumberOfConnectionsExceeded) ClientAlreadyConnected(SQLDatabase.SQLDatabaseException.ClientAlreadyConnected) Test(org.junit.Test)

Aggregations

ClientNotConnected (SQLDatabase.SQLDatabaseException.ClientNotConnected)172 CriticalError (SQLDatabase.SQLDatabaseException.CriticalError)172 Test (org.junit.Test)147 CommandWrapper (ClientServerApi.CommandWrapper)124 CommandExecuter (CommandHandler.CommandExecuter)100 Gson (com.google.gson.Gson)96 ProductNotExistInCatalog (SQLDatabase.SQLDatabaseException.ProductNotExistInCatalog)81 SmartCode (BasicCommonClasses.SmartCode)63 ProductPackage (BasicCommonClasses.ProductPackage)55 SQLDatabaseConnection (SQLDatabase.SQLDatabaseConnection)48 ProductPackageAmountNotMatch (SQLDatabase.SQLDatabaseException.ProductPackageAmountNotMatch)43 ProductPackageNotExist (SQLDatabase.SQLDatabaseException.ProductPackageNotExist)43 Location (BasicCommonClasses.Location)34 IngredientNotExist (SQLDatabase.SQLDatabaseException.IngredientNotExist)32 ManufacturerNotExist (SQLDatabase.SQLDatabaseException.ManufacturerNotExist)31 CatalogProduct (BasicCommonClasses.CatalogProduct)21 AuthenticationError (SQLDatabase.SQLDatabaseException.AuthenticationError)19 ClientAlreadyConnected (SQLDatabase.SQLDatabaseException.ClientAlreadyConnected)19 NumberOfConnectionsExceeded (SQLDatabase.SQLDatabaseException.NumberOfConnectionsExceeded)19 Manufacturer (BasicCommonClasses.Manufacturer)12