import com.izouma.awesomeadmin.model.SysMenu;
import com.izouma.awesomeadmin.service.SysMenuService;
import com.izouma.awesomeadmin.service.UserInfoService;
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.support.GenericXmlContextLoader;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@RunWith(value = SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = {"classpath:/spring/applicationContext.xml"}, loader = GenericXmlContextLoader.class)
@Transactional
public class MenuTest {
    @Autowired
    private SysMenuService sysMenuService;

    @Test
    public void testGetMenuTree() {
        long start, end;

        start = System.currentTimeMillis();
        sysMenuService.getMenuTree();
        end = System.currentTimeMillis();
        System.out.println("getall:" + (end - start));

        start = System.currentTimeMillis();
        sysMenuService.getMenuTree(84664);
        end = System.currentTimeMillis();
        System.out.println("getuser:" + (end - start));

        start = System.currentTimeMillis();
        sysMenuService.getMenuTree(true, null);
        end = System.currentTimeMillis();
        System.out.println("getallorigin:" + (end - start));

        start = System.currentTimeMillis();
        sysMenuService.getMenuTree(false, 84664);
        end = System.currentTimeMillis();
        System.out.println("getuserorigin:" + (end - start));
    }

    @Test
    public void testClone() {
        SysMenu menu1 = new SysMenu();
        menu1.setName("aaa");
        SysMenu menu2 = menu1.clone();
        menu1.setName("bbb");
        System.out.println(menu1.getName());
        System.out.println(menu2.getName());
    }
}
