package xyz.acmer.database;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.web.WebAppConfiguration;
import xyz.acmer.dao.IUserDao;
import xyz.acmer.entity.user.User;

/**
 * Created by hypo on 16-2-18.
 */
@RunWith(SpringJUnit4ClassRunner.class)
@WebAppConfiguration
@ContextConfiguration({"classpath*:spring.xml"})
public class UserDaoTest {

    private User user;

    @Autowired
    private IUserDao dao;

    @Before
    public void getUser(){
        user = new User("asd", "asd", "asd@123.net", "123");
    }

    @After
    public void print(){
        System.out.println(user.getUserId());
    }

    @Test
    public void save(){
        dao.save(user);
    }

}

@@ -456,16 +456,40 @@
 .User;%0A%0A
+import java.util.List;%0A%0A
 /**%0A * C
@@ -661,32 +661,8 @@
  %7B%0A%0A
-    private User user;%0A%0A
     
@@ -704,22 +704,20 @@
 ;%0A%0A    @
-Before
+Test
 %0A    pub
@@ -725,23 +725,20 @@
 ic void 
-getUser
+save
 ()%7B%0A    
@@ -741,16 +741,21 @@
         
+User 
 user = n
@@ -767,41 +767,113 @@
 er(%22
-asd%22, %22asd%22, %22asd@123.net%22, %22123%22
+hypo%22, %22hypo%22, %22i@ihypo.net%22, %22123%22);%0A        dao.save(user);%0A        System.out.println(user.getUserId()
 );%0A 
@@ -883,21 +883,20 @@
 %7D%0A%0A    @
-After
+Test
 %0A    pub
@@ -908,58 +908,416 @@
 oid 
-print()%7B%0A        System.out.println(user.getUserId
+getUserById()%7B%0A%0A        User user = dao.get(3L);%0A%0A        System.out.println(user.getNickName());%0A    %7D%0A%0A    @Test%0A    public void getUserByUsername()%7B%0A%0A        User user = dao.getUserByUsername(%22hypo%22);%0A%0A        System.out.println(user.getNickName());%0A    %7D%0A%0A    @Test%0A    public void getUserByUserEmail()%7B%0A%0A        User user = dao.getUserByEmail(%22i@ihypo.net%22);%0A%0A        System.out.println(user.getNickName
 ());
@@ -1350,32 +1350,40 @@
 ic void 
-save
+getAllUsers
 ()%7B%0A
+%0A
         
 dao.save
@@ -1378,29 +1378,167 @@
     
-dao.save(user);%0A    %7D%0A
+List%3CUser%3E list = dao.getAllUser();%0A%0A        for(User user: list)%7B%0A            System.out.println(user.getUserId() + %22%5Ct%22 + user.getUserName());%0A        %7D%0A    %7D
 %0A%7D%0A

update test