Search in sources :

Example 6 with UploadPluginMeta

use of com.qlangtech.tis.util.UploadPluginMeta in project tis by qlangtech.

the class TestSuFormProperties method testVisitSubForm.

public void testVisitSubForm() {
    SubFieldContainPlugin plugin = new SubFieldContainPlugin();
    String pluginName = "test_plugin";
    // dataxName_" + dataXName
    UploadPluginMeta pluginMeta = UploadPluginMeta.parse(pluginName + ":require," + DataxUtils.DATAX_NAME + "_" + dataXName);
    IPropertyType.SubFormFilter subFormFilter = new IPropertyType.SubFormFilter(pluginMeta, SubFieldContainPlugin.PLUGIN_NAME, SubFieldContainPlugin.SUB_PROP_FIELD_NAME);
    Descriptor<SubFieldContainPlugin> descriptor = plugin.getDescriptor();
    assertNotNull("descriptor can not be null", descriptor);
    PluginFormProperties pluginFormPropertyTypes = descriptor.getPluginFormPropertyTypes(Optional.of(subFormFilter));
    assertNotNull("pluginFormPropertyTypes can not be null", pluginFormPropertyTypes);
    // AtomicBoolean hasExecVisitSubForm = new AtomicBoolean(false);
    boolean hasExecVisitSubForm = pluginFormPropertyTypes.accept(new DescriptorsJSON.SubFormFieldVisitor(Optional.of(subFormFilter)) {

        @Override
        public // SuFormProperties.SuFormPropertiesBehaviorMeta behaviorMeta,
        Boolean visit(SuFormProperties props) {
            // assertNotNull("behaviorMeta can not be null", behaviorMeta);
            assertNotNull("prop can not be null", props);
            // assertEquals("设置", behaviorMeta.getClickBtnLabel());
            // Map<String, SuFormProperties.SuFormPropertyGetterMeta>
            // onClickFillData = behaviorMeta.getOnClickFillData();
            // assertEquals("onClickFillData.size() > 0", 2, onClickFillData.size());
            // SuFormProperties.SuFormPropertyGetterMeta getterMeta = onClickFillData.get("cols");
            // assertNotNull(getterMeta);
            // assertEquals("getTableMetadata", getterMeta.getMethod());
            // assertTrue("getParams equal"
            // , CollectionUtils.isEqualCollection(Collections.singleton("id"), getterMeta.getParams()));
            // 
            // 
            // getterMeta = onClickFillData.get("recordField");
            // assertNotNull(getterMeta);
            // assertEquals("getPrimaryKeys", getterMeta.getMethod());
            // assertTrue("getParams equal"
            // , CollectionUtils.isEqualCollection(Collections.singleton("id"), getterMeta.getParams()));
            // ===============================================
            Set<Map.Entry<String, PropertyType>> kvTuples = props.getKVTuples();
            assertEquals(3, kvTuples.size());
            assertTrue(CollectionUtils.isEqualCollection(Lists.newArrayList("name", "subProp1", "subProp2"), kvTuples.stream().map((kv) -> kv.getKey()).collect(Collectors.toList())));
            Object subField = props.newSubDetailed();
            assertTrue("subField must be type of " + SubFieldExtend.class.getSimpleName(), subField instanceof SubFieldExtend);
            return true;
        }
    });
    assertTrue("hasExecVisitSubForm must has execute", hasExecVisitSubForm);
}
Also used : Set(java.util.Set) UploadPluginMeta(com.qlangtech.tis.util.UploadPluginMeta) IPropertyType(com.qlangtech.tis.extension.IPropertyType) PluginFormProperties(com.qlangtech.tis.extension.PluginFormProperties) DescriptorsJSON(com.qlangtech.tis.util.DescriptorsJSON) IPropertyType(com.qlangtech.tis.extension.IPropertyType) Map(java.util.Map)

Example 7 with UploadPluginMeta

