Search in sources :

Example 1 with IForgotPasswordHandler

use of UtilsContracts.IForgotPasswordHandler in project SmartCity-Market by TechnionYP5777.

the class ForgotPasswordTest method sendWrongAnswerWithNewPassword.

@Test
public void sendWrongAnswerWithNewPassword() {
    ForgotPasswordData forgotPassData = new ForgotPasswordData(null, authQuestionAnswer + "bla");
    Login ansAndPassContainer = new Login(worker.getUsername(), newPass, forgotPassData);
    try {
        Mockito.when(clientRequestHandler.sendRequestWithRespond(new CommandWrapper(WorkerDefs.loginCommandSenderId, CommandDescriptor.FORGOT_PASSWORD_SEND_ANSWER_WITH_NEW_PASSWORD, Serialization.serialize(ansAndPassContainer)).serialize())).thenReturn(new CommandWrapper(ResultDescriptor.SM_FOROGT_PASSWORD_WRONG_ANSWER, null).serialize());
    } catch (IOException ¢) {
        fail();
    }
    try {
        ((IForgotPasswordHandler) worker).sendAnswerAndNewPassword(authQuestionAnswer + "bla", newPass);
    } catch (WrongAnswer e) {
        //success
        return;
    } catch (NoSuchUserName e) {
        fail();
    }
    fail();
}
Also used : WrongAnswer(UtilsImplementations.ForgotPasswordHandler.WrongAnswer) IForgotPasswordHandler(UtilsContracts.IForgotPasswordHandler) NoSuchUserName(UtilsImplementations.ForgotPasswordHandler.NoSuchUserName) ForgotPasswordData(BasicCommonClasses.ForgotPasswordData) CommandWrapper(ClientServerApi.CommandWrapper) Login(BasicCommonClasses.Login) IOException(java.io.IOException) Test(org.junit.Test)

Example 2 with IForgotPasswordHandler

use of UtilsContracts.IForgotPasswordHandler in project SmartCity-Market by TechnionYP5777.

the class EmployeeLoginScreen method forgetPassPressed.

@FXML
void forgetPassPressed(MouseEvent __) {
    try {
        IForgotPasswordHandler forgot = InjectionFactory.getInstance(Worker.class);
        ForgetPasswordWizard.start(forgot);
    } catch (Exception e) {
        log.fatal(e);
        log.debug(StackTraceUtil.getStackTrace(e));
    //TODO
    }
}
Also used : IForgotPasswordHandler(UtilsContracts.IForgotPasswordHandler) SMException(SMExceptions.SMException) FXML(javafx.fxml.FXML)

Example 3 with IForgotPasswordHandler

use of UtilsContracts.IForgotPasswordHandler in project SmartCity-Market by TechnionYP5777.

the class ForgotPasswordTest method sendCorrectAnswerWithNewPassword.

@Test
public void sendCorrectAnswerWithNewPassword() {
    ForgotPasswordData forgotPassData = new ForgotPasswordData(null, authQuestionAnswer);
    Login ansAndPassContainer = new Login(worker.getUsername(), newPass, forgotPassData);
    try {
        Mockito.when(clientRequestHandler.sendRequestWithRespond(new CommandWrapper(WorkerDefs.loginCommandSenderId, CommandDescriptor.FORGOT_PASSWORD_SEND_ANSWER_WITH_NEW_PASSWORD, Serialization.serialize(ansAndPassContainer)).serialize())).thenReturn(new CommandWrapper(ResultDescriptor.SM_OK, Serialization.serialize(true)).serialize());
    } catch (IOException ¢) {
        fail();
    }
    try {
        ((IForgotPasswordHandler) worker).sendAnswerAndNewPassword(authQuestionAnswer, newPass);
    } catch (NoSuchUserName | WrongAnswer e) {
        fail();
    }
}
Also used : WrongAnswer(UtilsImplementations.ForgotPasswordHandler.WrongAnswer) IForgotPasswordHandler(UtilsContracts.IForgotPasswordHandler) NoSuchUserName(UtilsImplementations.ForgotPasswordHandler.NoSuchUserName) ForgotPasswordData(BasicCommonClasses.ForgotPasswordData) CommandWrapper(ClientServerApi.CommandWrapper) Login(BasicCommonClasses.Login) IOException(java.io.IOException) Test(org.junit.Test)

Example 4 with IForgotPasswordHandler

use of UtilsContracts.IForgotPasswordHandler in project SmartCity-Market by TechnionYP5777.

the class CustomerLoginScreen method forgotPassButtonPressed.

@FXML
void forgotPassButtonPressed(MouseEvent __) {
    try {
        IForgotPasswordHandler forgot = InjectionFactory.getInstance(Customer.class);
        ForgetPasswordWizard.start(forgot);
    } catch (Exception e) {
    // TODO
    }
}
Also used : IForgotPasswordHandler(UtilsContracts.IForgotPasswordHandler) SMException(SMExceptions.SMException) FXML(javafx.fxml.FXML)

Aggregations

IForgotPasswordHandler (UtilsContracts.IForgotPasswordHandler)4 ForgotPasswordData (BasicCommonClasses.ForgotPasswordData)2 Login (BasicCommonClasses.Login)2 CommandWrapper (ClientServerApi.CommandWrapper)2 SMException (SMExceptions.SMException)2 NoSuchUserName (UtilsImplementations.ForgotPasswordHandler.NoSuchUserName)2 WrongAnswer (UtilsImplementations.ForgotPasswordHandler.WrongAnswer)2 IOException (java.io.IOException)2 FXML (javafx.fxml.FXML)2 Test (org.junit.Test)2