Search in sources :

Example 6 with CustomerProfile

use of BasicCommonClasses.CustomerProfile 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());
}
Also used : SQLDatabaseConnection(SQLDatabase.SQLDatabaseConnection) CriticalError(SQLDatabase.SQLDatabaseException.CriticalError) ClientAlreadyExist(SQLDatabase.SQLDatabaseException.ClientAlreadyExist) ForgotPasswordData(BasicCommonClasses.ForgotPasswordData) CustomerProfile(BasicCommonClasses.CustomerProfile) IngredientNotExist(SQLDatabase.SQLDatabaseException.IngredientNotExist) ClientNotExist(SQLDatabase.SQLDatabaseException.ClientNotExist) Test(org.junit.Test)

Example 7 with CustomerProfile

use of BasicCommonClasses.CustomerProfile 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) {
    }
}
Also used : SQLDatabaseConnection(SQLDatabase.SQLDatabaseConnection) CriticalError(SQLDatabase.SQLDatabaseException.CriticalError) ForgotPasswordData(BasicCommonClasses.ForgotPasswordData) CustomerProfile(BasicCommonClasses.CustomerProfile) IngredientNotExist(SQLDatabase.SQLDatabaseException.IngredientNotExist) ClientNotExist(SQLDatabase.SQLDatabaseException.ClientNotExist) Test(org.junit.Test)

Aggregations

CustomerProfile (BasicCommonClasses.CustomerProfile)7 CriticalError (SQLDatabase.SQLDatabaseException.CriticalError)5 ClientNotExist (SQLDatabase.SQLDatabaseException.ClientNotExist)4 IngredientNotExist (SQLDatabase.SQLDatabaseException.IngredientNotExist)4 ForgotPasswordData (BasicCommonClasses.ForgotPasswordData)3 CommandWrapper (ClientServerApi.CommandWrapper)2 SQLDatabaseConnection (SQLDatabase.SQLDatabaseConnection)2 ClientAlreadyExist (SQLDatabase.SQLDatabaseException.ClientAlreadyExist)2 SQLException (java.sql.SQLException)2 Test (org.junit.Test)2 ICustomerProfile (BasicCommonClasses.ICustomerProfile)1 Ingredient (BasicCommonClasses.Ingredient)1 ICustomer (CustomerContracts.ICustomer)1 SMException (SMExceptions.SMException)1 SQLDatabaseException (SQLDatabase.SQLDatabaseException)1 PreparedStatement (java.sql.PreparedStatement)1 ResultSet (java.sql.ResultSet)1 LocalDate (java.time.LocalDate)1 FXML (javafx.fxml.FXML)1