Skip to content

Instantly share code, notes, and snippets.

@brunodutr
Created March 17, 2019 19:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brunodutr/895611669894ea37a0e851e65adfac6e to your computer and use it in GitHub Desktop.
Save brunodutr/895611669894ea37a0e851e65adfac6e to your computer and use it in GitHub Desktop.
package example.bdutra.it.jpa;
import static org.junit.Assert.assertEquals;
import java.util.List;
import javax.inject.Inject;
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.arquillian.junit.InSequence;
import org.jboss.shrinkwrap.api.Archive;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.spec.JavaArchive;
import org.junit.Test;
import org.junit.runner.RunWith;
import example.bdutra.jpa.person.PersonEntity;
import example.bdutra.jpa.person.PersonRepository;
@RunWith(Arquillian.class)
public class PersonRepositoryIT {
@SuppressWarnings("rawtypes")
@Deployment
public static Archive createDeployment() {
return ShrinkWrap.create(JavaArchive.class)
.addPackages(true, "example.bdutra")
.addAsResource("META-INF/beans.xml")
.addAsResource("META-INF/it-persistence.xml", "META-INF/persistence.xml")
.addAsResource("project-it.yml", "project-defaults.yml");
}
@Inject
private PersonRepository personRepository;
@Test
@InSequence(1)
public void testSavePerson() {
PersonEntity person = new PersonEntity();
person.setName("Bruno");
person.setSurname("Dutra");
personRepository.create(person);
}
@Test
@InSequence(2)
public void testListPersons() {
List<PersonEntity> persons = personRepository.findAll();
assertEquals(persons.size(), 1);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment