|
|
|
@ -6,7 +6,6 @@ import com.fr.invoke.Reflect;
|
|
|
|
|
import com.fr.json.JSON; |
|
|
|
|
import com.fr.json.JSONArray; |
|
|
|
|
import com.fr.json.JSONFactory; |
|
|
|
|
import com.fr.json.JSONObject; |
|
|
|
|
import com.fr.stable.ProductConstants; |
|
|
|
|
import com.fr.stable.StringUtils; |
|
|
|
|
import com.fr.third.org.apache.commons.io.FileUtils; |
|
|
|
@ -18,6 +17,7 @@ import org.junit.Test;
|
|
|
|
|
import org.junit.runner.RunWith; |
|
|
|
|
import org.powermock.api.easymock.PowerMock; |
|
|
|
|
import org.powermock.core.classloader.annotations.PrepareForTest; |
|
|
|
|
import org.powermock.core.classloader.annotations.SuppressStaticInitializationFor; |
|
|
|
|
import org.powermock.modules.junit4.PowerMockRunner; |
|
|
|
|
|
|
|
|
|
import java.io.File; |
|
|
|
@ -34,6 +34,7 @@ import static org.junit.Assert.assertTrue;
|
|
|
|
|
*/ |
|
|
|
|
@RunWith(PowerMockRunner.class) |
|
|
|
|
@PrepareForTest({ProductConstants.class, MarketConfig.class, DesignerEnvManager.class}) |
|
|
|
|
@SuppressStaticInitializationFor({"com.fr.jvm.assist.FineAssist"}) |
|
|
|
|
public class TemplateInfoCollectorTest { |
|
|
|
|
private String filePath; |
|
|
|
|
private String initialFileContent; |
|
|
|
@ -58,6 +59,7 @@ public class TemplateInfoCollectorTest {
|
|
|
|
|
EasyMock.expect(mockProcessInfo.useParaPane()).andReturn(false).anyTimes(); |
|
|
|
|
EasyMock.expect(mockProcessInfo.getComponentsInfo()).andReturn(new JSONArray()).anyTimes(); |
|
|
|
|
EasyMock.expect(mockProcessInfo.isTestTemplate()).andReturn(true).anyTimes(); |
|
|
|
|
EasyMock.expect(mockProcessInfo.getReuseCmpList()).andReturn(JSONArray.create().add("reuse-id-1")).anyTimes(); |
|
|
|
|
EasyMock.replay(mockProcessInfo); |
|
|
|
|
|
|
|
|
|
// 缓存 tpl.info
|
|
|
|
@ -102,7 +104,8 @@ public class TemplateInfoCollectorTest {
|
|
|
|
|
|
|
|
|
|
assertJsonStringEquals("{\"process\":\"\",\"float_count\":1,\"widget_count\":0," + |
|
|
|
|
"\"cell_count\":13,\"paraApply\":0,\"block_count\":3,\"report_type\":0,\"components_info\":\"[]\"," + |
|
|
|
|
"\"templateID\":\"e5d7dbb2-d1df-43d4-b974-67acb5ecbffa\"}", |
|
|
|
|
"\"templateID\":\"e5d7dbb2-d1df-43d4-b974-67acb5ecbffa\",\"reuseCmptList\":\"[\\\"reuse-id-1\\\"]\"" + |
|
|
|
|
"}", |
|
|
|
|
JSONFactory.createJSON(JSON.OBJECT, processMap).toString()); |
|
|
|
|
|
|
|
|
|
Assert.assertEquals(71113, consumingMap.get("uid")); |
|
|
|
@ -133,7 +136,8 @@ public class TemplateInfoCollectorTest {
|
|
|
|
|
|
|
|
|
|
assertJsonStringEquals("{\"process\":\"\",\"float_count\":1,\"widget_count\":0," + |
|
|
|
|
"\"cell_count\":13,\"paraApply\":0,\"block_count\":3,\"report_type\":0,\"components_info\":\"[]\"," + |
|
|
|
|
"\"templateID\":\"e5d7dbb2-d1df-43d4-b974-67acb5ecbffa\"}", JSONFactory.createJSON(JSON.OBJECT, processMap).toString()); |
|
|
|
|
"\"templateID\":\"e5d7dbb2-d1df-43d4-b974-67acb5ecbffa\",\"reuseCmptList\":\"[\\\"reuse-id-1\\\"]\"" + |
|
|
|
|
"}", JSONFactory.createJSON(JSON.OBJECT, processMap).toString()); |
|
|
|
|
|
|
|
|
|
Map<String, Object> consumingMap = Reflect.on(templateInfo).field("consumingMap").get(); |
|
|
|
|
Assert.assertEquals(71113, consumingMap.get("uid")); |
|
|
|
@ -159,9 +163,10 @@ public class TemplateInfoCollectorTest {
|
|
|
|
|
TemplateInfo templateInfo = getTemplateInfoByID(templateID); |
|
|
|
|
Map processMap = Reflect.on(templateInfo).field("processMap").get(); |
|
|
|
|
|
|
|
|
|
assertJsonStringEquals("{\"process\":\"\",\"float_count\":1,\"widget_count\":0,\"cell_count\":13," + |
|
|
|
|
"\"paraApply\":0,\"block_count\":3,\"report_type\":0,\"components_info\":\"[]\"," + |
|
|
|
|
"\"templateID\":\"e5d7dbb2-d1df-43d4-b974-67acb5ecbffa\"}", JSONFactory.createJSON(JSON.OBJECT, processMap).toString()); |
|
|
|
|
assertJsonStringEquals("{\"process\":\"\",\"float_count\":1,\"widget_count\":0," + |
|
|
|
|
"\"cell_count\":13,\"paraApply\":0,\"block_count\":3,\"report_type\":0,\"components_info\":\"[]\"," + |
|
|
|
|
"\"templateID\":\"e5d7dbb2-d1df-43d4-b974-67acb5ecbffa\",\"reuseCmptList\":\"[\\\"reuse-id-1\\\"]\"" + |
|
|
|
|
"}", JSONFactory.createJSON(JSON.OBJECT, processMap).toString()); |
|
|
|
|
|
|
|
|
|
Map<String, Object> consumingMap = Reflect.on(templateInfo).field("consumingMap").get(); |
|
|
|
|
Assert.assertEquals(71113, consumingMap.get("uid")); |
|
|
|
|