Blame view

src/test/java/fr/plil/sio/web/mvc/UserServiceTest.java 798 Bytes
3c085ac4   Julien Iguchi-Cartigny   Support for mockM...
1
2
3
4
  package fr.plil.sio.web.mvc;
  
  import org.junit.Test;
  import org.junit.runner.RunWith;
88ff471f   Julien Cartigny   Switching to spri...
5
  import org.springframework.boot.test.context.SpringBootTest;
3c085ac4   Julien Iguchi-Cartigny   Support for mockM...
6
  import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
3c085ac4   Julien Iguchi-Cartigny   Support for mockM...
7
8
9
10
11
12
13
  import org.springframework.transaction.annotation.Transactional;
  
  import javax.annotation.Resource;
  
  import static org.junit.Assert.assertEquals;
  
  @RunWith(SpringJUnit4ClassRunner.class)
88ff471f   Julien Cartigny   Switching to spri...
14
  @SpringBootTest(classes = Application.class)
3c085ac4   Julien Iguchi-Cartigny   Support for mockM...
15
  @Transactional
3c085ac4   Julien Iguchi-Cartigny   Support for mockM...
16
17
18
19
20
21
22
23
24
25
26
  public class UserServiceTest {
  
      @Resource
      private UserService userService;
  
      @Resource
      private UserRepository userRepository;
  
      @Test
      public void testCreateUser() {
          userService.createUser("blabla", "polo");
ed4910db   Julien Cartigny   Fixing tests
27
          assertEquals("blabla", userRepository.findByUsername("blabla").getUsername());
3c085ac4   Julien Iguchi-Cartigny   Support for mockM...
28
29
      }
  }