589e1ad3
jcartign
First version
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
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);
}
}
|