use of CustomerImplementations.Customer in project SmartCity-Market by TechnionYP5777.
the class LogoutTest method setup.
@Before
public void setup() {
PropertyConfigurator.configure("../log4j.properties");
customer = new Customer(clientRequestHandler);
}
use of CustomerImplementations.Customer in project SmartCity-Market by TechnionYP5777.
the class RemoveProductFromCartTest method setup.
@Before
public void setup() {
PropertyConfigurator.configure("../log4j.properties");
customer = new Customer(clientRequestHandler);
try {
Mockito.when(clientRequestHandler.sendRequestWithRespond(new CommandWrapper(CustomerDefs.loginCommandSenderId, CommandDescriptor.ADD_PRODUCT_TO_GROCERY_LIST, Serialization.serialize(pp)).serialize())).thenReturn(new CommandWrapper(ResultDescriptor.SM_OK).serialize());
} catch (IOException ¢) {
fail();
}
try {
Mockito.when(clientRequestHandler.sendRequestWithRespond(new CommandWrapper(CustomerDefs.loginCommandSenderId, CommandDescriptor.VIEW_PRODUCT_FROM_CATALOG, Serialization.serialize(sc)).serialize())).thenReturn(new CommandWrapper(ResultDescriptor.SM_OK, Serialization.serialize(catalogProduct)).serialize());
} catch (IOException ¢) {
fail();
}
try {
customer.addProductToCart(sc, amount);
} catch (CriticalError | CustomerNotConnected | AmountBiggerThanAvailable | ProductPackageDoesNotExist | InvalidParameter e1) {
fail();
}
}
use of CustomerImplementations.Customer in project SmartCity-Market by TechnionYP5777.
the class ResumeTest method setup.
@Before
public void setup() {
PropertyConfigurator.configure("../log4j.properties");
customer = new Customer(clientRequestHandler);
}
use of CustomerImplementations.Customer in project SmartCity-Market by TechnionYP5777.
the class AddProductToCartTest method setup.
@Before
public void setup() {
PropertyConfigurator.configure("../log4j.properties");
customer = new Customer(clientRequestHandler);
}
use of CustomerImplementations.Customer in project SmartCity-Market by TechnionYP5777.
the class CustomerRegistration_PersonalInfoScreen method initialize.
@Override
public void initialize(URL location, ResourceBundle __) {
AbstractApplicationScreen.fadeTransition(personalInfoScreenPane);
updateFields();
customer = InjectionFactory.getInstance(Customer.class);
userNameTextField.textProperty().addListener((observable, oldValue, newValue) -> {
if (validNewUserName(newValue))
TempCustomerProfilePassingData.customerProfile.setUserName(newValue);
else
DialogMessagesService.showErrorDialog(GuiCommonDefs.registrationFieldFailureTitle, null, GuiCommonDefs.registrationUsedUserName);
});
userValidator1 = new RequiredFieldValidator();
userValidator1.setMessage("Input Required");
userValidator1.setIcon(GlyphsBuilder.create(FontAwesomeIconView.class).glyph(FontAwesomeIcon.WARNING).size("1em").styleClass("error").build());
userValidator2 = new RequiredFieldValidator();
userValidator2.setMessage("Username Already Exists");
userValidator2.setIcon(GlyphsBuilder.create(FontAwesomeIconView.class).glyph(FontAwesomeIcon.WARNING).size("1em").styleClass("error").build());
userNameTextField.focusedProperty().addListener((o, oldVal, newVal) -> {
if (!newVal) {
userNameTextField.getValidators().add(userValidator1);
userNameTextField.validate();
} else if (!validNewUserName(userNameTextField.getText())) {
userNameTextField.getValidators().add(userValidator2);
userNameTextField.validate();
}
});
passwordField.textProperty().addListener((observable, oldValue, newValue) -> {
TempCustomerProfilePassingData.password = newValue;
enableNextButton();
});
RequiredFieldValidator userValidator3 = new RequiredFieldValidator();
userValidator3.setMessage("Input Required");
userValidator3.setIcon(GlyphsBuilder.create(FontAwesomeIconView.class).glyph(FontAwesomeIcon.WARNING).size("1em").styleClass("error").build());
passwordField.getValidators().add(userValidator3);
passwordField.focusedProperty().addListener((o, oldVal, newVal) -> {
if (!newVal)
passwordField.validate();
});
firstNameTextField.textProperty().addListener((observable, oldValue, newValue) -> {
TempCustomerProfilePassingData.customerProfile.setFirstName(newValue);
enableNextButton();
});
RequiredFieldValidator val4 = new RequiredFieldValidator();
val4.setMessage("Input Required");
val4.setIcon(GlyphsBuilder.create(FontAwesomeIconView.class).glyph(FontAwesomeIcon.WARNING).size("1em").styleClass("error").build());
firstNameTextField.getValidators().add(val4);
firstNameTextField.focusedProperty().addListener((o, oldVal, newVal) -> {
if (!newVal)
firstNameTextField.validate();
});
lastNameTextField.textProperty().addListener((observable, oldValue, newValue) -> {
TempCustomerProfilePassingData.customerProfile.setLastName(newValue);
enableNextButton();
});
RequiredFieldValidator val5 = new RequiredFieldValidator();
val5.setMessage("Input Required");
val5.setIcon(GlyphsBuilder.create(FontAwesomeIconView.class).glyph(FontAwesomeIcon.WARNING).size("1em").styleClass("error").build());
lastNameTextField.getValidators().add(val5);
lastNameTextField.focusedProperty().addListener((o, oldVal, newVal) -> {
if (!newVal)
lastNameTextField.validate();
});
phoneNumberTextField.textProperty().addListener((observable, oldValue, newValue) -> {
if (!newValue.matches("\\d*")) {
phoneNumberTextField.setText(newValue.replaceAll("[^\\d]", ""));
return;
}
TempCustomerProfilePassingData.customerProfile.setPhoneNumber(newValue);
enableNextButton();
});
RequiredFieldValidator val6 = new RequiredFieldValidator();
val6.setMessage("Input Required");
val6.setIcon(GlyphsBuilder.create(FontAwesomeIconView.class).glyph(FontAwesomeIcon.WARNING).size("1em").styleClass("error").build());
phoneNumberTextField.getValidators().add(val6);
phoneNumberTextField.focusedProperty().addListener((o, oldVal, newVal) -> {
if (!newVal)
phoneNumberTextField.validate();
});
emailTextField.textProperty().addListener((observable, oldValue, newValue) -> {
TempCustomerProfilePassingData.customerProfile.setEmailAddress(newValue);
enableNextButton();
});
RequiredFieldValidator val9 = new RequiredFieldValidator();
val9.setMessage("Input Required");
val9.setIcon(GlyphsBuilder.create(FontAwesomeIconView.class).glyph(FontAwesomeIcon.WARNING).size("1em").styleClass("error").build());
emailTextField.getValidators().add(val9);
emailTextField.focusedProperty().addListener((o, oldVal, newVal) -> {
if (!newVal)
emailTextField.validate();
});
cityTextField.textProperty().addListener((observable, oldValue, newValue) -> {
TempCustomerProfilePassingData.customerProfile.setCity(newValue);
enableNextButton();
});
RequiredFieldValidator val10 = new RequiredFieldValidator();
val10.setMessage("Input Required");
val10.setIcon(GlyphsBuilder.create(FontAwesomeIconView.class).glyph(FontAwesomeIcon.WARNING).size("1em").styleClass("error").build());
cityTextField.getValidators().add(val10);
cityTextField.focusedProperty().addListener((o, oldVal, newVal) -> {
if (!newVal)
cityTextField.validate();
});
streetTextField.textProperty().addListener((observable, oldValue, newValue) -> {
TempCustomerProfilePassingData.customerProfile.setStreet(newValue);
enableNextButton();
});
RequiredFieldValidator val7 = new RequiredFieldValidator();
val7.setMessage("Input Required");
val7.setIcon(GlyphsBuilder.create(FontAwesomeIconView.class).glyph(FontAwesomeIcon.WARNING).size("1em").styleClass("error").build());
streetTextField.getValidators().add(val7);
streetTextField.focusedProperty().addListener((o, oldVal, newVal) -> {
if (!newVal)
streetTextField.validate();
});
birthDatePicker.valueProperty().addListener((observable, oldValue, newValue) -> {
TempCustomerProfilePassingData.customerProfile.setBirthdate(newValue);
enableNextButton();
});
securityQuestionComboBox.valueProperty().addListener((observable, oldValue, newValue) -> {
TempCustomerProfilePassingData.sequrityQuestion = newValue;
enableNextButton();
});
securityQuestionComboBox.setButtonCell(new ListCell<String>() {
@Override
protected void updateItem(String item, boolean empty) {
super.updateItem(item, empty);
if (!empty && item != null)
setText(item + "");
else {
setStyle(null);
setText(null);
}
}
});
securityAnswerTextField.textProperty().addListener((observable, oldValue, newValue) -> {
TempCustomerProfilePassingData.sequrityAnswer = newValue;
enableNextButton();
});
RequiredFieldValidator val8 = new RequiredFieldValidator();
val8.setMessage("Input Required");
val8.setIcon(GlyphsBuilder.create(FontAwesomeIconView.class).glyph(FontAwesomeIcon.WARNING).size("1em").styleClass("error").build());
securityAnswerTextField.getValidators().add(val8);
securityAnswerTextField.focusedProperty().addListener((o, oldVal, newVal) -> {
if (!newVal)
securityAnswerTextField.validate();
});
birthDatePicker.setValue(LocalDate.now());
enableNextButton();
}
Aggregations