use of com.qlangtech.tis.util.UploadPluginMeta in project tis by qlangtech.

the class TestParamsConfigPluginStore method testWriteAndGet.

public void testWriteAndGet() {
    UploadPluginMeta pluginMeta = UploadPluginMeta.parse(UploadPluginMeta.KEY_TARGET_PLUGIN_DESC + "_test1");
    ParamsConfigPluginStore paramsCfgPluginStore = new ParamsConfigPluginStore(pluginMeta);
    List<Descriptor.ParseDescribable<ParamsConfig>> dlist = Lists.newArrayList();
    Test1ParamsConfig cfg1 = new Test1ParamsConfig();
    cfg1.name = "id1";
    Descriptor.ParseDescribable<ParamsConfig> pluginDesc1 = new Descriptor.ParseDescribable<>(cfg1);
    pluginDesc1.extraPluginMetas.add(new XStream2.PluginMeta("test1meta", "1.0.0"));
    dlist.add(pluginDesc1);
    Test2ParamsConfig cfg2 = new Test2ParamsConfig();
    cfg2.name = "id1";
    Descriptor.ParseDescribable<ParamsConfig> pluginDesc2 = new Descriptor.ParseDescribable<>(cfg2);
    pluginDesc2.extraPluginMetas.add(new XStream2.PluginMeta("test2meta", "1.0.0"));
    dlist.add(pluginDesc2);
    paramsCfgPluginStore.setPlugins(null, Optional.empty(), dlist);
    List<ParamsConfig> plugins = paramsCfgPluginStore.getPlugins();
    assertEquals(3, plugins.size());
    cfg2 = new Test2ParamsConfig();
    cfg2.name = "id1";
    pluginDesc2 = new Descriptor.ParseDescribable<>(cfg2);
    pluginDesc2.extraPluginMetas.add(new XStream2.PluginMeta("test2meta", "1.0.0"));
    dlist.add(pluginDesc2);
    // 保存应该是要出错的,因为cfg2存在Id重复的问题
    paramsCfgPluginStore.setPlugins(null, Optional.empty(), dlist);
}
Also used : UploadPluginMeta(com.qlangtech.tis.util.UploadPluginMeta) XStream2(com.qlangtech.tis.util.XStream2) ParamsConfig(com.qlangtech.tis.config.ParamsConfig) Descriptor(com.qlangtech.tis.extension.Descriptor)

Aggregations

UploadPluginMeta (com.qlangtech.tis.util.UploadPluginMeta)7 DescriptorsJSON (com.qlangtech.tis.util.DescriptorsJSON)4 JSONObject (com.alibaba.fastjson.JSONObject)3 PluginFormProperties (com.qlangtech.tis.extension.PluginFormProperties)3 Descriptor (com.qlangtech.tis.extension.Descriptor)2 PropertyType (com.qlangtech.tis.extension.impl.PropertyType)2 JsonUtil (com.qlangtech.tis.trigger.util.JsonUtil)2 Context (com.alibaba.citrus.turbine.Context)1 JSON (com.alibaba.fastjson.JSON)1 Lists (com.google.common.collect.Lists)1 Maps (com.google.common.collect.Maps)1 Pager (com.koubei.web.tag.pager.Pager)1 RocketMQListenerFactory (com.qlangtech.async.message.client.consumer.RocketMQListenerFactory)1 TIS (com.qlangtech.tis.TIS)1 FullbuildPhase (com.qlangtech.tis.assemble.FullbuildPhase)1 MQListenerFactory (com.qlangtech.tis.async.message.client.consumer.impl.MQListenerFactory)1 Assert (com.qlangtech.tis.common.utils.Assert)1 ParamsConfig (com.qlangtech.tis.config.ParamsConfig)1 CoreAction (com.qlangtech.tis.coredefine.module.action.CoreAction)1 DataxAction (com.qlangtech.tis.coredefine.module.action.DataxAction)1