diff --git a/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/SignUpPart2.java b/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/SignUpPart2.java index 4e01909..9d8b4ba 100644 --- a/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/SignUpPart2.java +++ b/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/SignUpPart2.java @@ -6,6 +6,7 @@ import android.os.Bundle; import android.view.View; import android.widget.CheckBox; import android.widget.EditText; +import android.widget.Toast; public class SignUpPart2 extends AppCompatActivity { private String username; @@ -32,8 +33,22 @@ public class SignUpPart2 extends AppCompatActivity { String address = ((EditText) findViewById(R.id.AddressInput)).getText().toString(); boolean licensed = ((CheckBox) findViewById(R.id.LicensedInput)).isChecked(); - ServiceProvider serviceProvider = new ServiceProvider(username, password, firstname, lastname, - address, phonenumber, companyname, licensed); + if(companyname.length()>0 && address.length()>0 && phonenumber.length()>0 + && companyname.matches("[a-zA-Z0-9]*") && address.matches("[a-zA-Z]*") + && phonenumber.matches("^(\\+\\d{1,2}\\s)?\\(?\\d{3}\\)?[\\s.-]?\\d{3}[\\s.-]?\\d{4}$")) { + + ServiceProvider serviceProvider = new ServiceProvider(username, password, firstname, lastname, + address, phonenumber, companyname, licensed); + if(dbHelper.addUser(serviceProvider)){ + startActivity(intent); + finish(); + }else{ + Toast.makeText(this,"Could not create account",Toast.LENGTH_LONG).show(); + } + } + else{ + Toast.makeText(this, "Fields cannot be empty and must be formatted correctly", Toast.LENGTH_LONG).show(); + } } } diff --git a/OlympusServices/app/src/test/java/com/uottawa/olympus/olympusservices/ServiceProviderTest.java b/OlympusServices/app/src/test/java/com/uottawa/olympus/olympusservices/ServiceProviderTest.java index ab776d1..7f5b5e8 100644 --- a/OlympusServices/app/src/test/java/com/uottawa/olympus/olympusservices/ServiceProviderTest.java +++ b/OlympusServices/app/src/test/java/com/uottawa/olympus/olympusservices/ServiceProviderTest.java @@ -8,7 +8,8 @@ import static org.junit.Assert.*; public class ServiceProviderTest { - ServiceProvider serviceprovider = new ServiceProvider("John123", "1234567890", "John", "Doe"); + ServiceProvider serviceprovider = new ServiceProvider("John123", "1234567890", "John", "Doe", + "testaddress", "8888888888", "companydotcom", true); /** * Initiates an ServiceProvider account and tests if the random strings match to the required inputs.