refactored user to homeowner
This commit is contained in:
parent
fd2cf0fe0d
commit
fece5c7758
7 changed files with 25 additions and 25 deletions
|
@ -25,7 +25,7 @@
|
||||||
</value>
|
</value>
|
||||||
</option>
|
</option>
|
||||||
</component>
|
</component>
|
||||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" default="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
||||||
<output url="file://$PROJECT_DIR$/build/classes" />
|
<output url="file://$PROJECT_DIR$/build/classes" />
|
||||||
</component>
|
</component>
|
||||||
<component name="ProjectType">
|
<component name="ProjectType">
|
||||||
|
|
|
@ -155,7 +155,7 @@ public class DBHelper extends SQLiteOpenHelper {
|
||||||
.equals("ServiceProvider")){
|
.equals("ServiceProvider")){
|
||||||
usertype = new ServiceProvider(username, password, firstname, lastname);
|
usertype = new ServiceProvider(username, password, firstname, lastname);
|
||||||
} else {
|
} else {
|
||||||
usertype = new User(username, password, firstname, lastname);
|
usertype = new HomeOwner(username, password, firstname, lastname);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
usertype = null;
|
usertype = null;
|
||||||
|
|
|
@ -0,0 +1,12 @@
|
||||||
|
package com.uottawa.olympus.olympusservices;
|
||||||
|
|
||||||
|
|
||||||
|
public class HomeOwner extends UserType {
|
||||||
|
|
||||||
|
HomeOwner(String username, String password, String firstname, String lastname){
|
||||||
|
super(username, password, firstname, lastname);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getRole(){ return "HomeOwner"; }
|
||||||
|
|
||||||
|
}
|
|
@ -15,7 +15,7 @@ public class SignUp extends AppCompatActivity {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.activity_sign_up);
|
setContentView(R.layout.activity_sign_up);
|
||||||
MaterialSpinner spinner = findViewById(R.id.RoleInput);
|
MaterialSpinner spinner = findViewById(R.id.RoleInput);
|
||||||
spinner.setItems("User", "Service Provider");
|
spinner.setItems("HomeOwner", "Service Provider");
|
||||||
spinner.setOnItemSelectedListener(new MaterialSpinner.OnItemSelectedListener<String>() {
|
spinner.setOnItemSelectedListener(new MaterialSpinner.OnItemSelectedListener<String>() {
|
||||||
|
|
||||||
@Override public void onItemSelected(MaterialSpinner view, int position, long id, String item) {
|
@Override public void onItemSelected(MaterialSpinner view, int position, long id, String item) {
|
||||||
|
@ -36,14 +36,14 @@ public class SignUp extends AppCompatActivity {
|
||||||
if(username.length()>=5 && password.length()>5 && firstname.length()>0 && lastname.length()>0 && username.matches("[a-zA-Z0-9]*") && password.matches("[a-zA-Z0-9]*")
|
if(username.length()>=5 && password.length()>5 && firstname.length()>0 && lastname.length()>0 && username.matches("[a-zA-Z0-9]*") && password.matches("[a-zA-Z0-9]*")
|
||||||
&& firstname.matches("[a-zA-Z]*") && lastname.matches("[a-zA-Z]*")){
|
&& firstname.matches("[a-zA-Z]*") && lastname.matches("[a-zA-Z]*")){
|
||||||
switch(spinner.getText().toString()){
|
switch(spinner.getText().toString()){
|
||||||
case "User":
|
case "HomeOwner":
|
||||||
newUser = new User(username,password,firstname,lastname);
|
newUser = new HomeOwner(username,password,firstname,lastname);
|
||||||
break;
|
break;
|
||||||
case "Service Provider":
|
case "Service Provider":
|
||||||
newUser = new ServiceProvider(username,password,firstname,lastname);
|
newUser = new ServiceProvider(username,password,firstname,lastname);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
newUser = new User(username,password,firstname,lastname); //if nothing is enter then defaults to user role.
|
newUser = new HomeOwner(username,password,firstname,lastname); //if nothing is enter then defaults to user role.
|
||||||
break;
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,12 +0,0 @@
|
||||||
package com.uottawa.olympus.olympusservices;
|
|
||||||
|
|
||||||
|
|
||||||
public class User extends UserType {
|
|
||||||
|
|
||||||
User(String username, String password, String firstname, String lastname){
|
|
||||||
super(username, password, firstname, lastname);
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getRole(){ return "User"; }
|
|
||||||
|
|
||||||
}
|
|
|
@ -19,7 +19,7 @@ public class UsersList extends AppCompatActivity {
|
||||||
List<String[]> users = dbHelper.getAllUsers();
|
List<String[]> users = dbHelper.getAllUsers();
|
||||||
String[] usernames = new String[(users.size()+1)*2];
|
String[] usernames = new String[(users.size()+1)*2];
|
||||||
usernames[0] = "Username";
|
usernames[0] = "Username";
|
||||||
usernames[1] = "User Type";
|
usernames[1] = "HomeOwner Type";
|
||||||
Iterator iter = users.iterator();
|
Iterator iter = users.iterator();
|
||||||
for (int i=0; i<users.size();i++){
|
for (int i=0; i<users.size();i++){
|
||||||
String[] current = (String[])iter.next();
|
String[] current = (String[])iter.next();
|
||||||
|
|
|
@ -37,11 +37,11 @@ public class DBIntegrationTest {
|
||||||
boolean deleted, addedOne, addedTwo;
|
boolean deleted, addedOne, addedTwo;
|
||||||
|
|
||||||
|
|
||||||
originalUser = new User("mgarzon", "soccer", "Miguel", "Garzon");
|
originalUser = new HomeOwner("mgarzon", "soccer", "Miguel", "Garzon");
|
||||||
addedOne = dbHelper.addUser(originalUser);
|
addedOne = dbHelper.addUser(originalUser);
|
||||||
dbUser = dbHelper.findUserByUsername("mgarzon");
|
dbUser = dbHelper.findUserByUsername("mgarzon");
|
||||||
|
|
||||||
assertEquals("User", dbUser.getClass().getSimpleName());
|
assertEquals("HomeOwner", dbUser.getClass().getSimpleName());
|
||||||
assertEquals("mgarzon", dbUser.getUsername());
|
assertEquals("mgarzon", dbUser.getUsername());
|
||||||
assertEquals("soccer", dbUser.getPassword());
|
assertEquals("soccer", dbUser.getPassword());
|
||||||
assertEquals("Miguel", dbUser.getFirstname());
|
assertEquals("Miguel", dbUser.getFirstname());
|
||||||
|
@ -75,9 +75,9 @@ public class DBIntegrationTest {
|
||||||
public void testAddDuplicateUsers(){
|
public void testAddDuplicateUsers(){
|
||||||
boolean added;
|
boolean added;
|
||||||
|
|
||||||
added = dbHelper.addUser(new User("jbO4aBF4dC", "soccer", "Miguel", "Garzon"));
|
added = dbHelper.addUser(new HomeOwner("jbO4aBF4dC", "soccer", "Miguel", "Garzon"));
|
||||||
assertTrue(added);
|
assertTrue(added);
|
||||||
added = dbHelper.addUser(new User("jbO4aBF4dC", "seg2105", "Miguel", "Garzon"));
|
added = dbHelper.addUser(new HomeOwner("jbO4aBF4dC", "seg2105", "Miguel", "Garzon"));
|
||||||
assertTrue(!added);
|
assertTrue(!added);
|
||||||
added = dbHelper.addUser(new ServiceProvider("jbO4aBF4dC", "seg2105", "Juan", "Guzman"));
|
added = dbHelper.addUser(new ServiceProvider("jbO4aBF4dC", "seg2105", "Juan", "Guzman"));
|
||||||
assertTrue(!added);
|
assertTrue(!added);
|
||||||
|
@ -90,7 +90,7 @@ public class DBIntegrationTest {
|
||||||
boolean updated;
|
boolean updated;
|
||||||
UserType dbUser;
|
UserType dbUser;
|
||||||
|
|
||||||
dbHelper.addUser(new User("jbO4aBF4dC", "soccer", "Miguel", "Garzon"));
|
dbHelper.addUser(new HomeOwner("jbO4aBF4dC", "soccer", "Miguel", "Garzon"));
|
||||||
updated = dbHelper.updateUserInfo("jbO4aBF4dC", "soccer", "Juan", "Guzman");
|
updated = dbHelper.updateUserInfo("jbO4aBF4dC", "soccer", "Juan", "Guzman");
|
||||||
assertTrue(updated);
|
assertTrue(updated);
|
||||||
|
|
||||||
|
@ -110,7 +110,7 @@ public class DBIntegrationTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetAllUsers(){
|
public void testGetAllUsers(){
|
||||||
dbHelper.addUser(new User("jbO4aBF4dC", "soccer", "Miguel", "Garzon"));
|
dbHelper.addUser(new HomeOwner("jbO4aBF4dC", "soccer", "Miguel", "Garzon"));
|
||||||
|
|
||||||
List<String[]> allUsers = dbHelper.getAllUsers();
|
List<String[]> allUsers = dbHelper.getAllUsers();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue