Skip to content

Commit 97d5c5d

Browse files
authored
Merge pull request #3 from francoisadam/Issue#2_Unit_Test
Created JUnit tests for contacts
2 parents e06ede2 + 6bc753c commit 97d5c5d

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package net.apispark.webapi;
2+
3+
import org.junit.Assert;
4+
import org.junit.Test;
5+
6+
import net.apispark.webapi.db.ContactPersistence;
7+
import net.apispark.webapi.representation.Contact;
8+
9+
public class ContactPersistenceTest {
10+
@Test
11+
public void addContactTest() throws Exception {
12+
ContactPersistence contactPersistence = new ContactPersistence();
13+
Contact contact = new Contact();
14+
Contact createdContact = contactPersistence.addContact(contact);
15+
Assert.assertNotNull(createdContact.getId());
16+
Assert.assertEquals(createdContact, contact);
17+
}
18+
19+
@Test
20+
public void requestNewContactTest() throws Exception {
21+
ContactPersistence contactPersistence = new ContactPersistence();
22+
Contact contact = new Contact();
23+
Contact createdContact = contactPersistence.addContact(contact);
24+
Assert.assertEquals(contactPersistence.getContact(createdContact.getId()), createdContact);
25+
}
26+
27+
28+
}

0 commit comments

Comments
 (0)