Created
February 2, 2017 06:26
-
-
Save gokman/0a8887fabb9778d4b26888ca00ffe6e5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @RunWith(SpringRunner.class) | |
| @DataJpaTest | |
| @AutoConfigureTestDatabase(replace = AutoConfigureTestDatabase.Replace.NONE) | |
| public class UserRepositoryTests { | |
| @Autowired | |
| private TestEntityManager entityManager; | |
| @Autowired | |
| private UserRepository repository; | |
| @Autowired | |
| SystemUtils systemUtils; | |
| AcilUser user; | |
| @Before | |
| public void init(){ | |
| user = new User(); | |
| user.setId(111); | |
| user.setName("name"); | |
| user.setSurname("surname"); | |
| this.entityManager.persist(user); | |
| } | |
| @Test | |
| public void findByIdShouldReturnUser() throws Exception { | |
| Optional<User> user = this.repository.findOneById(111); | |
| Assert.assertEquals(user.get().getId(), 111); | |
| } | |
| @Test | |
| @Modifying(clearAutomatically = true) | |
| public void updateUserStateShouldReturnNewState() throws Exception { | |
| this.repository.updateUserState(111, UserStatus.ACTIVE.getValue()); | |
| entityManager.refresh(user); | |
| Optional<User> user = this.repository.findOneById(111); | |
| Assert.assertEquals(user.get().getState(), UserStatus.ACTIVE.getValue()); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment