From c5d85d3f5ceb8ee54ac9aba42d69b05685f213f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Batuhan=20Berk=20Ba=C5=9Fo=C4=9Flu?= Date: Wed, 7 Nov 2018 13:28:41 -0500 Subject: [PATCH 1/5] Testing --- .../.idea/caches/build_file_checksums.ser | Bin 537 -> 537 bytes .../olympus/olympusservices/LogInTest.java | 1 - 2 files changed, 1 deletion(-) diff --git a/OlympusServices/.idea/caches/build_file_checksums.ser b/OlympusServices/.idea/caches/build_file_checksums.ser index 4c7ae2cb6fe400b7e4228637a4b4ed7858152f3c..c6475821fae657d69e411dbbe7ad0a00aa09ac84 100644 GIT binary patch delta 65 zcmV-H0KWg31epYonFDQM#gUwe4=6)ATvc;ra&uf_VRUt9lePgilO+Lg6Gc)afp>2b X{6(K*f>$BX3UmMwlfMBQlL!J4BU2XY delta 59 zcmV-B0L1^91epYonF9$r0+F1FlWGBQAtC;BA{s#RADTG+Q)o0Nu5Lpoelb7gXK RTuF9eZef!&0XCED0WEhP6(axu diff --git a/OlympusServices/app/src/androidTest/java/com/uottawa/olympus/olympusservices/LogInTest.java b/OlympusServices/app/src/androidTest/java/com/uottawa/olympus/olympusservices/LogInTest.java index 6828df5..0487845 100644 --- a/OlympusServices/app/src/androidTest/java/com/uottawa/olympus/olympusservices/LogInTest.java +++ b/OlympusServices/app/src/androidTest/java/com/uottawa/olympus/olympusservices/LogInTest.java @@ -17,7 +17,6 @@ public class LogInTest { @Test public void checkSignIn() throws Exception{ - //Lalala } } \ No newline at end of file From d1f7e5a81caa568da6179e384a660d77c6245758 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Batuhan=20Berk=20Ba=C5=9Fo=C4=9Flu?= Date: Wed, 7 Nov 2018 13:47:06 -0500 Subject: [PATCH 2/5] Added comments to test files --- .../uottawa/olympus/olympusservices/AdminTest.java | 4 ++++ .../olympus/olympusservices/HomeOwnerTest.java | 4 ++++ .../olympusservices/ServiceProviderTest.java | 13 +++++++++++-- .../olympus/olympusservices/ServiceTest.java | 10 ++++++++++ .../olympus/olympusservices/UserTypeTest.java | 4 ++++ 5 files changed, 33 insertions(+), 2 deletions(-) diff --git a/OlympusServices/app/src/test/java/com/uottawa/olympus/olympusservices/AdminTest.java b/OlympusServices/app/src/test/java/com/uottawa/olympus/olympusservices/AdminTest.java index 2eabc9d..38008b6 100644 --- a/OlympusServices/app/src/test/java/com/uottawa/olympus/olympusservices/AdminTest.java +++ b/OlympusServices/app/src/test/java/com/uottawa/olympus/olympusservices/AdminTest.java @@ -6,6 +6,10 @@ import static org.junit.Assert.*; public class AdminTest { + /** + * Initiates an Admin account and tests if the strings match to the required inputs. + */ + @Test public void testAdmin() { Admin admin = new Admin(); diff --git a/OlympusServices/app/src/test/java/com/uottawa/olympus/olympusservices/HomeOwnerTest.java b/OlympusServices/app/src/test/java/com/uottawa/olympus/olympusservices/HomeOwnerTest.java index 1453b21..47d33a8 100644 --- a/OlympusServices/app/src/test/java/com/uottawa/olympus/olympusservices/HomeOwnerTest.java +++ b/OlympusServices/app/src/test/java/com/uottawa/olympus/olympusservices/HomeOwnerTest.java @@ -6,6 +6,10 @@ import static org.junit.Assert.*; public class HomeOwnerTest { + /** + * Initiates an Homeowner account and tests if the random strings match to the required inputs. + */ + @Test public void testHomeOwner(){ UserType user = new HomeOwner( "John123", "1234567890", "John", "Doe" ); 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 d28fc45..ab776d1 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 @@ -10,6 +10,10 @@ public class ServiceProviderTest { ServiceProvider serviceprovider = new ServiceProvider("John123", "1234567890", "John", "Doe"); + /** + * Initiates an ServiceProvider account and tests if the random strings match to the required inputs. + */ + @Test public void testServiceProvider() { assertEquals( "John123", serviceprovider.getUsername() ); @@ -27,13 +31,18 @@ public class ServiceProviderTest { assertNotEquals("Doe", serviceprovider.getLastname()); } + /** + * adds services and tests if they match the requirements in order to function properly. Example: If a service has a same name it doesn't count as one. + * + */ + @Test public void addServiceTest() { serviceprovider.addService( new Service( "KitchenCleaner", 50 ) ); serviceprovider.addService( new Service( "FrenchMaid", 250 ) ); - serviceprovider.addService( new Service( "FrenchMaid", 250 ) ); - serviceprovider.addService( new Service( "SecretService", 150 ) ); + serviceprovider.addService( new Service( "FrenchMaid", 210 ) ); serviceprovider.addService( new Service( "SecretService", 150 ) ); + serviceprovider.addService( new Service( "SecretService", 110 ) ); int numOfServices = serviceprovider.getServices().size(); assertEquals( 3, numOfServices ); } diff --git a/OlympusServices/app/src/test/java/com/uottawa/olympus/olympusservices/ServiceTest.java b/OlympusServices/app/src/test/java/com/uottawa/olympus/olympusservices/ServiceTest.java index ea1d487..6402296 100644 --- a/OlympusServices/app/src/test/java/com/uottawa/olympus/olympusservices/ServiceTest.java +++ b/OlympusServices/app/src/test/java/com/uottawa/olympus/olympusservices/ServiceTest.java @@ -7,6 +7,10 @@ import static org.junit.Assert.*; public class ServiceTest { Service service = new Service( "FrenchMaid", 250 ); + /** + * Initiates an Service account and tests if the random strings match to the required inputs. + */ + @Test public void testService(){ assertEquals( "FrenchMaid", service.getName() ); @@ -17,12 +21,18 @@ public class ServiceTest { assertNotEquals( 250, service.getRate()); } + /** + * adds service providers and tests if they match the requirements in order to function properly. Example: If a service has a same name it doesn't count as one. + * + */ + @Test public void addServiceProviderTest(){ service.addServiceProvider( new ServiceProvider( "John123", "1234567890", "John", "Doe" ) ); service.addServiceProvider( new ServiceProvider( "Jane123", "1234567890", "Jane", "Doe" ) ); service.addServiceProvider( new ServiceProvider( "John123", "1234567890", "John", "Doe" ) ); service.addServiceProvider( new ServiceProvider( "Jane123", "1234567890", "Jane", "Doe" ) ); + service.addServiceProvider( new ServiceProvider( "Jane123", "1234567890", "John", "Doe" ) ); int numOfSP = service.getServiceProviders().size(); assertEquals( 2,numOfSP ); } diff --git a/OlympusServices/app/src/test/java/com/uottawa/olympus/olympusservices/UserTypeTest.java b/OlympusServices/app/src/test/java/com/uottawa/olympus/olympusservices/UserTypeTest.java index 1934f15..12d173d 100644 --- a/OlympusServices/app/src/test/java/com/uottawa/olympus/olympusservices/UserTypeTest.java +++ b/OlympusServices/app/src/test/java/com/uottawa/olympus/olympusservices/UserTypeTest.java @@ -11,6 +11,10 @@ import static org.junit.Assert.*; public class UserTypeTest { + /** + * Tests if the every user that is created is equal to each other or not. + */ + @Test public void userTypeComparaison() { UserType user = new HomeOwner("John123", "1234567890", "John", "Doe"); From 95e281fc87782058446b72e5608989ca29c87c7e Mon Sep 17 00:00:00 2001 From: IvanaE Date: Wed, 7 Nov 2018 13:50:10 -0500 Subject: [PATCH 3/5] added field checking, fixed some errors --- .../EditServiceDialogFragment.java | 20 +++++++++++++------ .../NewServiceDialogFragment.java | 20 ++++++++++++------- .../olympus/olympusservices/ServicesList.java | 2 ++ .../res/layout/activity_services_list.xml | 15 ++++++++++++-- .../main/res/layout/dialog_service_edit.xml | 1 + .../main/res/layout/dialog_service_new.xml | 2 ++ .../app/src/main/res/layout/list_item.xml | 8 +++++--- 7 files changed, 50 insertions(+), 18 deletions(-) diff --git a/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/EditServiceDialogFragment.java b/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/EditServiceDialogFragment.java index 2b06dc4..6eb89b1 100644 --- a/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/EditServiceDialogFragment.java +++ b/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/EditServiceDialogFragment.java @@ -8,6 +8,7 @@ import android.os.Bundle; import android.support.v4.app.DialogFragment; import android.view.LayoutInflater; import android.widget.EditText; +import android.widget.Toast; public class EditServiceDialogFragment extends DialogFragment{ @@ -47,18 +48,25 @@ public interface NoticeDialogListener { Bundle args = new Bundle(); args.putString("name", (String)getArguments().get("name")); EditText rateInput = (EditText) ((AlertDialog) dialog).findViewById(R.id.RateInput); - double rate = Double.parseDouble(rateInput.getText().toString()); - args.putDouble("rate", rate); - - EditServiceDialogFragment.this.setArguments(args); - mListener.onDialogEdit(EditServiceDialogFragment.this); + if(rateInput.getText().toString().length()>0){ + Double rate = Double.parseDouble(rateInput.getText().toString()); + args.putDouble("rate", rate); + + EditServiceDialogFragment.this.setArguments(args); + mListener.onDialogEdit(EditServiceDialogFragment.this); + } + else{ + Toast.makeText(getContext(), "Rate cannot be empty", Toast.LENGTH_LONG).show(); + + } + } }) .setNegativeButton(R.string.delete, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { Bundle args = new Bundle(); args.putString("name", (String)getArguments().get("name")); - + EditServiceDialogFragment.this.setArguments(args); mListener.onDialogDelete(EditServiceDialogFragment.this); } diff --git a/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/NewServiceDialogFragment.java b/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/NewServiceDialogFragment.java index a5240f5..3e2e5df 100644 --- a/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/NewServiceDialogFragment.java +++ b/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/NewServiceDialogFragment.java @@ -15,6 +15,7 @@ import android.support.annotation.Nullable; import android.view.ViewGroup; import android.widget.EditText; import android.view.View; +import android.widget.Toast; import com.rengwuxian.materialedittext.MaterialEditText; @@ -63,13 +64,18 @@ public class NewServiceDialogFragment extends DialogFragment { EditText nameInput = (EditText) ((AlertDialog) dialog).findViewById(R.id.NameInput); EditText rateInput = (EditText) ((AlertDialog) dialog).findViewById(R.id.RateInput); String name = nameInput.getText().toString(); - double rate = Double.parseDouble(rateInput.getText().toString()); - Bundle args = new Bundle(); - args.putString("name", name); - args.putDouble("rate", rate); - NewServiceDialogFragment.this.setArguments(args); - mListener.onDialogNew(NewServiceDialogFragment.this); - + if (rateInput.getText().toString().length()>0 && name.length()>0 && name.matches("[a-zA-Z]*")){ + Double rate = Double.parseDouble(rateInput.getText().toString()); + Bundle args = new Bundle(); + args.putString("name", name); + args.putDouble("rate", rate); + NewServiceDialogFragment.this.setArguments(args); + mListener.onDialogNew(NewServiceDialogFragment.this); + } + else{ + Toast.makeText(getContext(), "Service must have an alphanumeric name and a rate", Toast.LENGTH_LONG).show(); + + } } }) .setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() { diff --git a/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/ServicesList.java b/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/ServicesList.java index db0cd9e..2591a71 100644 --- a/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/ServicesList.java +++ b/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/ServicesList.java @@ -14,6 +14,7 @@ import android.widget.AdapterView; import android.widget.ArrayAdapter; import android.widget.GridView; import android.widget.TextView; +import android.widget.Toast; import java.util.Iterator; import java.util.List; @@ -91,6 +92,7 @@ public class ServicesList extends AppCompatActivity implements NewServiceDialogF DBHelper dbHelper = new DBHelper(this); String name = (String)dialog.getArguments().get("name"); dbHelper.deleteService(name); + Toast.makeText(this, "Service \""+(String)dialog.getArguments().get("name")+"\" has been deleted", Toast.LENGTH_LONG).show(); dialog.dismiss(); this.recreate(); } diff --git a/OlympusServices/app/src/main/res/layout/activity_services_list.xml b/OlympusServices/app/src/main/res/layout/activity_services_list.xml index 03bbcf4..756282d 100644 --- a/OlympusServices/app/src/main/res/layout/activity_services_list.xml +++ b/OlympusServices/app/src/main/res/layout/activity_services_list.xml @@ -50,7 +50,7 @@ android:layout_marginBottom="5dp" android:layout_marginTop="10dp" android:layout_weight="1" - android:text="Hourly Rate" + android:text="Hourly Rate($)" android:textAppearance="@style/TextAppearance.AppCompat.Large" android:textColor="@android:color/white" android:textSize="15sp" /> @@ -67,11 +67,22 @@ android:layout_height="250dp"/> +