<%
var parentPkgName=GetGParamValue('EZGEN_ROOT_PKGNAME'); //上级包名
if(!parentPkgName)parentPkgName='com.ruoyi.project';

var tb=curTable; //当前表
var ClsName=AutoCapProc(tb.name,'ClassName'); //类名（驼峰命名，首字母大写）
var tbName=AutoCapProc(tb.name,'FieldName'); //字段名（驼峰命名，首字母小写）
var dispName=tb.UIDisplayName; //逻辑显示名
var pkField="id"; //主键
var idValExp="id";
if(tb.getPrimaryKeyField()){
  pkField=AutoCapProc(tb.getPrimaryKeyField().name,'FieldName');
  if(tb.getPrimaryKeyField().dataType=='cfdtString')
    idValExp="Integer.toString(id)";
}
%>package ${parentPkgName}.${AutoCapProc(curModel.name,'JavaPackageName')}.${AutoCapProc(tb.name,'JavaPackageName')};

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;

import java.util.Arrays;
import java.util.Date;
import java.util.List;

import ${parentPkgName}.${AutoCapProc(curModel.name,'JavaPackageName')}.${AutoCapProc(tb.name,'JavaPackageName')}.domain.${ClsName};
import ${parentPkgName}.${AutoCapProc(curModel.name,'JavaPackageName')}.${AutoCapProc(tb.name,'JavaPackageName')}.service.I${ClsName}Service;
import ${parentPkgName}.${AutoCapProc(curModel.name,'JavaPackageName')}.${AutoCapProc(tb.name,'JavaPackageName')}.controller.${ClsName}Controller;

@SpringBootTest
public class ${ClsName}InitTest {

    protected Log logger= LogFactory.getLog(${ClsName}InitTest.class);

    @Autowired
    private I${ClsName}Service ${tbName}Service;

    @Autowired
    private ${ClsName}Controller ${tbName}Controller;

    public void wLog(String msg){
        logger.info(msg);
    }

    @Test
    public void testInit() throws Exception {
        wLog("initing database for ${ClsName}...");
        long startTime = System.currentTimeMillis();

        try{
          ${tbName}Service.initDb();
        }catch(Throwable ex){
          ex.printStackTrace();
        }

        long endTime = System.currentTimeMillis();
        wLog("${ClsName} inited successfully in " + (endTime - startTime) + " ms");
    }

}