package com.quantgroup.asset.distribution.rule;

import java.util.HashMap;
import java.util.Map;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

import com.alibaba.fastjson.JSON;
import com.quantgroup.asset.distribution.AssetDistributionBootstrap;
import com.quantgroup.asset.distribution.service.rule.IRuleService;
import com.quantgroup.asset.distribution.util.calc.Expression;

@SpringBootTest(classes = AssetDistributionBootstrap.class)
@RunWith(SpringRunner.class)
public class RuleValidTest {
	
	@Autowired
	private IRuleService ruleService;
	
	@Test
	public void testRuleValid() {
//		Map<String, Object> data = JSON.parseObject("{\"asset_no\":\"ASETb98eb77a9b0241c88b21c50e6ca18ed2\",\"biz_channel\":\"159843\",\"finance_product_type\":0,\"biz_no\":\"SP502357594925728441767462\",\"user_loan_type_latest\":0,\"batchUuid\":\"bcc35b09-fc7f-4dd3-957a-1c1d25c5bd36\",\"audit_result\":0,\"uuid\":\"b3cfb485-f4a1-4749-8ed0-d5ecc6cc5dd2\",\"user_loan_type\":0}");
		Map<String, Object> data = JSON.parseObject("{\"asset_no\":\"ASET669cfdc1e8064ae6ade6332bd2dc5baf\",\"biz_channel\":\"214\",\"finance_product_type\":0,\"biz_no\":\"SP499997499085250626417877\",\"user_loan_type_latest\":1,\"batchUuid\":\"19b1bdcc-103b-425c-af26-fe91fc0a9699\",\"audit_result\":true,\"uuid\":\"8e7437904897429e82e52082e1537631\",\"user_loan_type\":1}");
//		Map<String, Object> data = JSON.parseObject("{\"asset_no\":\"ASET669cfdc1e8064ae6ade6332bd2dc5baf\",\"biz_channel\":\"214\",\"finance_product_type\":0,\"biz_no\":\"SP499997499085250626417877\",\"user_loan_type_latest\":1,\"batchUuid\":\"19b1bdcc-103b-425c-af26-fe91fc0a9699\",\"audit_result\":0,\"uuid\":\"2c748ad2-4c9a-4bbe-80e9-267206d8e895\",\"user_loan_type\":1}");
//		data.put("audit_result", 0);
		System.out.println(ruleService.valid("audit_result=true||audit_result=false", data));
	}
	
	public static void main(String[] args) {
//		System.out.println(Expression.isNumber("677e1245-4e58-4979-8794-39e728e84248"));
	}
}
