/**
 * Copyright 2008-2009. Chongqing Communications Industry Services Co.,Ltd Information Technology Branch. All rights reserved. <a>http://www.crunii.com</a>
 */
package com.crunii.micro.api.test;

import java.util.Arrays;

import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.annotation.Commit;

import com.crunii.micro.common.dto.PageReq;
import com.crunii.micro.service.sysmgr.dto.sysmgr.UrlC;
import com.crunii.micro.service.sysmgr.dto.sysmgr.UrlGroupC;
import com.crunii.micro.service.sysmgr.dto.sysmgr.UrlGroupRelaUrl;
import com.crunii.micro.service.sysmgr.dto.sysmgr.UrlGroupReq;
import com.crunii.micro.service.sysmgr.dto.sysmgr.UrlGroupU;
import com.crunii.micro.service.sysmgr.dto.sysmgr.UrlReq;
import com.crunii.micro.service.sysmgr.dto.sysmgr.UrlU;
import com.crunii.micro.service.sysmgr.service.UrlService;

/**
 * @author 田平 create 2019年5月29日下午2:48:51
 */
public class UrlServiceTest extends SysmgrBaseTest {
	@Autowired
	private UrlService urlService;

	//@Test
	public void testPage() {
		PageReq<UrlReq> pr = new PageReq<UrlReq>();
		UrlReq urlReq = new UrlReq();
		//urlReq.setUrlName("t");
		pr.setQuery(urlReq);
		urlService.pageUrl(pr).getResult().forEach(System.out::println);
	}

	@Test
	@Commit
	public void testCreateUrl() {
		UrlC urlC = new UrlC();
		urlC.setUrlDesc("中国");
		urlC.setUrlName("测试");
		urlC.setUrlPath("/api/sysmgr/AuthControllerTest");
		urlService.createUrl(urlC);
	}

	// @Test
	@Commit
	public void testUpdateUrl() {
		UrlU urlU = new UrlU();
		urlU.setUrlId(10001);
		urlU.setUrlDesc("中国更新");
		urlU.setUrlName("测试更新");
		urlU.setUrlType(2);
		urlU.setState(1);
		urlU.setUrlPath("/api/sysmgr/AuthController/abc");
		urlService.updateUrl(urlU);
	}

	// @Test
	@Commit
	public void testCreateUrlGroup() {
		UrlGroupC urlGroupC = new UrlGroupC();
		urlGroupC.setGroupDesc("测试");
		urlGroupC.setGroupName("testgroup");
		urlService.createUrlGroup(urlGroupC);
	}

	// @Test
	@Commit
	public void testUpdateUrlGroup() {
		UrlGroupU groupU = new UrlGroupU();
		groupU.setGroupId(10000);
		groupU.setGroupName("testgroup更新");
		groupU.setGroupDesc("更新desc");
		groupU.setState(0);
		urlService.updateUrlGroup(groupU);
	}

	// @Test
	@Commit
	public void testPageUrlGroup() {
		PageReq<UrlGroupReq> pr = new PageReq<UrlGroupReq>();
		UrlGroupReq groupReq = new UrlGroupReq();
		groupReq.setGroupName("testgroup");
		pr.setQuery(groupReq);
		urlService.pageUrlGroup(pr).getResult().forEach(System.out::println);
	}

	//@Test
	@Commit
	public void testdoUrlGroupRelaUrl() {
		UrlGroupRelaUrl relaUrl = new UrlGroupRelaUrl();
		relaUrl.setGroupId(10000);
		relaUrl.setUrlIds(Arrays.asList(10000,10001));
		urlService.doUrlGroupRelaUrl(relaUrl);
	}

	//@Test
	public void testgetCheckedUrlGroupUrl() {
		urlService.getCheckedUrlGroupUrl(10000).stream().forEach(System.out::println);
	}
}
