use of SQLDatabase.SQLDatabaseException.ClientNotExist in project SmartCity-Market by TechnionYP5777.
the class SQLDatabaseConnectionTest method testCustomerCanSetProfile.
@Test
public void testCustomerCanSetProfile() {
SQLDatabaseConnection sqlConnection = new SQLDatabaseConnection();
CustomerProfile p = new CustomerProfile(customerName, customerName, "name", "last", "number", "email", "city", "street", date112000, new HashSet<>(), new ForgotPasswordData("question", "answer"));
CustomerProfile result = null;
try {
sqlConnection.registerCustomer(customerName, customerName);
} catch (CriticalError | ClientAlreadyExist e) {
fail();
}
try {
sqlConnection.setCustomerProfile(customerName, p);
result = Serialization.deserialize(sqlConnection.getCustomerProfile(customerName), CustomerProfile.class);
} catch (CriticalError | ClientNotExist | IngredientNotExist e1) {
fail();
} finally {
try {
sqlConnection.removeCustomer(customerName);
} catch (CriticalError | ClientNotExist e) {
e.printStackTrace();
}
}
assertEquals(p.getBirthdate(), result.getBirthdate());
assertEquals(p.getCity(), result.getCity());
assertEquals(p.getEmailAddress(), result.getEmailAddress());
assertEquals(p.getFirstName(), result.getFirstName());
assertEquals(p.getLastName(), result.getLastName());
assertEquals(p.getPhoneNumber(), result.getPhoneNumber());
assertEquals(p.getStreet(), result.getStreet());
assertEquals(p.getUserName(), result.getUserName());
}
use of SQLDatabase.SQLDatabaseException.ClientNotExist in project SmartCity-Market by TechnionYP5777.
the class SQLDatabaseConnectionTest method testCantSetSecurityQAToNotExistedCustomer.
@Test
public void testCantSetSecurityQAToNotExistedCustomer() {
SQLDatabaseConnection sqlConnection = new SQLDatabaseConnection();
ForgotPasswordData p = new ForgotPasswordData("question", "answer");
try {
sqlConnection.setSecurityQACustomer(customerName, p);
fail();
} catch (CriticalError e1) {
fail();
} catch (ClientNotExist e2) {
}
}
use of SQLDatabase.SQLDatabaseException.ClientNotExist in project SmartCity-Market by TechnionYP5777.
the class SQLDatabaseConnectionTest method testCustomerCanLoginLogout.
@Test
public void testCustomerCanLoginLogout() {
SQLDatabaseConnection sqlConnection = new SQLDatabaseConnection();
try {
sqlConnection.registerCustomer(customerName, customerName);
} catch (CriticalError | ClientAlreadyExist e) {
fail();
}
try {
int sessionID = sqlConnection.loginCustomer(customerName, customerName);
sqlConnection.logout(sessionID, customerName);
} catch (AuthenticationError | ClientAlreadyConnected | CriticalError | 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 SQLDatabaseConnectionTest method testCantSetProfileToNotExistedCustomer.
@Test
public void testCantSetProfileToNotExistedCustomer() {
SQLDatabaseConnection sqlConnection = new SQLDatabaseConnection();
CustomerProfile p = new CustomerProfile(customerName, customerName, "name", "last", "number", "email", "city", "street", date112000, new HashSet<>(), new ForgotPasswordData("question", "answer"));
try {
sqlConnection.setCustomerProfile(customerName, p);
fail();
} catch (CriticalError | IngredientNotExist e1) {
fail();
} catch (ClientNotExist e2) {
}
}
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());
}
Aggregations