package com.changhong.epc.admin; import com.changhong.epc.admin.service.mq.AutoFormConsumer; import com.changhong.epc.constter.base.BaseConst; import com.changhong.epc.constter.base.Context; import com.iemsoft.framework.cloud.core.thread.ThreadData; import com.iemsoft.framework.cloud.core.tools.JSONTool; import com.iemsoft.framework.cloud.core.tools.ObjectUtil; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.data.redis.connection.Message; import org.springframework.test.context.junit4.SpringRunner; import org.springframework.ui.ModelMap; //@RunWith(SpringRunner.class) //@SpringBootTest(classes={AdminApplication.class}) public class AutoFormTest implements BaseConst { // {tenantID=100000001, formID=Ug12TTbi, id=4, field=number_expend, fieldKey=Rt, fieldSize=8} // @Test public void test(){ ThreadData.set(TENANT_ID, "100000001"); ThreadData.set(COMPANY_ID, 7); TestAutoFormConsumer test = new TestAutoFormConsumer(); test.onMessage(new Message(){ @Override public byte[] getBody() { return ObjectUtil.objectToByte( Context.getMQParam( new ModelMap("tenantID", 100000001) .addAttribute("formID", "Ug12TTbi") .addAttribute("id", "4") .addAttribute("field", "number_expend") .addAttribute("fieldKey", "Rt") .addAttribute("fieldSize", "8") ) ); } @Override public byte[] getChannel() { return new byte[0]; } }, new byte[0]); } class TestAutoFormConsumer extends AutoFormConsumer { @Override public Object getFromRest(String fs, Object parm) { System.out.println(fs); System.out.println(JSONTool.toJson(parm)); return null; } } }