use of SQLDatabase.SQLDatabaseException.ClientNotExist in project SmartCity-Market by TechnionYP5777.
the class SQLDatabaseConnectionTest method testCantGetProfileToNotExistedCustomer.
@Test
public void testCantGetProfileToNotExistedCustomer() {
SQLDatabaseConnection sqlConnection = new SQLDatabaseConnection();
try {
Serialization.deserialize(sqlConnection.getCustomerProfile(customerName), CustomerProfile.class);
fail();
} catch (CriticalError e1) {
fail();
} catch (ClientNotExist e2) {
}
}
use of SQLDatabase.SQLDatabaseException.ClientNotExist in project SmartCity-Market by TechnionYP5777.
the class SQLDatabaseConnectionTest method testAddRemoveWorker.
@Test
public void testAddRemoveWorker() {
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 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 RemoveWorkerTest method removeWorkerClientNotExistTest.
@Test
public void removeWorkerClientNotExistTest() {
String command = new CommandWrapper(senderID, CommandDescriptor.REMOVE_WORKER, new Gson().toJson(username, String.class)).serialize();
CommandExecuter commandExecuter = new CommandExecuter(command);
CommandWrapper out;
try {
Mockito.doThrow(new ClientNotExist()).when(sqlDatabaseConnection).removeWorker(senderID, username);
} catch (CriticalError | ClientNotConnected e) {
fail();
} catch (ClientNotExist e) {
/* success */
}
out = commandExecuter.execute(sqlDatabaseConnection);
assertEquals(ResultDescriptor.SM_USERNAME_DOES_NOT_EXIST, out.getResultDescriptor());
}
use of SQLDatabase.SQLDatabaseException.ClientNotExist in project SmartCity-Market by TechnionYP5777.
the class UpdateCustomerProfileTest method updateCustomerProfileCriticalErrorTest.
@Test
public void updateCustomerProfileCriticalErrorTest() {
String command = new CommandWrapper(senderID, CommandDescriptor.UPDATE_CUSTOMER_PROFILE, new Gson().toJson(customerProfile, CustomerProfile.class)).serialize();
CommandExecuter commandExecuter = new CommandExecuter(command);
CommandWrapper out;
try {
Mockito.doThrow(new CriticalError()).when(sqlDatabaseConnection).setCustomerProfile(customerProfile.getUserName(), customerProfile);
} catch (ClientNotExist | IngredientNotExist e1) {
fail();
} catch (CriticalError e) {
/* success */
}
out = commandExecuter.execute(sqlDatabaseConnection);
assertEquals(ResultDescriptor.SM_ERR, out.getResultDescriptor());
}
use of SQLDatabase.SQLDatabaseException.ClientNotExist in project SmartCity-Market by TechnionYP5777.
the class UpdateCustomerProfileTest method updateCustomerProfileSuccessfulTest.
@Test
public void updateCustomerProfileSuccessfulTest() {
String command = new CommandWrapper(senderID, CommandDescriptor.UPDATE_CUSTOMER_PROFILE, new Gson().toJson(customerProfile, CustomerProfile.class)).serialize();
CommandExecuter commandExecuter = new CommandExecuter(command);
CommandWrapper out;
try {
Mockito.doNothing().when(sqlDatabaseConnection).setCustomerProfile(customerProfile.getUserName(), customerProfile);
} catch (CriticalError | ClientNotExist | IngredientNotExist e1) {
fail();
}
out = commandExecuter.execute(sqlDatabaseConnection);
assertEquals(ResultDescriptor.SM_OK, out.getResultDescriptor());
}
Aggregations