From e9ee14542c8c8ebf094cf2eabb8b8059dc0315fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Batuhan=20Berk=20Ba=C5=9Fo=C4=9Flu?= Date: Thu, 1 Nov 2018 23:17:34 -0400 Subject: [PATCH] made 3 test cases for each class --- .../olympus/olympusservices/UserType.java | 2 -- .../olympus/olympusservices/AdminTest.java | 23 ++++++++++++++ .../olympusservices/HomeOwnerTest.java | 27 +++++++++++++++++ .../olympus/olympusservices/LogInTest.java | 5 ---- .../olympusservices/ServiceProviderTest.java | 9 ++++++ .../olympus/olympusservices/ServiceTest.java | 4 +++ .../olympus/olympusservices/SignUpTest.java | 5 ---- .../olympus/olympusservices/UserTypeTest.java | 30 +++++++++++++++++++ 8 files changed, 93 insertions(+), 12 deletions(-) create mode 100644 OlympusServices/app/src/test/java/com/uottawa/olympus/olympusservices/AdminTest.java create mode 100644 OlympusServices/app/src/test/java/com/uottawa/olympus/olympusservices/HomeOwnerTest.java delete mode 100644 OlympusServices/app/src/test/java/com/uottawa/olympus/olympusservices/LogInTest.java create mode 100644 OlympusServices/app/src/test/java/com/uottawa/olympus/olympusservices/ServiceTest.java delete mode 100644 OlympusServices/app/src/test/java/com/uottawa/olympus/olympusservices/SignUpTest.java create mode 100644 OlympusServices/app/src/test/java/com/uottawa/olympus/olympusservices/UserTypeTest.java diff --git a/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/UserType.java b/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/UserType.java index 8c8cbeb..7539a2a 100644 --- a/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/UserType.java +++ b/OlympusServices/app/src/main/java/com/uottawa/olympus/olympusservices/UserType.java @@ -69,8 +69,6 @@ public abstract class UserType { } - - public boolean equals(UserType other){ if(this.username.equals(other.username)&&this.password.equals(other.password)&& this.firstname.equals(other.firstname)&&this.lastname.equals(other.lastname)){ 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 new file mode 100644 index 0000000..2eabc9d --- /dev/null +++ b/OlympusServices/app/src/test/java/com/uottawa/olympus/olympusservices/AdminTest.java @@ -0,0 +1,23 @@ +package com.uottawa.olympus.olympusservices; + +import org.junit.Test; + +import static org.junit.Assert.*; + +public class AdminTest { + + @Test + public void testAdmin() { + Admin admin = new Admin(); + String username = admin.getUsername(); + String password = admin.getPassword(); + String firstname = admin.getFirstname(); + String lastname = admin.getLastname(); + String role = admin.getRole(); + assertEquals("Admin", role); + assertEquals("admin", username); + assertEquals("admin", password); + assertEquals("Admin", firstname); + assertEquals("Admin", lastname); + } +} \ No newline at end of file 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 new file mode 100644 index 0000000..1453b21 --- /dev/null +++ b/OlympusServices/app/src/test/java/com/uottawa/olympus/olympusservices/HomeOwnerTest.java @@ -0,0 +1,27 @@ +package com.uottawa.olympus.olympusservices; + +import org.junit.Test; + +import static org.junit.Assert.*; + +public class HomeOwnerTest { + + @Test + public void testHomeOwner(){ + UserType user = new HomeOwner( "John123", "1234567890", "John", "Doe" ); + String role = user.getRole(); + assertEquals("HomeOwner", role); + assertEquals("John123", user.getUsername()); + assertEquals("1234567890", user.getPassword()); + assertEquals("John", user.getFirstname()); + assertEquals("Doe", user.getLastname()); + user.setUsername( "username" ); + user.setPassword( "password" ); + user.setFirstname( "firstname" ); + user.setLastname( "lastname" ); + assertNotEquals("John123", user.getUsername()); + assertNotEquals("1234567890", user.getPassword()); + assertNotEquals("John", user.getFirstname()); + assertNotEquals("Doe", user.getLastname()); + } +} diff --git a/OlympusServices/app/src/test/java/com/uottawa/olympus/olympusservices/LogInTest.java b/OlympusServices/app/src/test/java/com/uottawa/olympus/olympusservices/LogInTest.java deleted file mode 100644 index 572d402..0000000 --- a/OlympusServices/app/src/test/java/com/uottawa/olympus/olympusservices/LogInTest.java +++ /dev/null @@ -1,5 +0,0 @@ -import static org.junit.Assert.*; - -public class LogInTest { - -} \ No newline at end of file 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 23a9997..22cc495 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 @@ -1,5 +1,14 @@ +package com.uottawa.olympus.olympusservices; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + import static org.junit.Assert.*; public class ServiceProviderTest { + @Test + public void addService() { + } } \ No newline at end of file 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 new file mode 100644 index 0000000..87aaa31 --- /dev/null +++ b/OlympusServices/app/src/test/java/com/uottawa/olympus/olympusservices/ServiceTest.java @@ -0,0 +1,4 @@ +package com.uottawa.olympus.olympusservices; + +public class ServiceTest { +} diff --git a/OlympusServices/app/src/test/java/com/uottawa/olympus/olympusservices/SignUpTest.java b/OlympusServices/app/src/test/java/com/uottawa/olympus/olympusservices/SignUpTest.java deleted file mode 100644 index c349949..0000000 --- a/OlympusServices/app/src/test/java/com/uottawa/olympus/olympusservices/SignUpTest.java +++ /dev/null @@ -1,5 +0,0 @@ -import static org.junit.Assert.*; - -public class SignUpTest { - -} \ No newline at end of file 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 new file mode 100644 index 0000000..1934f15 --- /dev/null +++ b/OlympusServices/app/src/test/java/com/uottawa/olympus/olympusservices/UserTypeTest.java @@ -0,0 +1,30 @@ +package com.uottawa.olympus.olympusservices; + +import android.view.View; + +import org.junit.After; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; + +import static org.junit.Assert.*; + +public class UserTypeTest { + + @Test + public void userTypeComparaison() { + UserType user = new HomeOwner("John123", "1234567890", "John", "Doe"); + UserType admin = new Admin(); + UserType serviceprovider = new ServiceProvider( "Jane123", "1234567890", "Jane", "Doe"); + boolean userservice = user.equals(serviceprovider); + boolean useradmin = user.equals(admin); + boolean serviceadmin = serviceprovider.equals(admin); + assertNotEquals( true, useradmin ); + assertNotEquals( true, serviceadmin ); + assertNotEquals( true, userservice ); + user.setFirstname(serviceprovider.getFirstname()); + user.setUsername(serviceprovider.getUsername()); + userservice = user.equals(serviceprovider); + assertEquals( true, userservice ); + } +} \ No newline at end of file