Browse Source

KERNEL-3521 添加FineKit依赖

master
lucian 5 years ago
parent
commit
f3f6fe516a
  1. 16
      src/main/java/com/fanruan/api/cal/formula/Formula.java
  2. 20
      src/main/java/com/fanruan/api/cluster/ClusterBridgeKit.java
  3. 15
      src/main/java/com/fanruan/api/concurrent/ConcurrentKit.java
  4. 20
      src/main/java/com/fanruan/api/concurrent/NamedThreadFactory.java
  5. 21
      src/main/java/com/fanruan/api/conf/xml/XmlHolderKit.java
  6. 10
      src/main/java/com/fanruan/api/decision/monitor/RuntimeMemScoreKit.java
  7. 19
      src/main/java/com/fanruan/api/design/ui/component/table/model/DesignModelAdapter.java
  8. 15
      src/main/java/com/fanruan/api/design/ui/component/table/model/DesignModelAdapterKit.java
  9. 4
      src/main/java/com/fanruan/api/design/ui/table/BasePropertyTable.java
  10. 413
      src/main/java/com/fanruan/api/design/work/WidgetPropertyPane.java
  11. 3
      src/main/java/com/fanruan/api/design/work/component/ParameterComboBox.java
  12. 3
      src/main/java/com/fanruan/api/util/FineCollectionKit.java
  13. 34
      src/test/java/com/fanruan/api/cluster/ClusterBridgeKitTest.java
  14. 9
      src/test/java/com/fanruan/api/decision/monitor/RuntimeMemScoreKitTest.java
  15. 4
      src/test/java/com/fanruan/api/util/FineCollectionKitTest.java
  16. 1
      src/test/java/com/fanruan/api/util/GeneralKitTest.java
  17. 2
      src/test/java/com/fanruan/api/util/IOKitTest.java

16
src/main/java/com/fanruan/api/cal/formula/Formula.java

@ -1,16 +0,0 @@
package com.fanruan.api.cal.formula;
/**
* @author Lucian.Chen
* @version 10.0
* Created by Lucian.Chen on 2020/3/23
*/
public class Formula extends com.fr.base.Formula {
public Formula() {
super();
}
public Formula(String content) {
super(content);
}
}

20
src/main/java/com/fanruan/api/cluster/ClusterBridgeKit.java

