/**
 * 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.core.test;

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

import com.crunii.micro.common.dto.PageReq;
import com.crunii.micro.core.dto.CacheRefreshC;
import com.crunii.micro.core.dto.CacheRefreshQ;
import com.crunii.micro.core.dto.CacheRefreshU;
import com.crunii.micro.core.service.CacheRefreshService;

/**
 * @author 田平 create 2020年4月26日下午3:47:18
 *
 */
public class CacheRefreshServiceTest extends BaseTestCore {

	@Autowired
	private CacheRefreshService cacheRefreshService;

	@Test
	public void testPage() {
		PageReq<CacheRefreshQ> pageReq = new PageReq<CacheRefreshQ>();
		CacheRefreshQ cacheRefreshQ = new CacheRefreshQ();
		pageReq.setQuery(cacheRefreshQ);
		pageReq.setPageSize(1);
		cacheRefreshService.pageCacheRefresh(pageReq).getResult().forEach(System.out::println);
	}

	@Test
	@Rollback(false)
	public void testDelete() {
		int refreshId = 10013;
		cacheRefreshService.deleteCacheRefresh(refreshId);
	}

	// @Test
	@Rollback(false)
	public void testUpdate() {
		int refreshId = 10000;
		CacheRefreshU cacheRefreshU = new CacheRefreshU();
		cacheRefreshU.setRefreshId(refreshId);
		cacheRefreshU.setRefreshName("缓存刷新测试1-update");
		cacheRefreshU.setGroupName("workflow");
		cacheRefreshU.setRefreshUrl("/workflow/wf-test/XXController");
		cacheRefreshU.setAppName("wf-test");
		cacheRefreshService.updateCacheRefresh(cacheRefreshU);
		System.out.println(cacheRefreshService.getTCacheRefresh(refreshId));
	}

	// @Test
	@Rollback(false)
	public void testCreate() {
		CacheRefreshC cacheRefreshC = new CacheRefreshC();
		cacheRefreshC.setAppName("wf-test");
		cacheRefreshC.setGroupName("workflow");
		cacheRefreshC.setRefreshName("缓存刷新测试1");
		cacheRefreshC.setRefreshUrl("/workflow/wf-test/XXController");

		CacheRefreshC cacheRefreshC1 = new CacheRefreshC();
		cacheRefreshC1.setAppName("wf-test1");
		cacheRefreshC1.setGroupName("workflow");
		cacheRefreshC1.setRefreshName("缓存刷新测试1");
		cacheRefreshC1.setRefreshUrl("/workflow/wf-test-1/XXController");

		CacheRefreshC cacheRefreshC2 = new CacheRefreshC();
		cacheRefreshC2.setAppName("wf-test2");
		cacheRefreshC2.setGroupName("workflow");
		cacheRefreshC2.setRefreshName("缓存刷新测试1");
		cacheRefreshC2.setRefreshUrl("/workflow/wf-test-2/XXController");

		cacheRefreshService.createCacheRefresh(cacheRefreshC);
		cacheRefreshService.createCacheRefresh(cacheRefreshC1);
		cacheRefreshService.createCacheRefresh(cacheRefreshC2);
	}
}
