Blame view

src/test/java/fr/plil/sio/web/mvc/UserRepositoryTest.java 993 Bytes
aa193b2b   Julien Iguchi-Cartigny   First version
1
2
  package fr.plil.sio.web.mvc;
  
aa193b2b   Julien Iguchi-Cartigny   First version
3
  import org.junit.Test;
2070653e   Julien Iguchi-Cartigny   Switching to spri...
4
5
6
7
8
  import org.junit.runner.RunWith;
  import org.springframework.boot.test.SpringApplicationConfiguration;
  import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
  import org.springframework.test.context.transaction.TransactionConfiguration;
  import org.springframework.transaction.annotation.Transactional;
aa193b2b   Julien Iguchi-Cartigny   First version
9
  
2070653e   Julien Iguchi-Cartigny   Switching to spri...
10
11
12
13
14
15
16
17
18
  import javax.annotation.Resource;
  
  import static org.junit.Assert.assertEquals;
  import static org.junit.Assert.assertNotNull;
  
  @RunWith(SpringJUnit4ClassRunner.class)
  @SpringApplicationConfiguration(classes = Application.class)
  @Transactional
  @TransactionConfiguration
8efec875   Julien Iguchi-Cartigny   switch to spring ...
19
  public class UserRepositoryTest {
aa193b2b   Julien Iguchi-Cartigny   First version
20
  
2070653e   Julien Iguchi-Cartigny   Switching to spri...
21
      @Resource
8efec875   Julien Iguchi-Cartigny   switch to spring ...
22
      private UserRepository userRepository;
aa193b2b   Julien Iguchi-Cartigny   First version
23
  
aa193b2b   Julien Iguchi-Cartigny   First version
24
25
      @Test
      public void testAdminPresent() {
2070653e   Julien Iguchi-Cartigny   Switching to spri...
26
27
28
          assertEquals(1, userRepository.findAll().size());
          assertNotNull(userRepository.findByUsername("admin"));
          assertEquals("admin", userRepository.findByUsername("admin").getUsername());
aa193b2b   Julien Iguchi-Cartigny   First version
29
30
      }
  }