@ -1,7 +1,11 @@
package com.fanruan.api.cluster; package com.fanruan.api.cluster;
import com.fr.cluster.ClusterBridge; import com.fr.cluster.ClusterBridge;
import com.fr.cluster.core.ClusterNode;
import com.fr.cluster.core.ClusterView; import com.fr.cluster.core.ClusterView;
import com.fr.stable.Filter;
import java.util.List;
/** /**
* @author Lucian.Chen * @author Lucian.Chen
@ -10,8 +14,20 @@ import com.fr.cluster.core.ClusterView;
*/ */
public class ClusterBridgeKit { public class ClusterBridgeKit {
public static ClusterView getView() { public static ClusterNode getCurrentNode() {
return ClusterBridge.getView(); return ClusterBridge.getView().getCurrent();
}
public static ClusterNode getNodeById(String var1) {
return ClusterBridge.getView().getNodeById(var1);
}
public static List<ClusterNode> listNodes() {
return ClusterBridge.getView().listNodes();
}
public static List<ClusterNode> listNodes(Filter<ClusterNode> var1) {
return ClusterBridge.getView().listNodes(var1);
} }
public static boolean isClusterMode() { public static boolean isClusterMode() {

15
src/main/java/com/fanruan/api/concurrent/ConcurrentKit.java

@ -0,0 +1,15 @@
package com.fanruan.api.concurrent;
import com.fr.concurrent.NamedThreadFactory;
/**
* @author Lucian.Chen
* @version 10.0
* Created by Lucian.Chen on 2020/3/27
*/
public class ConcurrentKit {
public static NamedThreadFactory newNamedThreadFactory(String s) {
return new NamedThreadFactory(s);
}
}

20
src/main/java/com/fanruan/api/concurrent/NamedThreadFactory.java

@ -1,20 +0,0 @@
package com.fanruan.api.concurrent;
/**
* @author Lucian.Chen
* @version 10.0
* Created by Lucian.Chen on 2020/3/23
*/
public class NamedThreadFactory extends com.fr.concurrent.NamedThreadFactory {
public NamedThreadFactory(Class<?> aClass) {
super(aClass);
}
public NamedThreadFactory(String s) {
super(s);
}
public NamedThreadFactory(String s, boolean b) {
super(s, b);
}
}

21
src/main/java/com/fanruan/api/conf/xml/XmlHolderKit.java

@ -14,21 +14,38 @@ public class XmlHolderKit {
/** /**
* 创建一个要写入配置的xml多项 * 创建一个要写入配置的xml多项
* * @param <T> 类型
* @param <T> 类型
* @param t 配置对象 * @param t 配置对象
* @param clazz 类型 * @param clazz 类型
* @param xmlTag xml标签 * @param xmlTag xml标签
* @param <T> 类型
* @return 配置对象 * @return 配置对象
*/ */
public static <T extends XMLable> Conf<T> obj(T t, Class<T> clazz, String xmlTag) { public static <T extends XMLable> Conf<T> obj(T t, Class<T> clazz, String xmlTag) {
return new XmlConf(t, clazz, xmlTag); return new XmlConf(t, clazz, xmlTag);
} }
/**
* 创建一个集合类型的xml配置
*
* @param t 初始值
* @param clazz 对象class类型
* @param <T> 类型
* @return 配置对象
*/
public static <T extends XMLable> XmlColConf<Collection<T>> collection(Collection<T> t, Class<T> clazz) { public static <T extends XMLable> XmlColConf<Collection<T>> collection(Collection<T> t, Class<T> clazz) {
return collection(t,clazz,true); return collection(t,clazz,true);
} }
/**
* 创建一个集合类型的xml配置
*
* @param t 初始值
* @param clazz 对象class类型
* @param order 是否是有序的配置
* @param <T> 类型
* @return 配置对象
*/
public static <T extends XMLable> XmlColConf<Collection<T>> collection(Collection<T> t, Class<T> clazz, boolean order) { public static <T extends XMLable> XmlColConf<Collection<T>> collection(Collection<T> t, Class<T> clazz, boolean order) {
return new XmlColConf<Collection<T>>(t, clazz, order); return new XmlColConf<Collection<T>>(t, clazz, order);
} }

10
src/main/java/com/fanruan/api/decision/monitor/RuntimeMemScoreKit.java

@ -9,16 +9,6 @@ import com.fr.decision.system.monitor.gc.load.RuntimeMemScoreProvider;
*/ */
public class RuntimeMemScoreKit { public class RuntimeMemScoreKit {
//计算中止分值
public static int getBalancePromoterScore() {
return RuntimeMemScoreProvider.getBalancePromoterScore();
}
//释放会话分值
public static int getReleasePromoterScore() {
return RuntimeMemScoreProvider.getReleasePromoterScore();
}
//分发得分 //分发得分
public static int getLoadScore() { public static int getLoadScore() {
return RuntimeMemScoreProvider.getLoadScore(); return RuntimeMemScoreProvider.getLoadScore();

19
src/main/java/com/fanruan/api/design/ui/component/table/model/DesignModelAdapter.java

@ -1,19 +0,0 @@
package com.fanruan.api.design.ui.component.table.model;
import com.fr.base.io.BaseBook;
import com.fr.design.mainframe.JTemplateProvider;
/**
* @author Lucian.Chen
* @version 10.0
* Created by Lucian.Chen on 2020/3/23
*/
public abstract class DesignModelAdapter<T extends BaseBook, S extends JTemplateProvider<T>> extends com.fr.design.DesignModelAdapter {
public DesignModelAdapter(JTemplateProvider jTemplateProvider) {
super(jTemplateProvider);
}
public static DesignModelAdapter<?, ?> getCurrentModelAdapter() {
return DesignModelAdapter.getCurrentModelAdapter();
}
}

15
src/main/java/com/fanruan/api/design/ui/component/table/model/DesignModelAdapterKit.java

@ -0,0 +1,15 @@
package com.fanruan.api.design.ui.component.table.model;
import com.fr.design.DesignModelAdapter;
/**
* @author Lucian.Chen
* @version 10.0
* Created by Lucian.Chen on 2020/3/27
*/
public class DesignModelAdapterKit {
public static DesignModelAdapter<?, ?> getCurrentModelAdapter() {
return DesignModelAdapter.getCurrentModelAdapter();
}
}

4
src/main/java/com/fanruan/api/design/ui/table/AbstractPropertyTable.java → src/main/java/com/fanruan/api/design/ui/table/BasePropertyTable.java

@ -5,8 +5,8 @@ package com.fanruan.api.design.ui.table;
* @version 10.0 * @version 10.0
* Created by Lucian.Chen on 2020/3/23 * Created by Lucian.Chen on 2020/3/23
*/ */
public abstract class AbstractPropertyTable extends com.fr.design.gui.itable.AbstractPropertyTable { public abstract class BasePropertyTable extends com.fr.design.gui.itable.AbstractPropertyTable {
public AbstractPropertyTable() { public BasePropertyTable() {
super(); super();
} }
} }

413
src/main/java/com/fanruan/api/design/work/WidgetPropertyPane.java

@ -1,419 +1,12 @@
package com.fanruan.api.design.work; package com.fanruan.api.design.work;
import com.fanruan.api.design.ui.component.UIHeadGroup;
import com.fanruan.api.design.ui.component.UILabel;
import com.fanruan.api.design.ui.container.UIScrollPane;
import com.fanruan.api.design.ui.table.AbstractPropertyTable;
import com.fanruan.api.design.util.GUICoreKit;
import com.fanruan.api.util.ArrayKit;
import com.fanruan.api.util.IOKit;
import com.fr.design.ExtraDesignClassManager;
import com.fr.design.constants.UIConstants;
import com.fr.design.designer.beans.events.DesignerEditListener;
import com.fr.design.designer.beans.events.DesignerEvent;
import com.fr.design.designer.creator.XComponent;
import com.fr.design.designer.creator.XCreator;
import com.fr.design.designer.creator.XCreatorUtils;
import com.fr.design.designer.creator.XLayoutContainer;
import com.fr.design.designer.creator.XWAbsoluteLayout;
import com.fr.design.designer.creator.XWFitLayout;
import com.fr.design.designer.creator.XWParameterLayout;
import com.fr.design.designer.properties.EventPropertyTable;
import com.fr.design.designer.properties.mobile.MobileBookMarkPropertyUI;
import com.fr.design.designer.properties.mobile.MobileStylePropertyUI;
import com.fr.design.fun.WidgetPropertyUIProvider;
import com.fr.design.mainframe.BaseFormDesigner;
import com.fr.design.mainframe.BaseWidgetPropertyPane;
import com.fr.design.mainframe.FormDesigner;
import com.fr.design.mainframe.FormDockView;
import com.fr.design.mainframe.FormSelection;
import com.fr.design.mainframe.widget.ui.FormWidgetCardPane;
import com.fr.design.widget.ui.designer.mobile.MobileWidgetDefinePane;
import javax.swing.*;
import java.awt.*;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
/** /**
* 控件属性表绘制 * 控件属性表绘制
* Modified by fanglei
*/
public class WidgetPropertyPane extends FormDockView implements BaseWidgetPropertyPane {
private static final int PADDING = 10;
private static final int PADDING_M = 12;
private FormWidgetCardPane formWidgetCardPane; // 控件的属性表
private EventPropertyTable eventTable; // 控件的事件表
private List<AbstractPropertyTable> widgetPropertyTables; // 这个变量应该是保存控件拓展的属性tab
private List<MobileWidgetDefinePane> mobileExtraPropertyPanes; // 保存9.0设计器下移动端拓展的属性tab,舍弃JTable
private FormDesigner designer; // 当前designer
private UIScrollPane psp; // 用来装载属性表table的容器
private JPanel wsp; // 装载移动端tab的容器,包括移动端属性表和控件拓展的移动端属性表
private UIHeadGroup tabsHeaderIconPane;
private XComponent lastAffectedCreator;
public static WidgetPropertyPane getInstance() {
if (HOLDER.singleton == null) {
HOLDER.singleton = new WidgetPropertyPane();
}
return HOLDER.singleton;
}
public static WidgetPropertyPane getInstance(FormDesigner formEditor) {
HOLDER.singleton.setEditingFormDesigner(formEditor);
HOLDER.singleton.refreshDockingView();
return HOLDER.singleton;
}
private static class HOLDER {
private static WidgetPropertyPane singleton = new WidgetPropertyPane();
}
private WidgetPropertyPane() {
setLayout(GUICoreKit.createBorderLayout());
}
@Override
protected String title4PopupWindow() {
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Control_Setting");
}
@Override
public String getViewTitle() {
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Property_Table");
}
@Override
public Icon getViewIcon() {
return IOKit.readIcon("/com/fr/design/images/m_report/attributes.png");
}
@Override
/**
* 绘制属性表tab
*/
public void refreshDockingView() {
designer = this.getEditingFormDesigner();
removeAll();
if (designer == null) {
clearDockingView();
return;
}
widgetPropertyTables = new ArrayList<AbstractPropertyTable>();
mobileExtraPropertyPanes = new ArrayList<>();
//依次创建属性表、事件表、移动端表,再将它们整合到TabPane中去
this.createPropertyTable();
this.createEventTable();
this.createMobileWidgetTable();
this.createTabPane();
this.initTables();
}
/**
* 初始化属性表事件表移动端拓展的属性表
*/
private void initTables() {
formWidgetCardPane.populate();
eventTable.refresh();
if (mobileExtraPropertyPanes != null) {
for (MobileWidgetDefinePane extraPane : mobileExtraPropertyPanes) {
extraPane.initPropertyGroups(designer);
}
}
if (widgetPropertyTables != null) {
for (AbstractPropertyTable propertyTable : widgetPropertyTables) {
propertyTable.initPropertyGroups(designer);
}
}
}
/**
* 创建属性表table
*/
private void createPropertyTable() {
formWidgetCardPane = new FormWidgetCardPane(designer);
designer.addDesignerEditListener(new WidgetPropertyDesignerAdapter(formWidgetCardPane));
psp = new UIScrollPane(formWidgetCardPane); // 用来装载属性表table
psp.setBorder(null);
}
/**
* 创建事件表事件选项卡不是JTable
*/
private void createEventTable() {
eventTable = new EventPropertyTable(designer);
designer.addDesignerEditListener(new EventPropertyDesignerAdapter(eventTable));
}
/**
* 创建移动端控件列表
*/
private void createMobileWidgetTable() {
//加上表头后,这里不再使用borderLayout布局,而采用BoxLayout布局
wsp = GUICoreKit.createYAXISBoxInnerContainerPane();
wsp.setBorder(null);
designer.addDesignerEditListener(new MobileWidgetDesignerAdapter());
//获取拓展移动端属性tab
WidgetPropertyUIProvider[] widgetAttrProviders = getExtraPropertyUIProviders();
addWidgetAttr(widgetAttrProviders);
}
/**
* 将属性表事件表移动端控件列表整合到TabPane里面去
*/
private void createTabPane() {
initTabPane();
}
/**
* 获取当前控件扩展的属性tab
* 来源有两个:
* 1, 各个控件从各自的Xcreator里扩展例如手机重布局的tab就是从Xcreator中扩展的;
* 2, 所有的控件从插件里扩展.
*
* @return 扩展的tab
*/
private WidgetPropertyUIProvider[] getExtraPropertyUIProviders() {
FormSelection selection = designer.getSelectionModel().getSelection();
WidgetPropertyUIProvider[] embeddedPropertyUIProviders = null;
XCreator xCreator = selection.getSelectedCreator();
if (selection != null && xCreator != null) {
embeddedPropertyUIProviders = selection.getSelectedCreator().getWidgetPropertyUIProviders();
if(!designer.getDesignerMode().isFormParameterEditor()) {
if (!xCreator.acceptType(XWAbsoluteLayout.class, XWFitLayout.class)) {
embeddedPropertyUIProviders = ArrayKit.insert(0, embeddedPropertyUIProviders, new MobileBookMarkPropertyUI(xCreator));
}
if (xCreator.supportMobileStyle()) {
embeddedPropertyUIProviders = ArrayKit.insert(0, embeddedPropertyUIProviders, new MobileStylePropertyUI(xCreator));
}
}
}
Set<WidgetPropertyUIProvider> set = ExtraDesignClassManager.getInstance().getArray(WidgetPropertyUIProvider.XML_TAG);
return ArrayKit.addAll(embeddedPropertyUIProviders, set.toArray(new WidgetPropertyUIProvider[set.size()]));
}
/**
* 判断是将拓展的tab放入属性表还是将原来的tab放入属性表
*
* @param widgetAttrProviders 拓展的tab
*/
private void addWidgetAttr(WidgetPropertyUIProvider[] widgetAttrProviders) {
if (widgetAttrProviders.length == 0) { // 判断有没有拓展的tab,提示"无可用配置项"
wsp.add(getUnavailablePane());
} else {
for (WidgetPropertyUIProvider widgetAttrProvider : widgetAttrProviders) {
MobileWidgetDefinePane extraPane = (MobileWidgetDefinePane) widgetAttrProvider.createWidgetAttrPane();
if (extraPane != null) {
extraPane.setBorder(BorderFactory.createEmptyBorder(PADDING, PADDING, PADDING, PADDING_M));
mobileExtraPropertyPanes.add(extraPane);
wsp.add(extraPane);
}
AbstractPropertyTable propertyTable = (AbstractPropertyTable) widgetAttrProvider.createWidgetAttrTable();
if (propertyTable != null) {
widgetPropertyTables.add(propertyTable);
designer.addDesignerEditListener(new WidgetPropertyDesignerAdapter(formWidgetCardPane));
UIScrollPane uiScrollPane = new UIScrollPane(propertyTable);
wsp.add(uiScrollPane);
}
}
}
}
// "无可用配置项"面板
private JPanel getUnavailablePane() {
JPanel panel = GUICoreKit.createBorderLayoutPane();
UILabel label = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_No_Settings_Available"));
label.setHorizontalAlignment(SwingConstants.CENTER);
panel.add(label);
return panel;
}
private void initTabPane() {
final String[] tabTitles = new String[]{
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Properties"),
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Event"),
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Widget_Mobile_Terminal")
};
final CardLayout tabbedPane = new CardLayout();
final JPanel center = new JPanel(tabbedPane);
center.add(formWidgetCardPane, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Properties"));
center.add(eventTable, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Event"));
center.add(wsp, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Widget_Mobile_Terminal"));
this.add(center, BorderLayout.CENTER);
tabsHeaderIconPane = new UIHeadGroup(tabTitles) {
@Override
public void tabChanged(int index) {
//切换的时候再populate
if (index == 1) {
eventTable.populateNameObjects();
} else if (index == 2) {
if (mobileExtraPropertyPanes != null) {
for (MobileWidgetDefinePane extraPane : mobileExtraPropertyPanes) {
extraPane.populate(designer);
}
}
}
tabbedPane.show(center, tabTitles[index]);
}
};
tabsHeaderIconPane.setNeedLeftRightOutLine(true);
tabsHeaderIconPane.setBorder(BorderFactory.createMatteBorder(1, 0, 0, 0, UIConstants.SHADOW_GREY));
this.add(tabsHeaderIconPane, BorderLayout.NORTH);
}
/**
* 选中的组件是否在参数面板里
* *
* @param designer 设计器
* @return 是则返回true
*/
public boolean hasSelectParaPane(FormDesigner designer) {
XCreator xCreator = designer.getSelectionModel().getSelection().getSelectedCreator();
if (xCreator == null) {
xCreator = designer.getRootComponent();
}
XLayoutContainer container = XCreatorUtils.getHotspotContainer(xCreator);
boolean xCreatorAccept = xCreator.acceptType(XWParameterLayout.class);
boolean containerAccept = container != null && container.acceptType(XWParameterLayout.class);
return xCreatorAccept || containerAccept;
}
@Override
public void setEditingFormDesigner(BaseFormDesigner editor) {
FormDesigner fd = (FormDesigner) editor;
super.setEditingFormDesigner(fd);
}
private void clearDockingView() {
formWidgetCardPane = null;
eventTable = null;
if (widgetPropertyTables != null) {
widgetPropertyTables.clear();
}
JScrollPane psp = new JScrollPane();
psp.setBorder(null);
this.add(psp, BorderLayout.CENTER);
}
/**
* 属性表监听界面事件(编辑删除选中改变大小)
*/ */
private class WidgetPropertyDesignerAdapter implements DesignerEditListener { public class WidgetPropertyPane {
FormWidgetCardPane formWidgetCardPane;
WidgetPropertyDesignerAdapter(FormWidgetCardPane formWidgetCardPane) {
this.formWidgetCardPane = formWidgetCardPane;
}
@Override
public void fireCreatorModified(DesignerEvent evt) {
if (evt.getCreatorEventID() == DesignerEvent.CREATOR_DELETED
|| evt.getCreatorEventID() == DesignerEvent.CREATOR_RESIZED) {
formWidgetCardPane.populate();
} else if (evt.getCreatorEventID() == DesignerEvent.CREATOR_SELECTED) {
// 防止多次触发
if (lastAffectedCreator != null && lastAffectedCreator == evt.getAffectedCreator()) {
return;
}
lastAffectedCreator = evt.getAffectedCreator();
refreshDockingView();
formWidgetCardPane.populate();
}
}
@Override
public boolean equals(Object o) {
return o instanceof WidgetPropertyDesignerAdapter;
}
}
/**
* 事件表监听界面事件编辑选中
*/
private class EventPropertyDesignerAdapter implements DesignerEditListener {
EventPropertyTable propertyTable;
EventPropertyDesignerAdapter(EventPropertyTable eventTable) {
this.propertyTable = eventTable;
}
@Override
public void fireCreatorModified(DesignerEvent evt) {
if (evt.getCreatorEventID() == DesignerEvent.CREATOR_EDITED) {
propertyTable.refresh();
} else if (evt.getCreatorEventID() == DesignerEvent.CREATOR_SELECTED) {
// 防止多次触发
if (lastAffectedCreator != null && lastAffectedCreator == evt.getAffectedCreator()) {
return;
}
lastAffectedCreator = evt.getAffectedCreator();
propertyTable.refresh();
}
}
@Override
public boolean equals(Object o) {
return o instanceof EventPropertyDesignerAdapter;
}
}
/**
* 移动端属性表监听界面事件改变大小编辑选中增加控件
*/
private class MobileWidgetDesignerAdapter implements DesignerEditListener {
MobileWidgetDesignerAdapter() {
}
/**
* 响应界面改变事件
*
* @param evt 事件
*/
public void fireCreatorModified(DesignerEvent evt) {
int[] validEventIds = {DesignerEvent.CREATOR_RESIZED, DesignerEvent.CREATOR_EDITED,
DesignerEvent.CREATOR_SELECTED, DesignerEvent.CREATOR_ADDED, DesignerEvent.CREATOR_ORDER_CHANGED};
boolean isValid = false;
for (int validEventId : validEventIds) {
if (evt.getCreatorEventID() == validEventId) {
isValid = true;
break;
}
}
if (!isValid) {
return;
}
if (mobileExtraPropertyPanes != null) {
for (MobileWidgetDefinePane extraPane : mobileExtraPropertyPanes) {
extraPane.populate(designer);
}
}
}
@Override
public boolean equals(Object o) {
return o instanceof MobileWidgetDesignerAdapter;
}
}
@Override public static com.fr.design.mainframe.WidgetPropertyPane getInstance() {
public Location preferredLocation() { return com.fr.design.mainframe.WidgetPropertyPane.getInstance();
return Location.WEST_BELOW;
} }
} }

3
src/main/java/com/fanruan/api/design/work/component/ParameterComboBox.java

@ -2,6 +2,7 @@ package com.fanruan.api.design.work.component;
import com.fanruan.api.cal.ParameterKit; import com.fanruan.api.cal.ParameterKit;
import com.fanruan.api.design.ui.component.UIComboBox; import com.fanruan.api.design.ui.component.UIComboBox;
import com.fanruan.api.design.ui.component.table.model.DesignModelAdapterKit;
import com.fanruan.api.util.AssistKit; import com.fanruan.api.util.AssistKit;
import com.fr.design.DesignModelAdapter; import com.fr.design.DesignModelAdapter;
import com.fr.stable.ParameterProvider; import com.fr.stable.ParameterProvider;
@ -41,7 +42,7 @@ public class ParameterComboBox extends UIComboBox<ParameterProvider> {
public void updateParaItems() { public void updateParaItems() {
DesignModelAdapter<?, ?> designModel = DesignModelAdapter.getCurrentModelAdapter(); DesignModelAdapter<?, ?> designModel = DesignModelAdapterKit.getCurrentModelAdapter();
this.removeAllItems(); this.removeAllItems();
if (designModel != null) { if (designModel != null) {

3
src/main/java/com/fanruan/api/util/FineCollectionKit.java

@ -9,9 +9,6 @@ import com.fr.collections.api.FineCollectionClient;
* Created by Lucian.Chen on 2020/3/23 * Created by Lucian.Chen on 2020/3/23
*/ */
public class FineCollectionKit { public class FineCollectionKit {
public static FineCollections getFineCollections() {
return FineCollections.getInstance();
}
public static FineCollectionClient getClient() { public static FineCollectionClient getClient() {
return FineCollections.getInstance().getClient(); return FineCollections.getInstance().getClient();

34
src/test/java/com/fanruan/api/cluster/ClusterBridgeKitTest.java

@ -1,7 +1,9 @@
package com.fanruan.api.cluster; package com.fanruan.api.cluster;
import com.fr.cluster.ClusterBridge; import com.fr.cluster.ClusterBridge;
import com.fr.cluster.core.ClusterNode;
import com.fr.cluster.core.ClusterView; import com.fr.cluster.core.ClusterView;
import com.fr.stable.Filter;
import org.easymock.EasyMock; import org.easymock.EasyMock;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Test; import org.junit.Test;
@ -10,6 +12,9 @@ import org.powermock.api.easymock.PowerMock;
import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner; import org.powermock.modules.junit4.PowerMockRunner;
import java.util.ArrayList;
import java.util.List;
/** /**
* @author Lucian.Chen * @author Lucian.Chen
* @version 10.0 * @version 10.0
@ -23,15 +28,32 @@ public class ClusterBridgeKitTest {
public void testGetView() { public void testGetView() {
ClusterView view = EasyMock.mock(ClusterView.class); ClusterView view = EasyMock.mock(ClusterView.class);
PowerMock.mockStatic(ClusterBridge.class); PowerMock.mockStatic(ClusterBridge.class);
EasyMock.expect(ClusterBridge.getView()).andReturn(view).once(); EasyMock.expect(ClusterBridge.getView()).andReturn(view).anyTimes();
EasyMock.expect(ClusterBridge.getView()).andReturn(null).once(); Filter filter = EasyMock.createMock(Filter.class);
ClusterNode node1 = EasyMock.mock(ClusterNode.class);
ClusterNode node2 = EasyMock.mock(ClusterNode.class);
ClusterNode node3 = EasyMock.mock(ClusterNode.class);
List<ClusterNode> list1 = new ArrayList<>();
List<ClusterNode> list2 = new ArrayList<>();
list1.add(node1);
list1.add(node2);
list2.add(node3);
EasyMock.expect(view.getCurrent()).andReturn(node1).once();
EasyMock.expect(view.getNodeById("1")).andReturn(node2).once();
EasyMock.expect(view.listNodes()).andReturn(list1).once();
EasyMock.expect(view.listNodes(filter)).andReturn(list2).once();
EasyMock.replay(view); EasyMock.replay(view, filter, node1, node2, node3);
PowerMock.replay(ClusterBridge.class); PowerMock.replay(ClusterBridge.class);
Assert.assertEquals(ClusterBridgeKit.getView(), view); Assert.assertEquals(ClusterBridgeKit.getCurrentNode(), node1);
Assert.assertNull(ClusterBridgeKit.getView()); Assert.assertEquals(ClusterBridgeKit.getNodeById("1"), node2);
Assert.assertEquals(ClusterBridgeKit.listNodes(), list1);
Assert.assertEquals(ClusterBridgeKit.listNodes(filter), list2);
EasyMock.verify(view); EasyMock.verify(view, filter, node1, node2, node3);
PowerMock.verify(ClusterBridge.class); PowerMock.verify(ClusterBridge.class);
} }

9
src/test/java/com/fanruan/api/decision/monitor/RuntimeMemScoreKitTest.java

@ -16,13 +16,4 @@ public class RuntimeMemScoreKitTest {
Assert.assertEquals(RuntimeMemScoreProvider.getLoadScore(), RuntimeMemScoreKit.getLoadScore()); Assert.assertEquals(RuntimeMemScoreProvider.getLoadScore(), RuntimeMemScoreKit.getLoadScore());
} }
@Test
public void testGetReleasePromoterScore() {
Assert.assertEquals(RuntimeMemScoreProvider.getReleasePromoterScore(), RuntimeMemScoreKit.getReleasePromoterScore());
}
@Test
public void testGetBalancePromoterScore() {
Assert.assertEquals(RuntimeMemScoreProvider.getBalancePromoterScore(), RuntimeMemScoreKit.getBalancePromoterScore());
}
} }

4
src/test/java/com/fanruan/api/util/FineCollectionKitTest.java

@ -16,8 +16,4 @@ public class FineCollectionKitTest {
Assert.assertEquals(FineCollections.getInstance().getClient(), FineCollectionKit.getClient()); Assert.assertEquals(FineCollections.getInstance().getClient(), FineCollectionKit.getClient());
} }
@Test
public void testGetInstance() {
Assert.assertEquals(FineCollections.getInstance(), FineCollectionKit.getFineCollections());
}
} }

1
src/test/java/com/fanruan/api/util/GeneralKitTest.java

@ -2,6 +2,7 @@ package com.fanruan.api.util;
import com.fanruan.api.Prepare; import com.fanruan.api.Prepare;
import com.fr.general.GeneralUtils; import com.fr.general.GeneralUtils;
import com.fr.license.utils.JsonUtil;
import com.fr.stable.StableUtils; import com.fr.stable.StableUtils;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Test; import org.junit.Test;

2
src/test/java/com/fanruan/api/util/IOKitTest.java

@ -30,7 +30,7 @@ public class IOKitTest extends Prepare {
@Test @Test
public void readIcon() { public void readIcon() {
Assert.assertEquals((IOKit.readIcon("/com/fanruan/api/util/close.png")).getIconHeight(),(new ImageIcon(IOUtils.readImageWithCache("/com/fanruan/api/util/close.png")).getIconHeight())); Assert.assertEquals((IOKit.readIcon("/com/fanruan/api/util/close.png")).getIconHeight(), IOUtils.readIcon("/com/fanruan/api/util/close.png").getIconHeight());
} }
@Test @Test

Loading…
Cancel
Save