Add UserRepository test
This commit is contained in:
@@ -1,37 +1,24 @@
|
|||||||
//package greenify.server.data.repository;
|
package greenify.server.data.repository;
|
||||||
//
|
|
||||||
//import greenify.server.data.model.User;
|
import static org.junit.Assert.assertEquals;
|
||||||
//import org.junit.Test;
|
|
||||||
//import org.junit.runner.RunWith;
|
import greenify.server.data.model.User;
|
||||||
//import org.springframework.beans.factory.annotation.Autowired;
|
import org.junit.Test;
|
||||||
//import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest;
|
import org.junit.runner.RunWith;
|
||||||
//import org.springframework.boot.test.autoconfigure.orm.jpa.TestEntityManager;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
//import org.springframework.test.context.junit4.SpringRunner;
|
import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest;
|
||||||
//
|
import org.springframework.test.context.junit4.SpringRunner;
|
||||||
//import static junit.framework.TestCase.assertTrue;
|
|
||||||
//import static org.junit.Assert.assertEquals;
|
@RunWith(SpringRunner.class)
|
||||||
//
|
@DataJpaTest
|
||||||
//@RunWith(SpringRunner.class)
|
public class UserRepositoryTest {
|
||||||
//@DataJpaTest
|
@Autowired
|
||||||
//public class UserRepositoryTest {
|
private UserRepository repository;
|
||||||
//
|
|
||||||
// @Autowired
|
@Test
|
||||||
// private TestEntityManager entityManager;
|
public void findByUsernameTest() throws Exception {
|
||||||
//
|
repository.save(new User(296L, "cugurlu", "password", 6));
|
||||||
// @Autowired
|
User user = this.repository.findByName("cugurlu");
|
||||||
// private UserRepository repository;
|
assertEquals(user.getName(), "cugurlu");
|
||||||
//
|
}
|
||||||
// @Test
|
}
|
||||||
// public void findByUsernameShouldReturnUser() throws Exception {
|
|
||||||
// this.entityManager.persist(new User(296L, "cugurlu", "password", 6));
|
|
||||||
// User user = this.repository.findByName("cugurlu");
|
|
||||||
// assertEquals(user.getName(), "cugurlu");
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Test
|
|
||||||
// public void findByUsernameWhenNoUserShouldReturnNull() throws Exception {
|
|
||||||
// this.entityManager.persist(new User(296L, "cugurlu", "password", 6));
|
|
||||||
// User user = this.repository.findByName("mouse");
|
|
||||||
// assertTrue(user == null);
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
|
|||||||
Reference in New Issue
Block a user