-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add connect/signup and create association to production
Add features for 0.1.0 release
- Loading branch information
Showing
40 changed files
with
1,854 additions
and
247 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 0 additions & 26 deletions
26
app/src/androidTest/java/fr/paris10/projet/assogenda/assogenda/ExampleInstrumentedTest.java
This file was deleted.
Oops, something went wrong.
47 changes: 47 additions & 0 deletions
47
app/src/androidTest/java/fr/paris10/projet/assogenda/assogenda/daos/DAOAssociationTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package fr.paris10.projet.assogenda.assogenda.daos; | ||
|
||
import org.junit.After; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
|
||
import static org.junit.Assert.*; | ||
|
||
public class DAOAssociationTest { | ||
|
||
private DAOAssociation daoAssociation; | ||
|
||
@Before | ||
public void setUp() throws Exception { | ||
this.daoAssociation = DAOAssociation.getInstance(); | ||
} | ||
|
||
@After | ||
public void tearDown() throws Exception { | ||
this.daoAssociation = null; | ||
} | ||
|
||
@Test | ||
public void testInitDAO() throws Exception { | ||
assertNotNull(daoAssociation); | ||
} | ||
|
||
@Test | ||
public void testValidateAssociation() throws Exception { | ||
assertFalse(daoAssociation.validateAssociation(null, null, null)); | ||
assertFalse(daoAssociation.validateAssociationName(null)); | ||
|
||
//Test if association name contains more than 2 caracters | ||
assertFalse(daoAssociation.validateAssociationName("Na")); | ||
|
||
assertFalse(daoAssociation.validateAssociationUniversity(null)); | ||
assertFalse(daoAssociation.validateAssociationUniversity("Un")); | ||
|
||
assertFalse(daoAssociation.validateAssociationDescription(null)); | ||
assertFalse(daoAssociation.validateAssociationDescription("De")); | ||
|
||
assertTrue(daoAssociation.validateAssociation("Name", "University", "Description")); | ||
assertTrue(daoAssociation.validateAssociationName("Name")); | ||
assertTrue(daoAssociation.validateAssociationUniversity("University")); | ||
assertTrue(daoAssociation.validateAssociationDescription("Description")); | ||
} | ||
} |
63 changes: 63 additions & 0 deletions
63
app/src/androidTest/java/fr/paris10/projet/assogenda/assogenda/daos/DAOUserTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
package fr.paris10.projet.assogenda.assogenda.daos; | ||
|
||
import android.content.Context; | ||
import android.support.test.InstrumentationRegistry; | ||
import android.support.test.runner.AndroidJUnit4; | ||
|
||
import org.junit.After; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
|
||
import fr.paris10.projet.assogenda.assogenda.model.User; | ||
|
||
import static org.junit.Assert.*; | ||
|
||
@RunWith(AndroidJUnit4.class) | ||
public class DAOUserTest { | ||
private Context appContext; | ||
private DAOUser daoUser; | ||
|
||
@Before | ||
public void setUp() throws Exception { | ||
this.appContext = InstrumentationRegistry.getTargetContext(); | ||
this.daoUser = DAOUser.getInstance(); | ||
} | ||
|
||
@After | ||
public void tearDown() throws Exception { | ||
this.appContext = null; | ||
this.daoUser = null; | ||
} | ||
|
||
@Test | ||
public void testInitDAO() throws Exception { | ||
assertNotNull(daoUser); | ||
} | ||
|
||
@Test | ||
public void testValidateUser() throws Exception { | ||
final String userCreate = "User should have been created"; | ||
final String userNotCreate = "User should have not been created"; | ||
User user = new User("[email protected]", "test", "supertest"); | ||
assertFalse(userNotCreate, daoUser.validateUser(null, null, null, null)); | ||
assertTrue(userCreate, daoUser.validateUser(user, "superpassword")); | ||
assertFalse(userNotCreate, daoUser.validateUser(user, null)); | ||
user.email="test.fr"; | ||
assertFalse(userNotCreate, daoUser.validateUser(user, "superpassword")); | ||
user.email=null; | ||
assertFalse(userNotCreate, daoUser.validateUser(user, "superpassword")); | ||
assertFalse(userNotCreate, daoUser.validateUser((String) null, null)); | ||
assertFalse(userNotCreate, daoUser.validateUser("fakeemail.fr", "password")); | ||
assertFalse(userNotCreate, daoUser.validateUser("[email protected]", "123")); | ||
assertTrue(userCreate, daoUser.validateUser("[email protected]", "password")); | ||
} | ||
|
||
@Test | ||
public void testSignInAndOut() throws Exception { | ||
if (daoUser.isLoggedIn()) | ||
daoUser.signOut(); | ||
assertFalse(daoUser.isLoggedIn()); | ||
} | ||
|
||
} |
32 changes: 32 additions & 0 deletions
32
...androidTest/java/fr/paris10/projet/assogenda/assogenda/ui/activites/MainActivityTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package fr.paris10.projet.assogenda.assogenda.ui.activites; | ||
|
||
import android.support.test.rule.ActivityTestRule; | ||
import android.support.test.runner.AndroidJUnit4; | ||
|
||
import org.junit.Rule; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
|
||
import fr.paris10.projet.assogenda.assogenda.R; | ||
import fr.paris10.projet.assogenda.assogenda.daos.DAOUser; | ||
|
||
import static org.junit.Assert.*; | ||
import static android.support.test.espresso.Espresso.onView; | ||
import static android.support.test.espresso.action.ViewActions.click; | ||
import static android.support.test.espresso.matcher.ViewMatchers.withId; | ||
|
||
@RunWith(AndroidJUnit4.class) | ||
public class MainActivityTest { | ||
@Rule | ||
public ActivityTestRule<MainActivity> mActivityRule = | ||
new ActivityTestRule<>(MainActivity.class); | ||
|
||
@Test | ||
public void testLogOutButton() { | ||
DAOUser daoUser = DAOUser.getInstance(); | ||
if (daoUser.isLoggedIn()) { | ||
onView(withId(R.id.main_logout_button)).perform(click()); | ||
assertFalse(daoUser.isLoggedIn()); | ||
} | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
...t/java/fr/paris10/projet/assogenda/assogenda/ui/fragment/AssociationMainFragmentTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package fr.paris10.projet.assogenda.assogenda.ui.fragment; | ||
|
||
import org.junit.Test; | ||
|
||
import fr.paris10.projet.assogenda.assogenda.R; | ||
|
||
import static android.support.test.espresso.Espresso.onView; | ||
import static android.support.test.espresso.action.ViewActions.click; | ||
import static android.support.test.espresso.assertion.ViewAssertions.matches; | ||
import static android.support.test.espresso.matcher.ViewMatchers.withId; | ||
import static android.support.test.espresso.matcher.ViewMatchers.withText; | ||
import static org.hamcrest.Matchers.notNullValue; | ||
|
||
public class AssociationMainFragmentTest { | ||
|
||
@Test | ||
public void testCreateAssociationButton() { | ||
|
||
onView(withId(R.id.fragment_association_main_button_create_association)).check(matches(notNullValue() )); | ||
onView(withId(R.id.fragment_association_main_button_create_association)).perform(click()); | ||
onView(withId(R.id.fragment_create_association_name_title)) | ||
.check(matches(withText((R.string.fragment_create_association_name_title)))); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
app/src/main/java/fr/paris10/projet/assogenda/assogenda/daos/DAOAssociation.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package fr.paris10.projet.assogenda.assogenda.daos; | ||
|
||
import fr.paris10.projet.assogenda.assogenda.daos.firebase.DAOFirebaseAssociation; | ||
|
||
public class DAOAssociation { | ||
|
||
private DAOFirebaseAssociation daoFirebaseAssociation; | ||
private static DAOAssociation instance = null; | ||
|
||
public DAOAssociation() { | ||
daoFirebaseAssociation = DAOFirebaseAssociation.getInstance(); | ||
} | ||
|
||
public static DAOAssociation getInstance() { | ||
if(instance == null) { | ||
instance = new DAOAssociation(); | ||
} | ||
return instance; | ||
} | ||
|
||
public void createAssociation(String associationName, String associationUniversity, String associationDescription, String logo) { | ||
daoFirebaseAssociation.createAssociation(associationName, associationUniversity, associationDescription, logo); | ||
} | ||
|
||
public boolean validateAssociationName(String associationName) { | ||
return daoFirebaseAssociation.validateAssociationName(associationName); | ||
} | ||
|
||
public boolean validateAssociationUniversity(String associationUniversity) { | ||
return daoFirebaseAssociation.validateAssociationUniversity(associationUniversity); | ||
} | ||
|
||
public boolean validateAssociationDescription(String associationDescription) { | ||
return daoFirebaseAssociation.validateAssociationDescription(associationDescription); | ||
} | ||
|
||
public boolean validateAssociation(String associationName, String associationUniversity, String associationDescription) { | ||
return daoFirebaseAssociation.validateAssociation(associationName, associationUniversity, associationDescription); | ||
} | ||
} |
49 changes: 49 additions & 0 deletions
49
app/src/main/java/fr/paris10/projet/assogenda/assogenda/daos/DAOUser.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package fr.paris10.projet.assogenda.assogenda.daos; | ||
|
||
import com.google.firebase.auth.FirebaseAuth; | ||
|
||
import fr.paris10.projet.assogenda.assogenda.daos.firebase.DAOFirebaseUser; | ||
import fr.paris10.projet.assogenda.assogenda.model.User; | ||
|
||
public class DAOUser { | ||
private DAOFirebaseUser database; | ||
private static DAOUser instance = null; | ||
|
||
private DAOUser() { | ||
database = DAOFirebaseUser.getInstance(); | ||
} | ||
|
||
public static DAOUser getInstance() { | ||
if (instance == null) | ||
instance = new DAOUser(); | ||
return instance; | ||
} | ||
|
||
public boolean isLoggedIn() { | ||
return database.isLoggedIn(); | ||
} | ||
|
||
public void signOut() { | ||
database.signOut(); | ||
} | ||
|
||
public boolean validateUser(User user, String password) { | ||
return database.validateUser(user, password); | ||
} | ||
|
||
public boolean validateUser(String email, String password, String firstName, String lastName) { | ||
return database.validateUser(email, password, firstName, lastName); | ||
} | ||
|
||
public boolean validateUser(final String email, final String password) { | ||
return database.validateUser(email, password); | ||
} | ||
|
||
public void createUser(String uid, String email, String firstName, String lastName) { | ||
database.createUser(uid, email, firstName, lastName); | ||
} | ||
|
||
public FirebaseAuth getAuth() { | ||
return FirebaseAuth.getInstance(); | ||
} | ||
} |
Oops, something went wrong.