Added description field to database and fixed some tests with old ServiceProvider constructor
This commit is contained in:
parent
66d33d4cc4
commit
d7cf9ba311
6 changed files with 50 additions and 41 deletions
|
@ -23,7 +23,7 @@ import java.util.List;
|
||||||
public class DBHelper extends SQLiteOpenHelper {
|
public class DBHelper extends SQLiteOpenHelper {
|
||||||
|
|
||||||
//version of db used for update method
|
//version of db used for update method
|
||||||
private static final int DB_VERSION = 3;
|
private static final int DB_VERSION = 4;
|
||||||
//name of db in app data
|
//name of db in app data
|
||||||
private static final String DB_NAME = "UsersDB.db";
|
private static final String DB_NAME = "UsersDB.db";
|
||||||
|
|
||||||
|
@ -45,6 +45,8 @@ public class DBHelper extends SQLiteOpenHelper {
|
||||||
private static final String COLUMN_PHONE = "phone";
|
private static final String COLUMN_PHONE = "phone";
|
||||||
private static final String COLUMN_COMPANY = "company";
|
private static final String COLUMN_COMPANY = "company";
|
||||||
private static final String COLUMN_LICENSED = "licensed";
|
private static final String COLUMN_LICENSED = "licensed";
|
||||||
|
private static final String COLUMN_DESCRIPTION = "description";
|
||||||
|
private static final String COLUMN_SALT = "salt";
|
||||||
|
|
||||||
//name of table containing services and rates
|
//name of table containing services and rates
|
||||||
private static final String TABLE_SERVICES = "services";
|
private static final String TABLE_SERVICES = "services";
|
||||||
|
@ -108,7 +110,9 @@ public class DBHelper extends SQLiteOpenHelper {
|
||||||
+ COLUMN_ADDRESS + " TEXT, "
|
+ COLUMN_ADDRESS + " TEXT, "
|
||||||
+ COLUMN_PHONE + " TEXT, "
|
+ COLUMN_PHONE + " TEXT, "
|
||||||
+ COLUMN_COMPANY + " TEXT, "
|
+ COLUMN_COMPANY + " TEXT, "
|
||||||
+ COLUMN_LICENSED + " TEXT "
|
+ COLUMN_LICENSED + " TEXT, "
|
||||||
|
+ COLUMN_DESCRIPTION + " TEXT, "
|
||||||
|
+ COLUMN_SALT + " TEXT "
|
||||||
+ ")";
|
+ ")";
|
||||||
db.execSQL(CREATE_LOGIN_TABLE);
|
db.execSQL(CREATE_LOGIN_TABLE);
|
||||||
|
|
||||||
|
@ -197,6 +201,10 @@ public class DBHelper extends SQLiteOpenHelper {
|
||||||
db.execSQL("ALTER TABLE " + TABLE_LOGIN + " ADD COLUMN " + COLUMN_PHONE + " TEXT");
|
db.execSQL("ALTER TABLE " + TABLE_LOGIN + " ADD COLUMN " + COLUMN_PHONE + " TEXT");
|
||||||
db.execSQL("ALTER TABLE " + TABLE_LOGIN + " ADD COLUMN " + COLUMN_COMPANY + " TEXT");
|
db.execSQL("ALTER TABLE " + TABLE_LOGIN + " ADD COLUMN " + COLUMN_COMPANY + " TEXT");
|
||||||
db.execSQL("ALTER TABLE " + TABLE_LOGIN + " ADD COLUMN " + COLUMN_LICENSED + " TEXT");
|
db.execSQL("ALTER TABLE " + TABLE_LOGIN + " ADD COLUMN " + COLUMN_LICENSED + " TEXT");
|
||||||
|
case 3:
|
||||||
|
db.execSQL("ALTER TABLE " + TABLE_LOGIN + " ADD COLUMN " + COLUMN_DESCRIPTION + " TEXT");
|
||||||
|
db.execSQL("ALTER TABLE " + TABLE_LOGIN + " ADD COLUMN " + COLUMN_SALT + " TEXT");
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -259,6 +267,11 @@ public class DBHelper extends SQLiteOpenHelper {
|
||||||
String licensed = String.valueOf(serviceProvider.isLicensed());
|
String licensed = String.valueOf(serviceProvider.isLicensed());
|
||||||
values.put(COLUMN_LICENSED, licensed);
|
values.put(COLUMN_LICENSED, licensed);
|
||||||
|
|
||||||
|
String description = serviceProvider.getDescription();
|
||||||
|
if (description != null){
|
||||||
|
values.put(COLUMN_DESCRIPTION, description);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
writeDB.insert(TABLE_LOGIN, null, values);
|
writeDB.insert(TABLE_LOGIN, null, values);
|
||||||
|
@ -324,14 +337,14 @@ public class DBHelper extends SQLiteOpenHelper {
|
||||||
*/
|
*/
|
||||||
public boolean updateUserInfo(String username, String password, String firstname, String lastname){
|
public boolean updateUserInfo(String username, String password, String firstname, String lastname){
|
||||||
return updateUserInfo(username, password, firstname, lastname,
|
return updateUserInfo(username, password, firstname, lastname,
|
||||||
null, null, null, null);
|
null, null, null, null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public boolean updateUserInfo(String username, String password, String firstname, String lastname,
|
public boolean updateUserInfo(String username, String password, String firstname, String lastname,
|
||||||
String address, String phonenumber, String companyname, Boolean licensed){
|
String address, String phonenumber, String companyname, Boolean licensed,
|
||||||
|
String description){
|
||||||
ContentValues values = new ContentValues();
|
ContentValues values = new ContentValues();
|
||||||
if (password != null && !password.equals("")) values.put(COLUMN_PASSWORD, password);
|
if (password != null && !password.equals("")) values.put(COLUMN_PASSWORD, password);
|
||||||
if (firstname != null && !firstname.equals("")) values.put(COLUMN_FIRSTNAME, firstname);
|
if (firstname != null && !firstname.equals("")) values.put(COLUMN_FIRSTNAME, firstname);
|
||||||
|
@ -339,7 +352,8 @@ public class DBHelper extends SQLiteOpenHelper {
|
||||||
if (address != null && !address.equals(""))values.put(COLUMN_ADDRESS, address);
|
if (address != null && !address.equals(""))values.put(COLUMN_ADDRESS, address);
|
||||||
if (phonenumber != null && !phonenumber.equals(""))values.put(COLUMN_PHONE, phonenumber);
|
if (phonenumber != null && !phonenumber.equals(""))values.put(COLUMN_PHONE, phonenumber);
|
||||||
if (companyname != null && !companyname.equals(""))values.put(COLUMN_COMPANY, companyname);
|
if (companyname != null && !companyname.equals(""))values.put(COLUMN_COMPANY, companyname);
|
||||||
if (licensed != null)values.put(COLUMN_LICENSED, String.valueOf(licensed));
|
if (licensed != null) values.put(COLUMN_LICENSED, String.valueOf(licensed));
|
||||||
|
if (description != null && !description.equals(""))values.put(COLUMN_DESCRIPTION, description);
|
||||||
|
|
||||||
|
|
||||||
return writeDB.update(TABLE_LOGIN, values, COLUMN_USERNAME+" = ?",
|
return writeDB.update(TABLE_LOGIN, values, COLUMN_USERNAME+" = ?",
|
||||||
|
@ -358,7 +372,7 @@ public class DBHelper extends SQLiteOpenHelper {
|
||||||
|
|
||||||
Cursor cursor = readDB.rawQuery("SELECT * FROM " + TABLE_LOGIN
|
Cursor cursor = readDB.rawQuery("SELECT * FROM " + TABLE_LOGIN
|
||||||
+ " WHERE " + COLUMN_USERNAME + " = ?",
|
+ " WHERE " + COLUMN_USERNAME + " = ?",
|
||||||
new String[]{username});
|
new String[]{username});
|
||||||
|
|
||||||
if (!cursor.moveToFirst()) return false;
|
if (!cursor.moveToFirst()) return false;
|
||||||
|
|
||||||
|
@ -589,7 +603,7 @@ public class DBHelper extends SQLiteOpenHelper {
|
||||||
return writeDB.delete(TABLE_SERVICEPROVIDERS,
|
return writeDB.delete(TABLE_SERVICEPROVIDERS,
|
||||||
COLUMN_SERVICEPROVIDERNAME + " = ? AND "
|
COLUMN_SERVICEPROVIDERNAME + " = ? AND "
|
||||||
+ COLUMN_SERVICEPROVIDERSERVICE + " = ?",
|
+ COLUMN_SERVICEPROVIDERSERVICE + " = ?",
|
||||||
new String[]{serviceProviderUsername, serviceName}) > 0;
|
new String[]{serviceProviderUsername, serviceName}) > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<String[]> getAllServicesProvidedByUser(ServiceProvider serviceProvider){
|
public List<String[]> getAllServicesProvidedByUser(ServiceProvider serviceProvider){
|
||||||
|
@ -622,9 +636,9 @@ public class DBHelper extends SQLiteOpenHelper {
|
||||||
|
|
||||||
serviceName = serviceName.toLowerCase().trim();
|
serviceName = serviceName.toLowerCase().trim();
|
||||||
return getAll("SELECT " + COLUMN_SERVICEPROVIDERNAME
|
return getAll("SELECT " + COLUMN_SERVICEPROVIDERNAME
|
||||||
+ " FROM " + TABLE_SERVICEPROVIDERS
|
+ " FROM " + TABLE_SERVICEPROVIDERS
|
||||||
+ " WHERE " + COLUMN_SERVICEPROVIDERSERVICE + " = '"
|
+ " WHERE " + COLUMN_SERVICEPROVIDERSERVICE + " = '"
|
||||||
+ serviceName + "'");
|
+ serviceName + "'");
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean updateAvailability(ServiceProvider serviceProvider){
|
public boolean updateAvailability(ServiceProvider serviceProvider){
|
||||||
|
@ -635,7 +649,7 @@ public class DBHelper extends SQLiteOpenHelper {
|
||||||
|
|
||||||
Cursor cursor = readDB.rawQuery("SELECT * FROM " + TABLE_AVAILABILITY
|
Cursor cursor = readDB.rawQuery("SELECT * FROM " + TABLE_AVAILABILITY
|
||||||
+ " WHERE " + COLUMN_AVAILABILITYNAME + " = ?",
|
+ " WHERE " + COLUMN_AVAILABILITYNAME + " = ?",
|
||||||
new String[]{serviceProvider.getUsername()});
|
new String[]{serviceProvider.getUsername()});
|
||||||
|
|
||||||
ContentValues contentValues = new ContentValues();
|
ContentValues contentValues = new ContentValues();
|
||||||
addAvailabilityToContentValues(contentValues, COLUMN_MONSTART, COLUMN_MONEND, availabilities[0]);
|
addAvailabilityToContentValues(contentValues, COLUMN_MONSTART, COLUMN_MONEND, availabilities[0]);
|
||||||
|
@ -682,14 +696,14 @@ public class DBHelper extends SQLiteOpenHelper {
|
||||||
public int[][] getAvailabilities(ServiceProvider serviceProvider){
|
public int[][] getAvailabilities(ServiceProvider serviceProvider){
|
||||||
if (serviceProvider==null) return new int[7][4];
|
if (serviceProvider==null) return new int[7][4];
|
||||||
Cursor cursor = readDB.rawQuery("SELECT * FROM " + TABLE_AVAILABILITY
|
Cursor cursor = readDB.rawQuery("SELECT * FROM " + TABLE_AVAILABILITY
|
||||||
+ " WHERE " + COLUMN_AVAILABILITYNAME + " = ?",
|
+ " WHERE " + COLUMN_AVAILABILITYNAME + " = ?",
|
||||||
new String[]{serviceProvider.getUsername()});
|
new String[]{serviceProvider.getUsername()});
|
||||||
if (cursor.moveToFirst()){
|
if (cursor.moveToFirst()){
|
||||||
for (int i = 0; i < 7; i++) {
|
for (int i = 0; i < 7; i++) {
|
||||||
int start = cursor.getInt(i*2+1);
|
int start = cursor.getInt(i*2+1);
|
||||||
int end = cursor.getInt(i*2+2);
|
int end = cursor.getInt(i*2+2);
|
||||||
serviceProvider.setAvailabilities(i, start/60, start%60,
|
serviceProvider.setAvailabilities(i, start/60, start%60,
|
||||||
end/60, end%60);
|
end/60, end%60);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return new int[7][4];
|
return new int[7][4];
|
||||||
|
@ -703,7 +717,7 @@ public class DBHelper extends SQLiteOpenHelper {
|
||||||
|
|
||||||
Cursor cursor = readDB.rawQuery("SELECT * FROM " + TABLE_AVAILABILITY
|
Cursor cursor = readDB.rawQuery("SELECT * FROM " + TABLE_AVAILABILITY
|
||||||
+ " WHERE " + COLUMN_AVAILABILITYNAME + " = ?",
|
+ " WHERE " + COLUMN_AVAILABILITYNAME + " = ?",
|
||||||
new String[]{serviceProviderName});
|
new String[]{serviceProviderName});
|
||||||
if (cursor.moveToFirst()){
|
if (cursor.moveToFirst()){
|
||||||
for (int i = 0; i < 7; i++) {
|
for (int i = 0; i < 7; i++) {
|
||||||
int start = cursor.getInt(i*2+1);
|
int start = cursor.getInt(i*2+1);
|
||||||
|
|
|
@ -79,7 +79,7 @@ public class EditProfile extends AppCompatActivity {
|
||||||
&& address.getText().toString().replaceAll("\\s+","").length()>0) {
|
&& address.getText().toString().replaceAll("\\s+","").length()>0) {
|
||||||
|
|
||||||
if(dbHelper.updateUserInfo(username, password.getText().toString(), firstname.getText().toString(), lastname.getText().toString(),
|
if(dbHelper.updateUserInfo(username, password.getText().toString(), firstname.getText().toString(), lastname.getText().toString(),
|
||||||
address.getText().toString(), phonenumber.getText().toString(), companyname.getText().toString(), licensed.isChecked())){
|
address.getText().toString(), phonenumber.getText().toString(), companyname.getText().toString(), licensed.isChecked(), description.getText().toString())){
|
||||||
//add comment method here
|
//add comment method here
|
||||||
Toast.makeText(this, "Profile has been updated", Toast.LENGTH_LONG).show();
|
Toast.makeText(this, "Profile has been updated", Toast.LENGTH_LONG).show();
|
||||||
}
|
}
|
||||||
|
|
|
@ -142,7 +142,6 @@ public class ServiceProvider extends UserType {
|
||||||
this.licensed = licensed;
|
this.licensed = licensed;
|
||||||
}
|
}
|
||||||
|
|
||||||
<<<<<<< HEAD
|
|
||||||
public String getDescription() {
|
public String getDescription() {
|
||||||
return description;
|
return description;
|
||||||
}
|
}
|
||||||
|
@ -150,10 +149,5 @@ public class ServiceProvider extends UserType {
|
||||||
public void setDescription(String phonenumber) {
|
public void setDescription(String phonenumber) {
|
||||||
this.description = description;
|
this.description = description;
|
||||||
}
|
}
|
||||||
=======
|
|
||||||
|
|
||||||
public String getDescription() {return description; }
|
|
||||||
|
|
||||||
public void setDescription(String description) { this.description = description; }
|
|
||||||
>>>>>>> 587e99040b46bc068178844c11165b0730c21628
|
|
||||||
}
|
}
|
|
@ -52,7 +52,7 @@ public class DBIntegrationTest {
|
||||||
|
|
||||||
//add a ServiceProvider to database
|
//add a ServiceProvider to database
|
||||||
originalUser = new ServiceProvider("jbO4aBF4dC", "seg2105", "Juan", "Guzman",
|
originalUser = new ServiceProvider("jbO4aBF4dC", "seg2105", "Juan", "Guzman",
|
||||||
"testaddress", "8888888888", "companydotcom", true);
|
"testaddress", "8888888888", "companydotcom", true, null);
|
||||||
addedTwo = dbHelper.addUser(originalUser);
|
addedTwo = dbHelper.addUser(originalUser);
|
||||||
|
|
||||||
//test retrieving ServiceProvider, and confirm that user info is the same as that in object passed
|
//test retrieving ServiceProvider, and confirm that user info is the same as that in object passed
|
||||||
|
@ -79,7 +79,7 @@ public class DBIntegrationTest {
|
||||||
public void testAddAndGetServiceProvider(){
|
public void testAddAndGetServiceProvider(){
|
||||||
//ServiceProviders have extra fields that can be added to the DB
|
//ServiceProviders have extra fields that can be added to the DB
|
||||||
ServiceProvider serviceProvider = new ServiceProvider("7MuF1c59XP", null, null, null,
|
ServiceProvider serviceProvider = new ServiceProvider("7MuF1c59XP", null, null, null,
|
||||||
"testaddress", "8888888888", "companydotcom", true);
|
"testaddress", "8888888888", "companydotcom", true, "Not a penguin");
|
||||||
dbHelper.addUser(serviceProvider);
|
dbHelper.addUser(serviceProvider);
|
||||||
|
|
||||||
//retrieve ServiceProvider and test the newly added fields
|
//retrieve ServiceProvider and test the newly added fields
|
||||||
|
@ -93,6 +93,7 @@ public class DBIntegrationTest {
|
||||||
assertEquals(serviceProvider.getPhonenumber(), dbServiceProvider.getPhonenumber());
|
assertEquals(serviceProvider.getPhonenumber(), dbServiceProvider.getPhonenumber());
|
||||||
assertEquals(serviceProvider.getCompanyname(), dbServiceProvider.getCompanyname());
|
assertEquals(serviceProvider.getCompanyname(), dbServiceProvider.getCompanyname());
|
||||||
assertEquals(serviceProvider.isLicensed(), dbServiceProvider.isLicensed());
|
assertEquals(serviceProvider.isLicensed(), dbServiceProvider.isLicensed());
|
||||||
|
assertEquals(serviceProvider.getDescription(), dbServiceProvider.getDescription());
|
||||||
|
|
||||||
dbHelper.deleteUser("7MuF1c59XP");
|
dbHelper.deleteUser("7MuF1c59XP");
|
||||||
}
|
}
|
||||||
|
@ -101,7 +102,7 @@ public class DBIntegrationTest {
|
||||||
public void testDeleteServiceProvider(){
|
public void testDeleteServiceProvider(){
|
||||||
//make sure all the rows related to ServiceProvider in all tables are deleted
|
//make sure all the rows related to ServiceProvider in all tables are deleted
|
||||||
ServiceProvider serviceProvider = new ServiceProvider("jbO4aBF4dC", null, null, null,
|
ServiceProvider serviceProvider = new ServiceProvider("jbO4aBF4dC", null, null, null,
|
||||||
"testaddress", "8888888888", "companydotcom", true);
|
"testaddress", "8888888888", "companydotcom", true, null);
|
||||||
dbHelper.addUser(serviceProvider);
|
dbHelper.addUser(serviceProvider);
|
||||||
|
|
||||||
Service service1 = new Service("Hitman", 12358);
|
Service service1 = new Service("Hitman", 12358);
|
||||||
|
@ -142,7 +143,7 @@ public class DBIntegrationTest {
|
||||||
added = dbHelper.addUser(new HomeOwner("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",
|
||||||
"testaddress", "8888888888", "companydotcom", true));
|
"testaddress", "8888888888", "companydotcom", true, null));
|
||||||
assertTrue(!added);
|
assertTrue(!added);
|
||||||
|
|
||||||
dbHelper.deleteUser("jbO4aBF4dC");
|
dbHelper.deleteUser("jbO4aBF4dC");
|
||||||
|
@ -278,7 +279,7 @@ public class DBIntegrationTest {
|
||||||
@Test
|
@Test
|
||||||
public void testAddAndDeleteServiceProvidedByUser(){
|
public void testAddAndDeleteServiceProvidedByUser(){
|
||||||
dbHelper.addUser(new ServiceProvider("jbO4aBF4dC", null, null, null,
|
dbHelper.addUser(new ServiceProvider("jbO4aBF4dC", null, null, null,
|
||||||
"testaddress", "8888888888", "companydotcom", true));
|
"testaddress", "8888888888", "companydotcom", true, null));
|
||||||
dbHelper.addService(new Service("Hitman", 12358));
|
dbHelper.addService(new Service("Hitman", 12358));
|
||||||
boolean added = dbHelper.addServiceProvidedByUser("jbO4aBF4dC", "hitman");
|
boolean added = dbHelper.addServiceProvidedByUser("jbO4aBF4dC", "hitman");
|
||||||
assertTrue(added);
|
assertTrue(added);
|
||||||
|
@ -291,7 +292,7 @@ public class DBIntegrationTest {
|
||||||
@Test
|
@Test
|
||||||
public void testGetAllServicesProvidedByUserAndDeleteService(){
|
public void testGetAllServicesProvidedByUserAndDeleteService(){
|
||||||
ServiceProvider serviceProvider = new ServiceProvider("jbO4aBF4dC", null, null, null,
|
ServiceProvider serviceProvider = new ServiceProvider("jbO4aBF4dC", null, null, null,
|
||||||
"testaddress", "8888888888", "companydotcom", true);
|
"testaddress", "8888888888", "companydotcom", true, null);
|
||||||
dbHelper.addUser(serviceProvider);
|
dbHelper.addUser(serviceProvider);
|
||||||
|
|
||||||
Service service1 = new Service("Hitman", 12358);
|
Service service1 = new Service("Hitman", 12358);
|
||||||
|
@ -324,9 +325,9 @@ public class DBIntegrationTest {
|
||||||
public void testGetAllProvidersByService(){
|
public void testGetAllProvidersByService(){
|
||||||
dbHelper.addService(new Service("Exterminating flatworms", 392.457));
|
dbHelper.addService(new Service("Exterminating flatworms", 392.457));
|
||||||
dbHelper.addUser(new ServiceProvider("jbO4aBF4dC", null, null, null,
|
dbHelper.addUser(new ServiceProvider("jbO4aBF4dC", null, null, null,
|
||||||
"testaddress", "8888888888", "companydotcom", true));
|
"testaddress", "8888888888", "companydotcom", true, null));
|
||||||
dbHelper.addUser(new ServiceProvider("7MuF1c59XP", null, null, null,
|
dbHelper.addUser(new ServiceProvider("7MuF1c59XP", null, null, null,
|
||||||
"testaddress", "8888888888", "companydotcom", true));
|
"testaddress", "8888888888", "companydotcom", true, null));
|
||||||
|
|
||||||
dbHelper.addServiceProvidedByUser("jbO4aBF4dC", "exterminating flatworms");
|
dbHelper.addServiceProvidedByUser("jbO4aBF4dC", "exterminating flatworms");
|
||||||
dbHelper.addServiceProvidedByUser("7MuF1c59XP", "exterminating flatworms");
|
dbHelper.addServiceProvidedByUser("7MuF1c59XP", "exterminating flatworms");
|
||||||
|
@ -346,7 +347,7 @@ public class DBIntegrationTest {
|
||||||
@Test
|
@Test
|
||||||
public void testDeleteServiceProvidedByUser(){
|
public void testDeleteServiceProvidedByUser(){
|
||||||
ServiceProvider serviceProvider = new ServiceProvider("jbO4aBF4dC", null, null, null,
|
ServiceProvider serviceProvider = new ServiceProvider("jbO4aBF4dC", null, null, null,
|
||||||
"testaddress", "8888888888", "companydotcom", true);
|
"testaddress", "8888888888", "companydotcom", true, null);
|
||||||
dbHelper.addUser(serviceProvider);
|
dbHelper.addUser(serviceProvider);
|
||||||
|
|
||||||
Service service1 = new Service("Hitman", 12358);
|
Service service1 = new Service("Hitman", 12358);
|
||||||
|
@ -376,7 +377,7 @@ public class DBIntegrationTest {
|
||||||
@Test
|
@Test
|
||||||
public void testUpdateAndGetAvailability(){
|
public void testUpdateAndGetAvailability(){
|
||||||
ServiceProvider serviceProvider = new ServiceProvider("jbO4aBF4dC", null, null, null,
|
ServiceProvider serviceProvider = new ServiceProvider("jbO4aBF4dC", null, null, null,
|
||||||
"testaddress", "8888888888", "companydotcom", true);
|
"testaddress", "8888888888", "companydotcom", true, null);
|
||||||
serviceProvider.setAvailabilities(0, 4, 18, 19, 30);
|
serviceProvider.setAvailabilities(0, 4, 18, 19, 30);
|
||||||
serviceProvider.setAvailabilities(1, 5, 20, 21, 11);
|
serviceProvider.setAvailabilities(1, 5, 20, 21, 11);
|
||||||
serviceProvider.setAvailabilities(3, 7, 12, 15, 14);
|
serviceProvider.setAvailabilities(3, 7, 12, 15, 14);
|
||||||
|
@ -384,7 +385,7 @@ public class DBIntegrationTest {
|
||||||
|
|
||||||
//TODO:Perhaps implement a deep clone function for UserType?
|
//TODO:Perhaps implement a deep clone function for UserType?
|
||||||
ServiceProvider serviceProvider2 = new ServiceProvider("jbO4aBF4dC", null, null, null,
|
ServiceProvider serviceProvider2 = new ServiceProvider("jbO4aBF4dC", null, null, null,
|
||||||
"testaddress", "8888888888", "companydotcom", true);
|
"testaddress", "8888888888", "companydotcom", true, null);
|
||||||
serviceProvider2.setAvailabilities(0, 4, 18, 19, 30);
|
serviceProvider2.setAvailabilities(0, 4, 18, 19, 30);
|
||||||
serviceProvider2.setAvailabilities(1, 5, 20, 21, 11);
|
serviceProvider2.setAvailabilities(1, 5, 20, 21, 11);
|
||||||
serviceProvider2.setAvailabilities(3, 7, 12, 15, 14);
|
serviceProvider2.setAvailabilities(3, 7, 12, 15, 14);
|
||||||
|
@ -413,7 +414,7 @@ public class DBIntegrationTest {
|
||||||
@Test
|
@Test
|
||||||
public void testInvalidAvailability(){
|
public void testInvalidAvailability(){
|
||||||
ServiceProvider serviceProvider = new ServiceProvider("jbO4aBF4dC", null, null, null,
|
ServiceProvider serviceProvider = new ServiceProvider("jbO4aBF4dC", null, null, null,
|
||||||
"testaddress", "8888888888", "companydotcom", true);
|
"testaddress", "8888888888", "companydotcom", true, null);
|
||||||
serviceProvider.setAvailabilities(2, 8, 14, 8, 14);
|
serviceProvider.setAvailabilities(2, 8, 14, 8, 14);
|
||||||
serviceProvider.setAvailabilities(3, 15, 12, 8, 14);
|
serviceProvider.setAvailabilities(3, 15, 12, 8, 14);
|
||||||
|
|
||||||
|
|
|
@ -29,15 +29,15 @@ public class ServiceTest {
|
||||||
@Test
|
@Test
|
||||||
public void addServiceProviderTest(){
|
public void addServiceProviderTest(){
|
||||||
service.addServiceProvider( new ServiceProvider( "John123", "1234567890", "John", "Doe",
|
service.addServiceProvider( new ServiceProvider( "John123", "1234567890", "John", "Doe",
|
||||||
"testaddress", "8888888888", "companydotcom", true) );
|
"testaddress", "8888888888", "companydotcom", true, null) );
|
||||||
service.addServiceProvider( new ServiceProvider( "Jane123", "1234567890", "Jane", "Doe",
|
service.addServiceProvider( new ServiceProvider( "Jane123", "1234567890", "Jane", "Doe",
|
||||||
"testaddress", "8888888888", "companydotcom", true) );
|
"testaddress", "8888888888", "companydotcom", true, null) );
|
||||||
service.addServiceProvider( new ServiceProvider( "John123", "1234567890", "John", "Doe",
|
service.addServiceProvider( new ServiceProvider( "John123", "1234567890", "John", "Doe",
|
||||||
"testaddress", "8888888888", "companydotcom", true) );
|
"testaddress", "8888888888", "companydotcom", true, null) );
|
||||||
service.addServiceProvider( new ServiceProvider( "Jane123", "1234567890", "Jane", "Doe",
|
service.addServiceProvider( new ServiceProvider( "Jane123", "1234567890", "Jane", "Doe",
|
||||||
"testaddress", "8888888888", "companydotcom", true) );
|
"testaddress", "8888888888", "companydotcom", true, null) );
|
||||||
service.addServiceProvider( new ServiceProvider( "Jane123", "1234567890", "John", "Doe",
|
service.addServiceProvider( new ServiceProvider( "Jane123", "1234567890", "John", "Doe",
|
||||||
"testaddress", "8888888888", "companydotcom", true) );
|
"testaddress", "8888888888", "companydotcom", true, null) );
|
||||||
int numOfSP = service.getServiceProviders().size();
|
int numOfSP = service.getServiceProviders().size();
|
||||||
assertEquals( 2,numOfSP );
|
assertEquals( 2,numOfSP );
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,7 @@ public class UserTypeTest {
|
||||||
UserType user = new HomeOwner("John123", "1234567890", "John", "Doe");
|
UserType user = new HomeOwner("John123", "1234567890", "John", "Doe");
|
||||||
UserType admin = new Admin();
|
UserType admin = new Admin();
|
||||||
UserType serviceprovider = new ServiceProvider( "Jane123", "1234567890", "Jane", "Doe",
|
UserType serviceprovider = new ServiceProvider( "Jane123", "1234567890", "Jane", "Doe",
|
||||||
"testaddress", "8888888888", "companydotcom", true);
|
"testaddress", "8888888888", "companydotcom", true, "I am a walrus");
|
||||||
boolean userservice = user.equals(serviceprovider);
|
boolean userservice = user.equals(serviceprovider);
|
||||||
boolean useradmin = user.equals(admin);
|
boolean useradmin = user.equals(admin);
|
||||||
boolean serviceadmin = serviceprovider.equals(admin);
|
boolean serviceadmin = serviceprovider.equals(admin);
|
||||||
|
|
Loading…
Reference in a new issue