use of SQLDatabase.SQLDatabaseException.ClientNotExist in project SmartCity-Market by TechnionYP5777.
the class SQLDatabaseConnectionTest method testWorkerCanSetSecurityQA.
@Test
public void testWorkerCanSetSecurityQA() {
SQLDatabaseConnection sqlConnection = new SQLDatabaseConnection();
ForgotPasswordData p = new ForgotPasswordData("question", "answer");
String result = null;
try {
sqlConnection.addWorker(null, new Login(workerName, workerName), new ForgotPasswordData("", ""));
} catch (CriticalError | ClientAlreadyExist | ClientNotConnected e) {
fail();
}
try {
sqlConnection.setSecurityQAWorker(workerName, p);
result = sqlConnection.getSecurityQuestionWorker(workerName);
assertTrue(sqlConnection.verifySecurityAnswerWorker(workerName, "answer"));
assertEquals("question", result);
} catch (CriticalError | ClientNotExist e1) {
fail();
} finally {
try {
sqlConnection.removeWorker(null, workerName);
} catch (CriticalError | ClientNotExist | ClientNotConnected e) {
e.printStackTrace();
}
}
}
use of SQLDatabase.SQLDatabaseException.ClientNotExist in project SmartCity-Market by TechnionYP5777.
the class SQLDatabaseConnectionTest method testWorkerCanLoginWithNewPassword.
@Test
public void testWorkerCanLoginWithNewPassword() {
SQLDatabaseConnection sqlConnection = new SQLDatabaseConnection();
try {
sqlConnection.addWorker(null, new Login(workerName, workerName), new ForgotPasswordData("", ""));
} catch (CriticalError | ClientAlreadyExist | ClientNotConnected e) {
fail();
}
try {
sqlConnection.setPasswordWorker(workerName, "newPass");
//try to login with new password
int sessionID = sqlConnection.loginWorker(workerName, "newPass");
sqlConnection.logout(sessionID, workerName);
} catch (CriticalError | ClientNotExist | AuthenticationError | ClientAlreadyConnected | NumberOfConnectionsExceeded | ClientNotConnected e1) {
fail();
} finally {
try {
sqlConnection.removeWorker(null, workerName);
} catch (CriticalError | ClientNotExist | ClientNotConnected e) {
e.printStackTrace();
}
}
}
use of SQLDatabase.SQLDatabaseException.ClientNotExist in project SmartCity-Market by TechnionYP5777.
the class SQLDatabaseConnectionTest method testCantAddWorkerAlreadyExisted.
@Test
public void testCantAddWorkerAlreadyExisted() {
SQLDatabaseConnection sqlConnection = new SQLDatabaseConnection();
String result = null;
//test add worker
try {
sqlConnection.addWorker(null, new Login(workerName, workerName), new ForgotPasswordData("", ""));
result = sqlConnection.getWorkersList(null);
} catch (CriticalError | ClientNotConnected | ClientAlreadyExist e) {
fail();
}
assert result != null;
HashMap<String, Boolean> map = Serialization.deserializeWorkersHashMap(result);
assert map != null;
assert map.containsKey(workerName);
assertEquals(false, map.get(workerName));
//test add again the same worker
try {
sqlConnection.addWorker(null, new Login(workerName, workerName), new ForgotPasswordData("", ""));
fail();
} catch (CriticalError | ClientNotConnected e) {
fail();
} catch (ClientAlreadyExist e) {
}
//remove worker
try {
sqlConnection.removeWorker(null, workerName);
result = sqlConnection.getWorkersList(null);
} catch (CriticalError | ClientNotConnected | ClientNotExist e) {
fail();
}
assert result != null;
map = Serialization.deserializeWorkersHashMap(result);
assert map != null;
assert !map.containsKey(workerName);
}
use of SQLDatabase.SQLDatabaseException.ClientNotExist in project SmartCity-Market by TechnionYP5777.
the class SQLDatabaseConnectionTest method testCantVerifySecurityAnswerOfNotExistedCustomer.
@Test
public void testCantVerifySecurityAnswerOfNotExistedCustomer() {
SQLDatabaseConnection sqlConnection = new SQLDatabaseConnection();
try {
sqlConnection.verifySecurityAnswerCustomer(customerName, "answer");
fail();
} catch (CriticalError e1) {
fail();
} catch (ClientNotExist e2) {
}
}
use of SQLDatabase.SQLDatabaseException.ClientNotExist 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) {
}
}
Aggregations