package fr.plil.sio.examen; import fr.plil.sio.examen.api.Animal; import fr.plil.sio.examen.api.Owner; import fr.plil.sio.examen.repositories.AnimalRepository; import fr.plil.sio.examen.repositories.OwnerRepository; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.transaction.annotation.Transactional; @RunWith(SpringJUnit4ClassRunner.class) @SpringBootTest @Transactional public class AnimalRepositoryTest { @Autowired private AnimalRepository animalRepository; @Autowired private OwnerRepository ownerRepository; @Test public void testSimpleOperations() { Owner owner = new Owner(); owner.setName("mickey"); ownerRepository.save(owner); Animal animal = new Animal(); animal.setName("pluto"); animal.setOwner(owner); owner.getAnimals().add(animal); animalRepository.save(animal); } }