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;
}
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) {
}
}
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);
}
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) {
}
}
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();
}
}
Aggregations