fixed bad constructor

This commit is contained in:
IvanaE 2018-11-16 15:50:56 -05:00
parent d83ae6bb69
commit cb06782c04
8 changed files with 23 additions and 23 deletions

View file

@ -309,9 +309,10 @@ public class DBHelper extends SQLiteOpenHelper {
usertype = new Admin(); usertype = new Admin();
} else if (cursor.getString(4) } else if (cursor.getString(4)
.equals("ServiceProvider")){ .equals("ServiceProvider")){
ServiceProvider serviceProvider = new ServiceProvider(username, password, firstname, lastname, address, phonenumber, companyname, licensed, description); ServiceProvider serviceProvider = new ServiceProvider(username, password, firstname, lastname, address, phonenumber, companyname, licensed);
getAllServicesProvidedByUser(serviceProvider); getAllServicesProvidedByUser(serviceProvider);
getAvailabilities(serviceProvider); getAvailabilities(serviceProvider);
serviceProvider.setDescription(description);
usertype = serviceProvider; usertype = serviceProvider;
} else { } else {
usertype = new HomeOwner(username, password, firstname, lastname); usertype = new HomeOwner(username, password, firstname, lastname);

View file

@ -44,7 +44,7 @@ public class ServiceProvider extends UserType {
* @param lastname String of the lastname. * @param lastname String of the lastname.
*/ */
ServiceProvider(String username, String password, String firstname, String lastname, String address, ServiceProvider(String username, String password, String firstname, String lastname, String address,
String phonenumber, String companyname, boolean licensed, String description){ String phonenumber, String companyname, boolean licensed){
super(username, password, firstname, lastname); super(username, password, firstname, lastname);
services = new ArrayList<>(); services = new ArrayList<>();
availabilities = new int[7][4]; availabilities = new int[7][4];
@ -52,7 +52,6 @@ public class ServiceProvider extends UserType {
this.phonenumber = phonenumber; this.phonenumber = phonenumber;
this.companyname = companyname; this.companyname = companyname;
this.licensed = licensed; this.licensed = licensed;
this.description = description;
} }
/** /**

View file

@ -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, null); "testaddress", "8888888888", "companydotcom", true);
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, "Not a penguin"); "testaddress", "8888888888", "companydotcom", true);
dbHelper.addUser(serviceProvider); dbHelper.addUser(serviceProvider);
//retrieve ServiceProvider and test the newly added fields //retrieve ServiceProvider and test the newly added fields
@ -102,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, null); "testaddress", "8888888888", "companydotcom", true);
dbHelper.addUser(serviceProvider); dbHelper.addUser(serviceProvider);
Service service1 = new Service("Hitman", 12358); Service service1 = new Service("Hitman", 12358);
@ -143,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, null)); "testaddress", "8888888888", "companydotcom", true));
assertTrue(!added); assertTrue(!added);
dbHelper.deleteUser("jbO4aBF4dC"); dbHelper.deleteUser("jbO4aBF4dC");
@ -279,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, null)); "testaddress", "8888888888", "companydotcom", true));
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);
@ -292,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, null); "testaddress", "8888888888", "companydotcom", true);
dbHelper.addUser(serviceProvider); dbHelper.addUser(serviceProvider);
Service service1 = new Service("Hitman", 12358); Service service1 = new Service("Hitman", 12358);
@ -325,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, null)); "testaddress", "8888888888", "companydotcom", true));
dbHelper.addUser(new ServiceProvider("7MuF1c59XP", null, null, null, dbHelper.addUser(new ServiceProvider("7MuF1c59XP", null, null, null,
"testaddress", "8888888888", "companydotcom", true, null)); "testaddress", "8888888888", "companydotcom", true));
dbHelper.addServiceProvidedByUser("jbO4aBF4dC", "exterminating flatworms"); dbHelper.addServiceProvidedByUser("jbO4aBF4dC", "exterminating flatworms");
dbHelper.addServiceProvidedByUser("7MuF1c59XP", "exterminating flatworms"); dbHelper.addServiceProvidedByUser("7MuF1c59XP", "exterminating flatworms");
@ -347,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, null); "testaddress", "8888888888", "companydotcom", true);
dbHelper.addUser(serviceProvider); dbHelper.addUser(serviceProvider);
Service service1 = new Service("Hitman", 12358); Service service1 = new Service("Hitman", 12358);
@ -377,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, null); "testaddress", "8888888888", "companydotcom", true);
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);
@ -385,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, null); "testaddress", "8888888888", "companydotcom", true);
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);
@ -414,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, null); "testaddress", "8888888888", "companydotcom", true);
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);

View file

@ -9,7 +9,7 @@ import static org.junit.Assert.*;
public class ServiceProviderTest { public class ServiceProviderTest {
ServiceProvider serviceprovider = new ServiceProvider("John123", "1234567890", "John", "Doe", ServiceProvider serviceprovider = new ServiceProvider("John123", "1234567890", "John", "Doe",
"testaddress", "8888888888", "companydotcom", true, "LOL"); "testaddress", "8888888888", "companydotcom", true);
/** /**
* Initiates an ServiceProvider account and tests if the random strings match to the required inputs. * Initiates an ServiceProvider account and tests if the random strings match to the required inputs.

View file

@ -6,7 +6,7 @@ import static org.junit.Assert.*;
public class ServiceProviderTest2 { public class ServiceProviderTest2 {
ServiceProvider serviceprovider = new ServiceProvider("John123", "1234567890", "John", "Doe", ServiceProvider serviceprovider = new ServiceProvider("John123", "1234567890", "John", "Doe",
"testaddress", "8888888888", "companydotcom", true, "LOL"); "testaddress", "8888888888", "companydotcom", true);
/** /**
* sets availabilities and tests them. * sets availabilities and tests them.

View file

@ -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, null) ); "testaddress", "8888888888", "companydotcom", true) );
service.addServiceProvider( new ServiceProvider( "Jane123", "1234567890", "Jane", "Doe", service.addServiceProvider( new ServiceProvider( "Jane123", "1234567890", "Jane", "Doe",
"testaddress", "8888888888", "companydotcom", true, null) ); "testaddress", "8888888888", "companydotcom", true) );
service.addServiceProvider( new ServiceProvider( "John123", "1234567890", "John", "Doe", service.addServiceProvider( new ServiceProvider( "John123", "1234567890", "John", "Doe",
"testaddress", "8888888888", "companydotcom", true, null) ); "testaddress", "8888888888", "companydotcom", true) );
service.addServiceProvider( new ServiceProvider( "Jane123", "1234567890", "Jane", "Doe", service.addServiceProvider( new ServiceProvider( "Jane123", "1234567890", "Jane", "Doe",
"testaddress", "8888888888", "companydotcom", true, null) ); "testaddress", "8888888888", "companydotcom", true) );
service.addServiceProvider( new ServiceProvider( "Jane123", "1234567890", "John", "Doe", service.addServiceProvider( new ServiceProvider( "Jane123", "1234567890", "John", "Doe",
"testaddress", "8888888888", "companydotcom", true, null) ); "testaddress", "8888888888", "companydotcom", true) );
int numOfSP = service.getServiceProviders().size(); int numOfSP = service.getServiceProviders().size();
assertEquals( 2,numOfSP ); assertEquals( 2,numOfSP );
} }

View file

@ -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, "I am a walrus"); "testaddress", "8888888888", "companydotcom", true);
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);