fixed bad constructor
This commit is contained in:
		
							parent
							
								
									92c4d8cfd8
								
							
						
					
					
						commit
						924bb3319e
					
				
					 8 changed files with 23 additions and 23 deletions
				
			
		
							
								
								
									
										
											BIN
										
									
								
								OlympusServices/.idea/caches/build_file_checksums.ser
									
										
									
										generated
									
									
									
								
							
							
						
						
									
										
											BIN
										
									
								
								OlympusServices/.idea/caches/build_file_checksums.ser
									
										
									
										generated
									
									
									
								
							
										
											Binary file not shown.
										
									
								
							| 
						 | 
				
			
			@ -309,9 +309,10 @@ public class DBHelper extends SQLiteOpenHelper {
 | 
			
		|||
                usertype = new Admin();
 | 
			
		||||
            } else if (cursor.getString(4)
 | 
			
		||||
                    .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);
 | 
			
		||||
                getAvailabilities(serviceProvider);
 | 
			
		||||
                serviceProvider.setDescription(description);
 | 
			
		||||
                usertype = serviceProvider;
 | 
			
		||||
            } else {
 | 
			
		||||
                usertype = new HomeOwner(username, password, firstname, lastname);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -44,7 +44,7 @@ public class ServiceProvider extends UserType {
 | 
			
		|||
     * @param lastname String of the lastname.
 | 
			
		||||
     */
 | 
			
		||||
    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);
 | 
			
		||||
        services = new ArrayList<>();
 | 
			
		||||
        availabilities = new int[7][4];
 | 
			
		||||
| 
						 | 
				
			
			@ -52,7 +52,6 @@ public class ServiceProvider extends UserType {
 | 
			
		|||
        this.phonenumber = phonenumber;
 | 
			
		||||
        this.companyname = companyname;
 | 
			
		||||
        this.licensed = licensed;
 | 
			
		||||
        this.description = description;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -52,7 +52,7 @@ public class DBIntegrationTest {
 | 
			
		|||
 | 
			
		||||
        //add a ServiceProvider to database
 | 
			
		||||
        originalUser = new ServiceProvider("jbO4aBF4dC", "seg2105", "Juan", "Guzman",
 | 
			
		||||
                "testaddress", "8888888888", "companydotcom", true, null);
 | 
			
		||||
                "testaddress", "8888888888", "companydotcom", true);
 | 
			
		||||
        addedTwo = dbHelper.addUser(originalUser);
 | 
			
		||||
 | 
			
		||||
        //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(){
 | 
			
		||||
        //ServiceProviders have extra fields that can be added to the DB
 | 
			
		||||
        ServiceProvider serviceProvider = new ServiceProvider("7MuF1c59XP", null, null, null,
 | 
			
		||||
                "testaddress", "8888888888", "companydotcom", true, "Not a penguin");
 | 
			
		||||
                "testaddress", "8888888888", "companydotcom", true);
 | 
			
		||||
        dbHelper.addUser(serviceProvider);
 | 
			
		||||
 | 
			
		||||
        //retrieve ServiceProvider and test the newly added fields
 | 
			
		||||
| 
						 | 
				
			
			@ -102,7 +102,7 @@ public class DBIntegrationTest {
 | 
			
		|||
    public void testDeleteServiceProvider(){
 | 
			
		||||
        //make sure all the rows related to ServiceProvider in all tables are deleted
 | 
			
		||||
        ServiceProvider serviceProvider = new ServiceProvider("jbO4aBF4dC", null, null, null,
 | 
			
		||||
                "testaddress", "8888888888", "companydotcom", true, null);
 | 
			
		||||
                "testaddress", "8888888888", "companydotcom", true);
 | 
			
		||||
        dbHelper.addUser(serviceProvider);
 | 
			
		||||
 | 
			
		||||
        Service service1 = new Service("Hitman", 12358);
 | 
			
		||||
| 
						 | 
				
			
			@ -143,7 +143,7 @@ public class DBIntegrationTest {
 | 
			
		|||
        added = dbHelper.addUser(new HomeOwner("jbO4aBF4dC", "seg2105", "Miguel", "Garzon"));
 | 
			
		||||
        assertTrue(!added);
 | 
			
		||||
        added = dbHelper.addUser(new ServiceProvider("jbO4aBF4dC", "seg2105", "Juan", "Guzman",
 | 
			
		||||
                "testaddress", "8888888888", "companydotcom", true, null));
 | 
			
		||||
                "testaddress", "8888888888", "companydotcom", true));
 | 
			
		||||
        assertTrue(!added);
 | 
			
		||||
 | 
			
		||||
        dbHelper.deleteUser("jbO4aBF4dC");
 | 
			
		||||
| 
						 | 
				
			
			@ -279,7 +279,7 @@ public class DBIntegrationTest {
 | 
			
		|||
    @Test
 | 
			
		||||
    public void testAddAndDeleteServiceProvidedByUser(){
 | 
			
		||||
        dbHelper.addUser(new ServiceProvider("jbO4aBF4dC", null, null, null,
 | 
			
		||||
                "testaddress", "8888888888", "companydotcom", true, null));
 | 
			
		||||
                "testaddress", "8888888888", "companydotcom", true));
 | 
			
		||||
        dbHelper.addService(new Service("Hitman", 12358));
 | 
			
		||||
        boolean added = dbHelper.addServiceProvidedByUser("jbO4aBF4dC", "hitman");
 | 
			
		||||
        assertTrue(added);
 | 
			
		||||
| 
						 | 
				
			
			@ -292,7 +292,7 @@ public class DBIntegrationTest {
 | 
			
		|||
    @Test
 | 
			
		||||
    public void testGetAllServicesProvidedByUserAndDeleteService(){
 | 
			
		||||
        ServiceProvider serviceProvider = new ServiceProvider("jbO4aBF4dC", null, null, null,
 | 
			
		||||
                "testaddress", "8888888888", "companydotcom", true, null);
 | 
			
		||||
                "testaddress", "8888888888", "companydotcom", true);
 | 
			
		||||
        dbHelper.addUser(serviceProvider);
 | 
			
		||||
 | 
			
		||||
        Service service1 = new Service("Hitman", 12358);
 | 
			
		||||
| 
						 | 
				
			
			@ -325,9 +325,9 @@ public class DBIntegrationTest {
 | 
			
		|||
    public void testGetAllProvidersByService(){
 | 
			
		||||
        dbHelper.addService(new Service("Exterminating flatworms", 392.457));
 | 
			
		||||
        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,
 | 
			
		||||
                "testaddress", "8888888888", "companydotcom", true, null));
 | 
			
		||||
                "testaddress", "8888888888", "companydotcom", true));
 | 
			
		||||
 | 
			
		||||
        dbHelper.addServiceProvidedByUser("jbO4aBF4dC", "exterminating flatworms");
 | 
			
		||||
        dbHelper.addServiceProvidedByUser("7MuF1c59XP", "exterminating flatworms");
 | 
			
		||||
