Users can now add an image when they sign up
This commit is contained in:
@@ -21,6 +21,10 @@ public class MainController extends Controller{
|
||||
@FXML
|
||||
PasswordField password;
|
||||
|
||||
public void register() throws Exception{
|
||||
changeScene(SceneCode.REGISTER);
|
||||
}
|
||||
|
||||
public boolean validateLogin(String user, String pass){
|
||||
if (user.equals(pass)){
|
||||
return true;
|
||||
|
||||
@@ -0,0 +1,134 @@
|
||||
package controllers;
|
||||
|
||||
import javafx.collections.FXCollections;
|
||||
import javafx.collections.ObservableList;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.scene.control.Alert;
|
||||
import javafx.scene.control.ComboBox;
|
||||
import javafx.scene.control.PasswordField;
|
||||
import javafx.scene.control.TextField;
|
||||
import javafx.scene.text.Text;
|
||||
import model.SceneCode;
|
||||
import model.User;
|
||||
import utils.DataValidator;
|
||||
|
||||
import java.net.URL;
|
||||
import java.util.ResourceBundle;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* Created by Gondr on 1/06/2017.
|
||||
*/
|
||||
public class RegisterController extends Controller {
|
||||
@FXML
|
||||
private PasswordField password;
|
||||
@FXML
|
||||
private TextField address;
|
||||
@FXML
|
||||
private TextField mobilePhone;
|
||||
@FXML
|
||||
private PasswordField passwordConfirm;
|
||||
@FXML
|
||||
private TextField homePhone;
|
||||
@FXML
|
||||
private ComboBox<String> accountType;
|
||||
@FXML
|
||||
private TextField email;
|
||||
@FXML
|
||||
private TextField username;
|
||||
|
||||
public String validateStudentNumber(String studentNumber){
|
||||
String failure = "";
|
||||
//student number
|
||||
if (studentNumber.equals("") || studentNumber == null){
|
||||
failure += "Your must enter your Student Number.\n";
|
||||
}
|
||||
try{
|
||||
Integer.parseInt(studentNumber);
|
||||
} catch (NumberFormatException e){
|
||||
failure += "Your Student Number must be a number.\n";
|
||||
}
|
||||
return failure;
|
||||
}
|
||||
|
||||
public String validateEmail(String email){
|
||||
String failure = "";
|
||||
Pattern uclivePattern = Pattern.compile(".*@uclive.ac.nz", Pattern.CASE_INSENSITIVE);
|
||||
Pattern canterburyPattern = Pattern.compile(".*@canterbury.ac.nz", Pattern.CASE_INSENSITIVE);
|
||||
if (!uclivePattern.matcher(email).matches() && !canterburyPattern.matcher(email).matches()){
|
||||
failure += "Your email must end in @uclive.ac.nz or @canterbury.ac.nz.\n";
|
||||
}
|
||||
return failure;
|
||||
}
|
||||
|
||||
public String validatePassword(String p1, String p2){
|
||||
String failure = "";
|
||||
if (p1.length() < 6){
|
||||
failure += "Your password must be at least 6 letters long.\n";
|
||||
}
|
||||
if (!p1.equals(p2)){
|
||||
failure += "Your passwords entered do not match.\n";
|
||||
}
|
||||
return failure;
|
||||
}
|
||||
|
||||
public String validateAddress(String address){
|
||||
String failure = "";
|
||||
if (!DataValidator.addressValidator(address)){
|
||||
failure += "Your address must be similar to 1 University Drive or 1/1 University Drive or 1A/2 University Drive or 1A/2A University Drive.\n";
|
||||
}
|
||||
return failure;
|
||||
}
|
||||
|
||||
public String validatePhone(String hp, String mp){
|
||||
String failure = "";
|
||||
if ((hp.equals("") || hp == null) && (mp.equals("")||mp == null)){
|
||||
failure += "You must enter either a home phone number or a mobile phone number.\n";
|
||||
}
|
||||
return failure;
|
||||
}
|
||||
|
||||
public boolean validate(){
|
||||
String failure = "";
|
||||
failure += validateStudentNumber(username.getText());
|
||||
failure += validateEmail(email.getText());
|
||||
failure += validatePassword(password.getText(), passwordConfirm.getText());
|
||||
failure += validateAddress(address.getText());
|
||||
failure += validatePhone(homePhone.getText(), mobilePhone.getText());
|
||||
if (failure.equals("")){
|
||||
return true;
|
||||
}else{
|
||||
popUp(Alert.AlertType.WARNING, "Error!", "Your details are not valid for the following reasons.", failure);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public void uploadPhoto(){
|
||||
if (validate()){
|
||||
try {
|
||||
UploadPhotoController c = (UploadPhotoController) changeScene(SceneCode.ADD_PHOTO);
|
||||
c.setUserInformation(Integer.parseInt(username.getText()), email.getText(), password.getText(), address.getText(),
|
||||
homePhone.getText(), mobilePhone.getText(), accountType.getValue());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initialize(URL location, ResourceBundle resources) {
|
||||
ObservableList<String> accountTypes = FXCollections.observableArrayList();
|
||||
accountTypes.addAll(User.AccountType.DRIVER.name, User.AccountType.PASSENGER.name);
|
||||
accountType.setItems(accountTypes);
|
||||
accountType.getSelectionModel().select(0);
|
||||
|
||||
//default values just for testing
|
||||
username.setText("79984862");
|
||||
email.setText("[email protected]");
|
||||
password.setText("123456");
|
||||
passwordConfirm.setText("123456");
|
||||
address.setText("90 Stables Street");
|
||||
homePhone.setText("033466057");
|
||||
mobilePhone.setText("+642726242114");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
package controllers;
|
||||
|
||||
import javafx.embed.swing.SwingFXUtils;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.scene.image.Image;
|
||||
import javafx.scene.image.ImageView;
|
||||
import javafx.stage.FileChooser;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
import java.util.ResourceBundle;
|
||||
|
||||
/**
|
||||
* Created by Gondr on 1/06/2017.
|
||||
*/
|
||||
public class UploadPhotoController extends Controller {
|
||||
|
||||
private Image photoStored;
|
||||
private int studentNumber;
|
||||
private String email;
|
||||
private String password;
|
||||
private String address;
|
||||
private String homephone;
|
||||
private String mobilephone;
|
||||
private String accountType;
|
||||
@FXML
|
||||
private ImageView photo;
|
||||
|
||||
public void setUserInformation(int studentNumber, String email, String password, String address, String homephone, String mobilephone, String accountType){
|
||||
this.studentNumber = studentNumber;
|
||||
this.email = email;
|
||||
this.password = password;
|
||||
this.address = address;
|
||||
this.homephone = homephone;
|
||||
this.mobilephone = mobilephone;
|
||||
this.accountType = accountType;
|
||||
}
|
||||
|
||||
public void upload(){
|
||||
FileChooser fileChooser = new FileChooser();
|
||||
fileChooser.setTitle("Select a Picture for you Profile.");
|
||||
fileChooser.getExtensionFilters().add(new FileChooser.ExtensionFilter("Image Files", "*.png", "*.jpg", "*.gif"));
|
||||
File file = fileChooser.showOpenDialog(parent.getPrimaryStage());
|
||||
if (file != null){
|
||||
try {
|
||||
BufferedImage bufferedImage = ImageIO.read(file);
|
||||
photoStored = SwingFXUtils.toFXImage(bufferedImage, null);
|
||||
photo.setImage(photoStored);
|
||||
} catch (IOException e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void next(){
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initialize(URL location, ResourceBundle resources) {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package model;
|
||||
|
||||
import javafx.scene.image.Image;
|
||||
|
||||
import java.awt.image.BufferedImage;
|
||||
|
||||
/**
|
||||
* Created by Gondr on 1/06/2017.
|
||||
*/
|
||||
public class Driver extends User{
|
||||
|
||||
protected LicenseType licenseType;
|
||||
protected String licenseNumber;
|
||||
protected String licenseDateIssued;
|
||||
protected String licenseDateExpire;
|
||||
|
||||
public enum LicenseType{
|
||||
RESTRICTED("Restricted"), FULL("Full"), FULL2YEARS("Full for 2 Years");
|
||||
public String name;
|
||||
|
||||
LicenseType(String name){
|
||||
this.name = name;
|
||||
}
|
||||
}
|
||||
|
||||
public Driver(int studentNumber, String email, String password, String address, String homephone, String mobilephone,
|
||||
Image photo, LicenseType licenseType, String licenseNumber, String licenseDateIssued, String licenseDateExpire){
|
||||
super(studentNumber, email, password, address, homephone, mobilephone, photo);
|
||||
this.accountType = AccountType.DRIVER;
|
||||
this.licenseType = licenseType;
|
||||
this.licenseNumber = licenseNumber;
|
||||
this.licenseDateIssued = licenseDateIssued;
|
||||
this.licenseDateExpire = licenseDateExpire;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -15,7 +15,8 @@ public enum SceneCode {
|
||||
MAIN("main", false), BASE("base", false),
|
||||
//screens after login
|
||||
HOME("home"),ADD_RIDE("addride"),MY_RIDES("myrides"), ADD_STOPS("addstops"), MY_STOPS("mystops"), ADD_ROUTE("addroute"),
|
||||
MY_ROUTES("myroutes"), ADD_TRIP("addtrip"), MY_TRIPS("mytrips"), SHARED_RIDES("sharedtrips"), SEARCH_STOPS("searchstops");
|
||||
MY_ROUTES("myroutes"), ADD_TRIP("addtrip"), MY_TRIPS("mytrips"), SHARED_RIDES("sharedtrips"), SEARCH_STOPS("searchstops"),
|
||||
REGISTER("register", false), ADD_PHOTO("addphoto", false);
|
||||
|
||||
private String path;
|
||||
private boolean loadMenu;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package model;
|
||||
|
||||
/**
|
||||
* Created by fwy13 on 4/04/17.
|
||||
* All user preferences are to be serialised in this class
|
||||
*/
|
||||
public class Session {
|
||||
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
package model;
|
||||
|
||||
import javafx.scene.image.Image;
|
||||
|
||||
import java.awt.image.BufferedImage;
|
||||
|
||||
/**
|
||||
* Created by Gondr on 1/06/2017.
|
||||
*/
|
||||
public class User {
|
||||
protected int studentNumber;
|
||||
protected String email;
|
||||
protected String password;
|
||||
protected String address;
|
||||
protected String homephone;
|
||||
protected String mobilephone;
|
||||
protected AccountType accountType;
|
||||
protected Image photo;
|
||||
|
||||
public enum AccountType{
|
||||
PASSENGER("Passenger"), DRIVER("Driver");
|
||||
public String name;
|
||||
AccountType(String name){
|
||||
this.name = name;
|
||||
}
|
||||
}
|
||||
|
||||
public User(int studentNumber, String email, String password, String address, String homephone, String mobilephone,
|
||||
Image photo){
|
||||
this.studentNumber = studentNumber;
|
||||
this.email = email;
|
||||
this.password = password;
|
||||
this.address = address;
|
||||
this.homephone = homephone;
|
||||
this.mobilephone = mobilephone;
|
||||
this.photo = photo;
|
||||
this.accountType = AccountType.PASSENGER;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package utils;
|
||||
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* Created by Gondr on 1/06/2017.
|
||||
*/
|
||||
public class DataValidator {
|
||||
|
||||
public static boolean addressValidator(String address){
|
||||
Pattern addressPattern = Pattern.compile("[0-9]+[a-zA-Z]?(/[0-9]*[a-zA-Z]?)?([\\sa-zA-Z])+");
|
||||
return addressPattern.matcher(address).matches();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<?import javafx.scene.image.*?>
|
||||
<?import java.lang.*?>
|
||||
<?import javafx.scene.control.*?>
|
||||
<?import javafx.scene.layout.*?>
|
||||
<?import javafx.scene.text.*?>
|
||||
<?import javafx.scene.control.Label?>
|
||||
<?import javafx.scene.layout.AnchorPane?>
|
||||
<?import javafx.scene.layout.ColumnConstraints?>
|
||||
<?import javafx.scene.layout.GridPane?>
|
||||
<?import javafx.scene.layout.RowConstraints?>
|
||||
<?import javafx.scene.text.Font?>
|
||||
|
||||
<AnchorPane xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="controllers.UploadPhotoController">
|
||||
<children>
|
||||
<GridPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
|
||||
<columnConstraints>
|
||||
<ColumnConstraints hgrow="SOMETIMES" maxWidth="1.7976931348623157E308" minWidth="0.0" prefWidth="75.0" />
|
||||
<ColumnConstraints hgrow="SOMETIMES" />
|
||||
<ColumnConstraints hgrow="SOMETIMES" maxWidth="1.7976931348623157E308" minWidth="0.0" prefWidth="75.0" />
|
||||
</columnConstraints>
|
||||
<rowConstraints>
|
||||
<RowConstraints minHeight="10.0" vgrow="SOMETIMES" />
|
||||
<RowConstraints maxHeight="60.0" minHeight="10.0" prefHeight="60.0" vgrow="SOMETIMES" />
|
||||
<RowConstraints maxHeight="300.0" minHeight="10.0" prefHeight="300.0" vgrow="SOMETIMES" />
|
||||
<RowConstraints minHeight="10.0" vgrow="SOMETIMES" />
|
||||
</rowConstraints>
|
||||
<children>
|
||||
<Label text="Register for UC Ride Sharing System" GridPane.columnSpan="3" GridPane.halignment="CENTER" GridPane.rowIndex="1">
|
||||
<font>
|
||||
<Font size="22.0" />
|
||||
</font>
|
||||
</Label>
|
||||
<GridPane GridPane.columnIndex="1" GridPane.rowIndex="2">
|
||||
<columnConstraints>
|
||||
<ColumnConstraints hgrow="SOMETIMES" maxWidth="1.7976931348623157E308" minWidth="10.0" prefWidth="200.0" />
|
||||
<ColumnConstraints hgrow="SOMETIMES" maxWidth="1.7976931348623157E308" minWidth="10.0" prefWidth="200.0" />
|
||||
</columnConstraints>
|
||||
<rowConstraints>
|
||||
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
|
||||
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
|
||||
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
|
||||
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
|
||||
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
|
||||
</rowConstraints>
|
||||
<children>
|
||||
<Button mnemonicParsing="false" onAction="#upload" text="Upload a Photo" GridPane.halignment="CENTER" GridPane.rowIndex="4" GridPane.valignment="CENTER" />
|
||||
<AnchorPane GridPane.columnSpan="2" GridPane.rowSpan="4">
|
||||
<children>
|
||||
<ImageView fx:id="photo" fitHeight="270.0" fitWidth="360.0" pickOnBounds="true" preserveRatio="true" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="25.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0" GridPane.rowIndex="1" />
|
||||
</children>
|
||||
</AnchorPane>
|
||||
<Button mnemonicParsing="false" onAction="#next" text="Next" GridPane.columnIndex="1" GridPane.halignment="CENTER" GridPane.rowIndex="4" GridPane.valignment="CENTER" />
|
||||
</children>
|
||||
</GridPane>
|
||||
</children>
|
||||
</GridPane>
|
||||
</children>
|
||||
</AnchorPane>
|
||||
@@ -53,7 +53,8 @@
|
||||
<Label text="Password" GridPane.rowIndex="1" />
|
||||
<TextField fx:id="username" GridPane.columnIndex="1" />
|
||||
<PasswordField fx:id="password" GridPane.columnIndex="1" GridPane.rowIndex="1" />
|
||||
<Button mnemonicParsing="false" onAction="#login" text="Login" GridPane.columnIndex="2" GridPane.halignment="CENTER" GridPane.rowSpan="2" GridPane.valignment="CENTER" />
|
||||
<Button mnemonicParsing="false" onAction="#login" text="Login" GridPane.columnIndex="2" GridPane.halignment="CENTER" GridPane.valignment="CENTER" />
|
||||
<Button mnemonicParsing="false" onAction="#register" text="Register" GridPane.columnIndex="2" GridPane.halignment="CENTER" GridPane.rowIndex="1" GridPane.valignment="CENTER" />
|
||||
</children>
|
||||
</GridPane>
|
||||
<Label text="Note for now as long as the username is the same as the password the application will work." GridPane.columnSpan="2147483647" GridPane.halignment="CENTER" GridPane.rowIndex="4" />
|
||||
|
||||
@@ -0,0 +1,71 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<?import java.lang.*?>
|
||||
<?import javafx.scene.control.*?>
|
||||
<?import javafx.scene.layout.*?>
|
||||
<?import javafx.scene.text.*?>
|
||||
<?import javafx.scene.control.Label?>
|
||||
<?import javafx.scene.layout.AnchorPane?>
|
||||
<?import javafx.scene.layout.ColumnConstraints?>
|
||||
<?import javafx.scene.layout.GridPane?>
|
||||
<?import javafx.scene.layout.RowConstraints?>
|
||||
<?import javafx.scene.text.Font?>
|
||||
|
||||
<AnchorPane xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="controllers.RegisterController">
|
||||
<children>
|
||||
<GridPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
|
||||
<columnConstraints>
|
||||
<ColumnConstraints hgrow="SOMETIMES" maxWidth="1.7976931348623157E308" minWidth="0.0" prefWidth="75.0" />
|
||||
<ColumnConstraints hgrow="SOMETIMES" />
|
||||
<ColumnConstraints hgrow="SOMETIMES" maxWidth="1.7976931348623157E308" minWidth="0.0" prefWidth="75.0" />
|
||||
</columnConstraints>
|
||||
<rowConstraints>
|
||||
<RowConstraints minHeight="10.0" vgrow="SOMETIMES" />
|
||||
<RowConstraints maxHeight="60.0" minHeight="10.0" prefHeight="60.0" vgrow="SOMETIMES" />
|
||||
<RowConstraints maxHeight="300.0" minHeight="10.0" prefHeight="300.0" vgrow="SOMETIMES" />
|
||||
<RowConstraints minHeight="10.0" vgrow="SOMETIMES" />
|
||||
</rowConstraints>
|
||||
<children>
|
||||
<Label text="Register for UC Ride Sharing System" GridPane.columnSpan="3" GridPane.halignment="CENTER" GridPane.rowIndex="1">
|
||||
<font>
|
||||
<Font size="22.0" />
|
||||
</font>
|
||||
</Label>
|
||||
<GridPane GridPane.columnIndex="1" GridPane.rowIndex="2">
|
||||
<columnConstraints>
|
||||
<ColumnConstraints hgrow="SOMETIMES" maxWidth="120.0" minWidth="10.0" prefWidth="120.0" />
|
||||
<ColumnConstraints hgrow="SOMETIMES" maxWidth="1.7976931348623157E308" minWidth="10.0" />
|
||||
<ColumnConstraints hgrow="SOMETIMES" maxWidth="1.7976931348623157E308" minWidth="10.0" prefWidth="120.0" />
|
||||
<ColumnConstraints hgrow="SOMETIMES" maxWidth="1.7976931348623157E308" minWidth="10.0" />
|
||||
</columnConstraints>
|
||||
<rowConstraints>
|
||||
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
|
||||
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
|
||||
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
|
||||
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
|
||||
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
|
||||
</rowConstraints>
|
||||
<children>
|
||||
<Label text="Student Number" />
|
||||
<TextField fx:id="username" GridPane.columnIndex="1" />
|
||||
<Label text="School Email:" GridPane.rowIndex="1" />
|
||||
<TextField fx:id="email" GridPane.columnIndex="1" GridPane.rowIndex="1" />
|
||||
<Label text="Password:" GridPane.rowIndex="2" />
|
||||
<PasswordField fx:id="password" GridPane.columnIndex="1" GridPane.rowIndex="2" />
|
||||
<Label text="Confirm Password:" GridPane.rowIndex="3" />
|
||||
<PasswordField fx:id="passwordConfirm" GridPane.columnIndex="1" GridPane.rowIndex="3" />
|
||||
<Label text="Account Type:" GridPane.columnIndex="2" />
|
||||
<ComboBox fx:id="accountType" prefWidth="150.0" GridPane.columnIndex="3" />
|
||||
<Label text="Address:" GridPane.columnIndex="2" GridPane.rowIndex="1" />
|
||||
<TextField fx:id="address" GridPane.columnIndex="3" GridPane.rowIndex="1" />
|
||||
<Label text="Home Phone:" GridPane.columnIndex="2" GridPane.rowIndex="2" />
|
||||
<TextField fx:id="homePhone" GridPane.columnIndex="3" GridPane.rowIndex="2" />
|
||||
<Label text="Mobile Phone:" GridPane.columnIndex="2" GridPane.rowIndex="3" />
|
||||
<TextField fx:id="mobilePhone" GridPane.columnIndex="3" GridPane.rowIndex="3" />
|
||||
<Button mnemonicParsing="false" onAction="#uploadPhoto" text="Next" GridPane.columnIndex="3" GridPane.halignment="RIGHT" GridPane.rowIndex="4" />
|
||||
</children>
|
||||
</GridPane>
|
||||
</children>
|
||||
</GridPane>
|
||||
</children>
|
||||
</AnchorPane>
|
||||
@@ -0,0 +1,28 @@
|
||||
package utils;/**
|
||||
* Created by Gondr on 1/06/2017.
|
||||
*/
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
public class DataValidatorTest {
|
||||
|
||||
@Test
|
||||
public void testAddress(){
|
||||
assertTrue(DataValidator.addressValidator("80 Staveley Street"));
|
||||
assertTrue(!DataValidator.addressValidator("80 Staveley 5Street"));
|
||||
assertTrue(!DataValidator.addressValidator("80 ~Staveley Street,"));
|
||||
assertTrue(!DataValidator.addressValidator("Staveley Street 80"));
|
||||
assertTrue(DataValidator.addressValidator("80/1 Staveley Street"));
|
||||
assertTrue(DataValidator.addressValidator("80/1A Staveley Street"));
|
||||
assertTrue(DataValidator.addressValidator("80A/1A Staveley Street"));
|
||||
assertTrue(DataValidator.addressValidator("80A Staveley Street"));
|
||||
assertTrue(DataValidator.addressValidator("80a Staveley Street"));
|
||||
assertTrue(DataValidator.addressValidator("80d Staveley Street"));
|
||||
assertTrue(DataValidator.addressValidator("80D Staveley Street"));
|
||||
assertTrue(!DataValidator.addressValidator(""));
|
||||
assertTrue(!DataValidator.addressValidator("80"));
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user