forked from boillodmanuel/material-contacts-apispark
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from francoisadam/Issue#2_Unit_Test
Created JUnit tests for contacts
- Loading branch information
Showing
1 changed file
with
28 additions
and
0 deletions.
There are no files selected for viewing
28 changes: 28 additions & 0 deletions
28
src/test/java/net/apispark/webapi/ContactPersistenceTest.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,28 @@ | ||
package net.apispark.webapi; | ||
|
||
import org.junit.Assert; | ||
import org.junit.Test; | ||
|
||
import net.apispark.webapi.db.ContactPersistence; | ||
import net.apispark.webapi.representation.Contact; | ||
|
||
public class ContactPersistenceTest { | ||
@Test | ||
public void addContactTest() throws Exception { | ||
ContactPersistence contactPersistence = new ContactPersistence(); | ||
Contact contact = new Contact(); | ||
Contact createdContact = contactPersistence.addContact(contact); | ||
Assert.assertNotNull(createdContact.getId()); | ||
Assert.assertEquals(createdContact, contact); | ||
} | ||
|
||
@Test | ||
public void requestNewContactTest() throws Exception { | ||
ContactPersistence contactPersistence = new ContactPersistence(); | ||
Contact contact = new Contact(); | ||
Contact createdContact = contactPersistence.addContact(contact); | ||
Assert.assertEquals(contactPersistence.getContact(createdContact.getId()), createdContact); | ||
} | ||
|
||
|
||
} |