| 
						 | 
				
			
			@ -347,7 +347,7 @@ public class DBIntegrationTest {
 | 
			
		|||
    @Test
 | 
			
		||||
    public void testDeleteServiceProvidedByUser(){
 | 
			
		||||
        ServiceProvider serviceProvider = new ServiceProvider("jbO4aBF4dC", null, null, null,
 | 
			
		||||
                "testaddress", "8888888888", "companydotcom", true, null);
 | 
			
		||||
                "testaddress", "8888888888", "companydotcom", true);
 | 
			
		||||
        dbHelper.addUser(serviceProvider);
 | 
			
		||||
 | 
			
		||||
        Service service1 = new Service("Hitman", 12358);
 | 
			
		||||
| 
						 | 
				
			
			@ -377,7 +377,7 @@ public class DBIntegrationTest {
 | 
			
		|||
    @Test
 | 
			
		||||
    public void testUpdateAndGetAvailability(){
 | 
			
		||||
        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(1, 5, 20, 21, 11);
 | 
			
		||||
        serviceProvider.setAvailabilities(3, 7, 12, 15, 14);
 | 
			
		||||
| 
						 | 
				
			
			@ -385,7 +385,7 @@ public class DBIntegrationTest {
 | 
			
		|||
 | 
			
		||||
        //TODO:Perhaps implement a deep clone function for UserType?
 | 
			
		||||
        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(1, 5, 20, 21, 11);
 | 
			
		||||
        serviceProvider2.setAvailabilities(3, 7, 12, 15, 14);
 | 
			
		||||
| 
						 | 
				
			
			@ -414,7 +414,7 @@ public class DBIntegrationTest {
 | 
			
		|||
    @Test
 | 
			
		||||
    public void testInvalidAvailability(){
 | 
			
		||||
        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(3, 15, 12, 8, 14);
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -9,7 +9,7 @@ import static org.junit.Assert.*;
 | 
			
		|||
public class ServiceProviderTest {
 | 
			
		||||
 | 
			
		||||
    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.
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -6,7 +6,7 @@ import static org.junit.Assert.*;
 | 
			
		|||
 | 
			
		||||
public class ServiceProviderTest2 {
 | 
			
		||||
    ServiceProvider serviceprovider = new ServiceProvider("John123", "1234567890", "John", "Doe",
 | 
			
		||||
            "testaddress", "8888888888", "companydotcom", true, "LOL");
 | 
			
		||||
            "testaddress", "8888888888", "companydotcom", true);
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * sets availabilities and tests them.
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -29,15 +29,15 @@ public class ServiceTest {
 | 
			
		|||
    @Test
 | 
			
		||||
    public void addServiceProviderTest(){
 | 
			
		||||
        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",
 | 
			
		||||
                "testaddress", "8888888888", "companydotcom", true, null) );
 | 
			
		||||
                "testaddress", "8888888888", "companydotcom", true) );
 | 
			
		||||
        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",
 | 
			
		||||
                "testaddress", "8888888888", "companydotcom", true, null) );
 | 
			
		||||
                "testaddress", "8888888888", "companydotcom", true) );
 | 
			
		||||
        service.addServiceProvider( new ServiceProvider( "Jane123", "1234567890", "John", "Doe",
 | 
			
		||||
                "testaddress", "8888888888", "companydotcom", true, null) );
 | 
			
		||||
                "testaddress", "8888888888", "companydotcom", true) );
 | 
			
		||||
        int numOfSP = service.getServiceProviders().size();
 | 
			
		||||
        assertEquals( 2,numOfSP );
 | 
			
		||||
    }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -20,7 +20,7 @@ public class UserTypeTest {
 | 
			
		|||
        UserType user = new HomeOwner("John123", "1234567890", "John", "Doe");
 | 
			
		||||
        UserType admin = new Admin();
 | 
			
		||||
        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 useradmin = user.equals(admin);
 | 
			
		||||
        boolean serviceadmin = serviceprovider.equals(admin);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue