Search in sources :

Example 11 with ForgotPasswordData

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

Example 12 with ForgotPasswordData

use of BasicCommonClasses.ForgotPasswordData 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)

Example 13 with ForgotPasswordData

use of BasicCommonClasses.ForgotPasswordData in project SmartCity-Market by TechnionYP5777.

the class SQLDatabaseConnectionTest method testCustomerCanSetSecurityQA.

@Test
public void testCustomerCanSetSecurityQA() {
    SQLDatabaseConnection sqlConnection = new SQLDatabaseConnection();
    ForgotPasswordData p = new ForgotPasswordData("question", "answer");
    String result = null;
    try {
        sqlConnection.registerCustomer(customerName, customerName);
    } catch (CriticalError | ClientAlreadyExist e) {
        fail();
    }
    try {
        sqlConnection.setSecurityQACustomer(customerName, p);
        result = sqlConnection.getSecurityQuestionCustomer(customerName);
        assertTrue(sqlConnection.verifySecurityAnswerCustomer(customerName, "answer"));
        assertEquals("question", result);
    } catch (CriticalError | ClientNotExist e1) {
        fail();
    } finally {
        try {
            sqlConnection.removeCustomer(customerName);
        } catch (CriticalError | ClientNotExist e) {
            e.printStackTrace();
        }
    }
}
Also used : SQLDatabaseConnection(SQLDatabase.SQLDatabaseConnection) CriticalError(SQLDatabase.SQLDatabaseException.CriticalError) ClientAlreadyExist(SQLDatabase.SQLDatabaseException.ClientAlreadyExist) ForgotPasswordData(BasicCommonClasses.ForgotPasswordData) ClientNotExist(SQLDatabase.SQLDatabaseException.ClientNotExist) Test(org.junit.Test)

Example 14 with ForgotPasswordData

use of BasicCommonClasses.ForgotPasswordData in project SmartCity-Market by TechnionYP5777.

the class SQLDatabaseConnectionTest method testCantSetSecurityQAToNotExistedWorker.

@Test
public void testCantSetSecurityQAToNotExistedWorker() {
    SQLDatabaseConnection sqlConnection = new SQLDatabaseConnection();
    ForgotPasswordData p = new ForgotPasswordData("question", "answer");
    try {
        sqlConnection.setSecurityQAWorker(workerName, p);
        fail();
    } catch (CriticalError e1) {
        fail();
    } catch (ClientNotExist e2) {
    }
}
Also used : SQLDatabaseConnection(SQLDatabase.SQLDatabaseConnection) CriticalError(SQLDatabase.SQLDatabaseException.CriticalError) ForgotPasswordData(BasicCommonClasses.ForgotPasswordData) ClientNotExist(SQLDatabase.SQLDatabaseException.ClientNotExist) Test(org.junit.Test)

Aggregations

ForgotPasswordData (BasicCommonClasses.ForgotPasswordData)14 Test (org.junit.Test)11 SQLDatabaseConnection (SQLDatabase.SQLDatabaseConnection)9 ClientNotExist (SQLDatabase.SQLDatabaseException.ClientNotExist)9 CriticalError (SQLDatabase.SQLDatabaseException.CriticalError)9 Login (BasicCommonClasses.Login)8 ClientAlreadyExist (SQLDatabase.SQLDatabaseException.ClientAlreadyExist)6 ClientNotConnected (SQLDatabase.SQLDatabaseException.ClientNotConnected)4 CustomerProfile (BasicCommonClasses.CustomerProfile)3 CommandWrapper (ClientServerApi.CommandWrapper)3 IngredientNotExist (SQLDatabase.SQLDatabaseException.IngredientNotExist)2 IForgotPasswordHandler (UtilsContracts.IForgotPasswordHandler)2 NoSuchUserName (UtilsImplementations.ForgotPasswordHandler.NoSuchUserName)2 WrongAnswer (UtilsImplementations.ForgotPasswordHandler.WrongAnswer)2 IOException (java.io.IOException)2 FXML (javafx.fxml.FXML)2 ICustomerProfile (BasicCommonClasses.ICustomerProfile)1 ICustomer (CustomerContracts.ICustomer)1 ConnectionFailure (EmployeeDefs.AEmployeeException.ConnectionFailure)1 EmployeeNotConnected (EmployeeDefs.AEmployeeException.EmployeeNotConnected)1