Commit 2cb389a34ca4ec3190a676e98687db068e58a3e3
1 parent
e5584575
Exists in
master
Adição de testes
Showing
1 changed file
with
18 additions
and
3 deletions
Show diff stats
impl/extension/jpa/src/test/java/template/JPACrudTest.java
| @@ -4,11 +4,14 @@ import static junit.framework.Assert.assertEquals; | @@ -4,11 +4,14 @@ import static junit.framework.Assert.assertEquals; | ||
| 4 | import static junit.framework.Assert.assertNotNull; | 4 | import static junit.framework.Assert.assertNotNull; |
| 5 | import static junit.framework.Assert.assertNull; | 5 | import static junit.framework.Assert.assertNull; |
| 6 | 6 | ||
| 7 | +import java.util.List; | ||
| 8 | + | ||
| 7 | import javax.inject.Inject; | 9 | import javax.inject.Inject; |
| 8 | 10 | ||
| 9 | import org.jboss.arquillian.container.test.api.Deployment; | 11 | import org.jboss.arquillian.container.test.api.Deployment; |
| 10 | import org.jboss.arquillian.junit.Arquillian; | 12 | import org.jboss.arquillian.junit.Arquillian; |
| 11 | import org.jboss.shrinkwrap.api.spec.WebArchive; | 13 | import org.jboss.shrinkwrap.api.spec.WebArchive; |
| 14 | +import org.junit.Before; | ||
| 12 | import org.junit.Test; | 15 | import org.junit.Test; |
| 13 | import org.junit.runner.RunWith; | 16 | import org.junit.runner.RunWith; |
| 14 | 17 | ||
| @@ -30,9 +33,11 @@ public class JPACrudTest { | @@ -30,9 +33,11 @@ public class JPACrudTest { | ||
| 30 | return deployment; | 33 | return deployment; |
| 31 | } | 34 | } |
| 32 | 35 | ||
| 33 | - @Test | ||
| 34 | - public void x() { | ||
| 35 | - | 36 | + @Before |
| 37 | + public void eraseData() { | ||
| 38 | + for(MyEntity myEntity : crud.findAll()) { | ||
| 39 | + crud.delete(myEntity.getId()); | ||
| 40 | + } | ||
| 36 | } | 41 | } |
| 37 | 42 | ||
| 38 | @Test | 43 | @Test |
| @@ -66,6 +71,16 @@ public class JPACrudTest { | @@ -66,6 +71,16 @@ public class JPACrudTest { | ||
| 66 | assertEquals("update example", persisted.getDescription()); | 71 | assertEquals("update example", persisted.getDescription()); |
| 67 | } | 72 | } |
| 68 | 73 | ||
| 74 | + @Test | ||
| 75 | + public void findAll() { | ||
| 76 | + populate(4, 0); | ||
| 77 | + | ||
| 78 | + List<MyEntity> list; | ||
| 79 | + list = crud.findAll(); | ||
| 80 | + | ||
| 81 | + assertEquals(list.size(), 4); | ||
| 82 | + } | ||
| 83 | + | ||
| 69 | private void populate(int size, int offset) { | 84 | private void populate(int size, int offset) { |
| 70 | MyEntity entity; | 85 | MyEntity entity; |
| 71 | 86 |