use std::sync::Arc;
use chrono::{Local, Utc};
use crate::{database};
use crate::database::TraitRedis;
use crate::rubase::{rutils, BaseEntity, BaseEntitySingle };
use crate::rubase::getself::GetSelf;
use crate::rubase::rudto::cfgdto;
use crate::rubase::rutils::{fileutils, rufile};
use crate::rucfg;
use crate::rudi::difactroy::{difactroy_init, find_bean_difactroy, rumulti, rusingle};
use crate::rudi::ditemplate;
use crate::rudi::ditemplate::parsetemplate;
use crate::rudomain::rudb::dbdao::userdao;
use crate::rulog::rulog;
#[test]
fn test_02_read_rs_test() {
let ret = fileutils::read_file("./tests/rucfg_test.rs");
rulog::info(ret.unwrap().as_str());
}
#[test]
fn test_03_f_factroy() {
let cfg=rucfg::find_bean_ruconfig().unwrap();
let file=cfg.find_base_path() +"/src/rudi/difactroy/difactroy.rs";
let ret = fileutils::read_file(file.as_str());
rulog::info(ret.unwrap().as_str());
}
#[test]
fn test_04_f_factroy() {
let cfg = rucfg::find_bean_ruconfig().unwrap();
println!("{}", cfg.config.lock().unwrap().software.logLevel);
}
#[test]
fn test_06_rusingle() {
let rs = rusingle::find_bean_rusingle().unwrap();
let ret = rs.execute();
crate::rulog::info(ret.as_str());
}
#[test]
fn test_08_factroy() {
let ret = fileutils::read_file("./src/rudi/difactroy/rusingle/rusingle.rs");
rulog::info(ret.unwrap().as_str());
}
#[test]
fn test_10_build_single_name() {
let pt = ditemplate::find_bean_parsetemplate().unwrap();
let template = pt.build_single_name("RuSingle");
rulog::info(template.as_str());
}
#[test]
fn test_11_parse_all_files() {
let di_factroy = find_bean_difactroy().unwrap() ;
di_factroy.parse_all_files("./src");
for stru in di_factroy.structs.lock().unwrap().iter() {
rulog::info2("struct file:===", stru.to_json().as_str());
}
}
#[test]
fn test_12_find_dirs() {
let files = fileutils::find_dir("./src", "ruenc");
for file in files {
rulog::info2("find_dirs:", file.to_str().unwrap());
}
}
#[test]
fn test_15_find_dirs() {
let files = fileutils::find_dir("C:\\Users\\leijmdas\\.cargo\\registry\\src", "rudi-0.8.3");
for file in files {
rulog::info2("find_dirs:", file.to_str().unwrap());
}
}
#[test]
fn test_16_parse_template_file() {
let template = parsetemplate::ParseTemplate::parse_template_file();
rulog::info2("parse_template_file:\r\n", template.as_str());
}
#[test]
fn test_19_parse_all_files() {
let diFacty = difactroy_init::find_bean_difactroy().unwrap();
diFacty.parse_all_files("./src");
diFacty.fill_template();
for stru in diFacty.get_structs().iter() {
rulog::info2("struct file:===", stru.to_json().as_str());
}
rulog::info2(diFacty.get_structs().len(),diFacty.get_self().notShowExist);
rulog::info2(diFacty.get_self().notShowExist,diFacty.get_template());
}
#[test]
fn test_20() {
let redisdb = database::find_bean_redisclient().unwrap().get_self();
rulog::info2("redisdb:\r\n", redisdb);
}
#[test]
fn test_21_write_filemake_di_all() {
let ret = fileutils::write_file("e:/opt/1.txt", "dd");
println!("{:?}", ret);
assert!(ret.is_ok());
assert!(fileutils::check_file_exist(&"e:/opt/1.txt".to_string()));
}
#[test]
fn test_22_make_di_one() {
let diFacty = difactroy_init::find_bean_difactroy().unwrap();
let ret = diFacty.make_di_one_dir("./src", "UsersDao");
println!("{:?}", ret);
}
#[test]
fn test_24_make_di_one() {
let diFacty = difactroy_init::find_bean_difactroy().unwrap();
let ret = diFacty.make_di_one_dir("./src", "RedisClient");
println!("{:?}", ret);
}
#[test]
fn test_25_make_di_one() {
let dao = userdao::find_bean_userdao().unwrap();
let ret = dao.execute();
println!("{:?}", ret);
}
#[test]
fn test_26_make_di_force() {
let diFacty = difactroy_init::find_bean_difactroy().unwrap();
}
#[test]
fn test_29_make_di () {
let diFacty = difactroy_init::find_bean_difactroy().unwrap();
diFacty.make_di ( );
}
#[test]
fn test_31_list_date_format () {
pub fn local_now2str_rfc3339() -> String {
Local::now().format("%Y-%m-%dT%H:%M:%S%z").to_string()
}
pub fn utc_now2str_rfc3339() -> String {
Utc::now().format("%Y-%m-%dT%H:%M:%S%z").to_string()
}
println!("{}", local_now2str_rfc3339());
println!("{}", utc_now2str_rfc3339());
}
#[test]
fn test_32_list_di () {
let dr=rutils::find_bean_daterange().unwrap();
rulog::info(dr.to_json().as_str());
}
#[test]
fn test_33_single_case() {
let bean1=find_bean_difactroy().unwrap();
let bean2=find_bean_difactroy().unwrap();
let addr1 = Arc::as_ptr(&bean1);
let addr2 = Arc::as_ptr(&bean2);
println!("DiFactroy 地址: {:p} {:p}",addr1, addr2);
assert_eq!(addr1,addr2);
println!("bean1=bean2 ? {:?}",addr1==addr2);
}
#[test]
fn test_34_multi_case() {
let bean1=cfgdto::find_bean_gorm().unwrap();
let bean2= cfgdto::find_bean_gorm() .unwrap();
let addr1 = Arc::as_ptr(&bean1);
let addr2 = Arc::as_ptr(&bean2);
println!("DiFactroy 地址: {:p} {:p}",addr1, addr2);
assert_ne!(addr1,addr2);
println!("bean1!=bean2 ? {:?}",addr1!=addr2);
}
#[test]
fn test_35_list_di () {
let diFacty = difactroy_init::find_bean_difactroy().unwrap();
diFacty.list_di ( );
}