package com.platform.test;

import java.util.List;

import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;

import com.platform.dao.EncodeInfoDao;
import com.platform.entities.EncodedInfoEntity;

public class TestEncodeInfoDao extends SMBasedTest {

	private EncodeInfoDao eiDao;
	private String testTableName;

	@Before
	public void initBeforeFunction() {
		eiDao = (EncodeInfoDao) this.applicationContext
				.getBean("encodeInfoDao");
		testTableName = "system_info";
	}

	@Test
	public void testGetAllEntityInfo() {
		List<EncodedInfoEntity> allEntities = eiDao
				.getAllEntityInfo(testTableName);
		System.out.println(allEntities);
		Assert.assertTrue(allEntities.size() > 0);
	}

	@Test
	public void testGetEncodeNameByCode() {
		String result = eiDao.getEncodeNameByCode("1", testTableName);
		Assert.assertTrue(result.equals("预算执行系统"));
	}

	@Test
	public void testGetEncodeCodeByName() {
		List<String> result = eiDao
				.getEncodeCodeByName("预算执行系统", testTableName);
		Assert.assertTrue(result.size() > 0);
	}

	@Test
	public void testUpdateEncodeNameByCode() {
		int result = eiDao
				.updateEncodeNameByCode("3", "财政一体化平台", testTableName);
		Assert.assertTrue(result > 0);
	}

	@Test
	public void testInsertEncodeEntity() {
		int result = eiDao.insertEncodeEntity(new EncodedInfoEntity("非税收入系统",
				"4"), testTableName);
		Assert.assertTrue(result == 1);
	}

	@Test
	public void testDeleteEncodeByCode() {
		int result = eiDao.deleteEncodeByCode("5", testTableName);
		Assert.assertTrue(result >= 1);
	}
}
