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);
}
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);
}
Aggregations