use of SQLDatabase.SQLDatabaseException.ClientNotExist in project SmartCity-Market by TechnionYP5777.
the class RemoveWorkerTest method removeWorkerCriticalErrorTest.
@Test
public void removeWorkerCriticalErrorTest() {
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 CriticalError()).when(sqlDatabaseConnection).removeWorker(senderID, username);
} catch (ClientNotExist | ClientNotConnected e) {
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 RemoveWorkerTest method removeWorkerSuccessfulTest.
@Test
public void removeWorkerSuccessfulTest() {
String command = new CommandWrapper(senderID, CommandDescriptor.REMOVE_WORKER, new Gson().toJson(username, String.class)).serialize();
CommandExecuter commandExecuter = new CommandExecuter(command);
CommandWrapper out;
try {
Mockito.doNothing().when(sqlDatabaseConnection).removeWorker(senderID, username);
} catch (CriticalError | ClientNotExist | ClientNotConnected e) {
fail();
}
out = commandExecuter.execute(sqlDatabaseConnection);
assertEquals(ResultDescriptor.SM_OK, out.getResultDescriptor());
}
use of SQLDatabase.SQLDatabaseException.ClientNotExist in project SmartCity-Market by TechnionYP5777.
the class SQLDatabaseConnectionTest method testCustomerCanLoginWithNewPassword.
@Test
public void testCustomerCanLoginWithNewPassword() {
SQLDatabaseConnection sqlConnection = new SQLDatabaseConnection();
try {
sqlConnection.registerCustomer(customerName, customerName);
} catch (CriticalError | ClientAlreadyExist e) {
fail();
}
try {
sqlConnection.setPasswordCustomer(customerName, "newPass");
//try to login with new password
int sessionID = sqlConnection.loginCustomer(customerName, "newPass");
sqlConnection.logout(sessionID, customerName);
} catch (CriticalError | ClientNotExist | AuthenticationError | ClientAlreadyConnected | NumberOfConnectionsExceeded | ClientNotConnected e1) {
fail();
} finally {
try {
sqlConnection.removeCustomer(customerName);
} catch (CriticalError | ClientNotExist e) {
e.printStackTrace();
}
}
}
use of SQLDatabase.SQLDatabaseException.ClientNotExist in project SmartCity-Market by TechnionYP5777.
the class RemoveWorkerTest method removeWorkerClientNotConnectedTest.
@Test
public void removeWorkerClientNotConnectedTest() {
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 ClientNotConnected()).when(sqlDatabaseConnection).removeWorker(senderID, username);
} catch (CriticalError | ClientNotExist e) {
fail();
} catch (ClientNotConnected e) {
/* success */
}
out = commandExecuter.execute(sqlDatabaseConnection);
assertEquals(ResultDescriptor.SM_SENDER_IS_NOT_CONNECTED, out.getResultDescriptor());
}
use of SQLDatabase.SQLDatabaseException.ClientNotExist in project SmartCity-Market by TechnionYP5777.
the class UpdateCustomerProfileTest method updateCustomerProfileClientNotExistTest.
@Test
public void updateCustomerProfileClientNotExistTest() {
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 ClientNotExist()).when(sqlDatabaseConnection).setCustomerProfile(customerProfile.getUserName(), customerProfile);
} catch (CriticalError | IngredientNotExist e1) {
fail();
} catch (ClientNotExist e) {
/* success */
}
out = commandExecuter.execute(sqlDatabaseConnection);
assertEquals(ResultDescriptor.SM_USERNAME_DOES_NOT_EXIST, out.getResultDescriptor());
}
Aggregations