use of SQLDatabase.SQLDatabaseException.AuthenticationError in project SmartCity-Market by TechnionYP5777.
the class LoginTest method loginEmployeeUsernameDoesNotExistWrongPasswordTest.
@Test
public void loginEmployeeUsernameDoesNotExistWrongPasswordTest() {
Login login = new Login("unknown", "unknown");
String command = new CommandWrapper(0, CommandDescriptor.LOGIN_EMPLOYEE, new Gson().toJson(login, Login.class)).serialize();
CommandExecuter commandExecuter = new CommandExecuter(command);
CommandWrapper out;
try {
Mockito.when(sqlDatabaseConnection.loginWorker(login.getUserName(), login.getPassword())).thenThrow(new AuthenticationError());
} catch (NumberOfConnectionsExceeded | ClientAlreadyConnected | CriticalError | AuthenticationError e) {
fail();
}
out = commandExecuter.execute(sqlDatabaseConnection);
assertEquals(ResultDescriptor.SM_USERNAME_DOES_NOT_EXIST_WRONG_PASSWORD, out.getResultDescriptor());
}
use of SQLDatabase.SQLDatabaseException.AuthenticationError in project SmartCity-Market by TechnionYP5777.
the class LoginTest method loginCustomerSuccessfulTest.
@Test
public void loginCustomerSuccessfulTest() {
Login login = new Login("admin", "admin");
String command = new CommandWrapper(0, CommandDescriptor.LOGIN_EMPLOYEE, new Gson().toJson(login, Login.class)).serialize();
CommandExecuter commandExecuter = new CommandExecuter(command);
CommandWrapper out;
try {
Mockito.when(sqlDatabaseConnection.loginCustomer(login.getUserName(), login.getPassword())).thenReturn(CUSTOMER_SENDER_ID);
} catch (NumberOfConnectionsExceeded | ClientAlreadyConnected | CriticalError | AuthenticationError e) {
fail();
}
out = commandExecuter.execute(sqlDatabaseConnection);
assertEquals(ResultDescriptor.SM_OK, out.getResultDescriptor());
}
Aggregations