Browse Source
* commit 'a4362fbee66df943728db44175e94ac8a135bdc9': CHART-16721 预定义样式代码回退 REPORT-43198 预定义样式功能优化代码回退遗漏部分 REPORT-43198 预定义样式功能优化代码回退遗漏部分 代码回退 代码屏蔽 代码屏蔽 REPORT-43198 预定义样式功能优化代码回退 代码修改 REPORT-42887 && REPORT-42450 新建多sheet背景不生效; 单元格设置预定义样式的时候,使用工具栏设置边框设置失败 REPORT-42550 注册RPC接口 代码修改 REPORT-42550 预定义样式优化及与图表统一迭代research/11.0
superman
4 years ago
79 changed files with 604 additions and 937 deletions
@ -1,56 +0,0 @@ |
|||||||
package com.fr.design.mainframe.burying.point; |
|
||||||
|
|
||||||
import com.fr.design.mainframe.template.info.SendHelper; |
|
||||||
import com.fr.design.mainframe.template.info.TemplateProcessInfo; |
|
||||||
import java.util.ArrayList; |
|
||||||
import java.util.List; |
|
||||||
import java.util.Map; |
|
||||||
import java.util.concurrent.ConcurrentHashMap; |
|
||||||
|
|
||||||
/** |
|
||||||
* Created by kerry on 2020-09-04 |
|
||||||
*/ |
|
||||||
public abstract class AbstractTemplateInfoCollector<T extends AbstractPointInfo> extends AbstractPointCollector { |
|
||||||
protected Map<String, T> pointInfoMap; |
|
||||||
|
|
||||||
public AbstractTemplateInfoCollector() { |
|
||||||
pointInfoMap = new ConcurrentHashMap<>(); |
|
||||||
loadFromFile(); |
|
||||||
|
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
/** |
|
||||||
* 保存埋点的信息到本地 |
|
||||||
*/ |
|
||||||
public abstract void collectInfo(String templateID, String originID, TemplateProcessInfo processInfo, int timeConsume); |
|
||||||
|
|
||||||
@Override |
|
||||||
public void sendPointInfo() { |
|
||||||
|
|
||||||
addIdleDayCount(); |
|
||||||
|
|
||||||
List<String> removeList = new ArrayList<>(); |
|
||||||
List<String> sendList = new ArrayList<>(); |
|
||||||
|
|
||||||
for (String key : pointInfoMap.keySet()) { |
|
||||||
BasePointInfo pointInfo = pointInfoMap.get(key); |
|
||||||
pointInfo.selectPoint(removeList, sendList); |
|
||||||
} |
|
||||||
|
|
||||||
// 发送记录
|
|
||||||
for (String key : sendList) { |
|
||||||
if(SendHelper.sendPointInfo(pointInfoMap.get(key))){ |
|
||||||
removeList.add(key); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
// 清空记录
|
|
||||||
for (String key : removeList) { |
|
||||||
pointInfoMap.remove(key); |
|
||||||
} |
|
||||||
|
|
||||||
saveInfo(); |
|
||||||
} |
|
||||||
|
|
||||||
} |
|
@ -1,140 +0,0 @@ |
|||||||
package com.fr.design.mainframe.predefined.info; |
|
||||||
|
|
||||||
import com.fr.config.MarketConfig; |
|
||||||
import com.fr.design.DesignerEnvManager; |
|
||||||
import com.fr.design.i18n.Toolkit; |
|
||||||
import com.fr.design.mainframe.burying.point.AbstractPointCollector; |
|
||||||
import com.fr.design.mainframe.template.info.SendHelper; |
|
||||||
import com.fr.general.CloudCenter; |
|
||||||
import com.fr.general.ComparatorUtils; |
|
||||||
import com.fr.general.GeneralUtils; |
|
||||||
import com.fr.json.JSONObject; |
|
||||||
import com.fr.stable.xml.XMLPrintWriter; |
|
||||||
import com.fr.stable.xml.XMLableReader; |
|
||||||
import com.fr.third.joda.time.DateTime; |
|
||||||
|
|
||||||
/** |
|
||||||
* Created by kerry on 2020-09-04 |
|
||||||
*/ |
|
||||||
public class PredefinedStyleInfoCollector extends AbstractPointCollector { |
|
||||||
//每三天上传一次
|
|
||||||
private static final long DELTA = 3 * 24 * 3600 * 1000L; |
|
||||||
|
|
||||||
private static final String SIMPLE_DATE_PATTERN = "yyyy-MM-dd"; |
|
||||||
private static final String XML_TAG = "PredefinedStyleInfo"; |
|
||||||
private static final String XML_FILE_NAME = "predefinedStyle.info"; |
|
||||||
private static final String CLOUD_URL = CloudCenter.getInstance().acquireUrlByKind("design.collector") + "/single"; |
|
||||||
|
|
||||||
private static final String FUNCTION_NAME = "predefinedStyle"; |
|
||||||
private static final String FUNCTION_ID = "FR-F7003"; |
|
||||||
|
|
||||||
private static final String ATTR_FUNCTION_NAME = "functionName"; |
|
||||||
private static final String ATTR_FUNCTION_ID = "functionId"; |
|
||||||
private static final String ATTR_UUID = "uuid"; |
|
||||||
private static final String ATTR_UID = "uid"; |
|
||||||
private static final String ATTR_JAR_TIME = "jatTime"; |
|
||||||
private static final String ATTR_CLICK_NUMBER = "clickNumber"; |
|
||||||
private static final String ATTR_USE_NUMBER = "useNumber"; |
|
||||||
private static final String ATTR_TIME = "time"; |
|
||||||
private static final String XML_LAST_TIME = "lastSendTime"; |
|
||||||
|
|
||||||
/** |
|
||||||
* 上一次的发送时间 |
|
||||||
*/ |
|
||||||
private long lastSendTime; |
|
||||||
|
|
||||||
private int clickNumber = 0; |
|
||||||
|
|
||||||
private int useNumber = 0; |
|
||||||
|
|
||||||
public int getClickNumber() { |
|
||||||
return clickNumber; |
|
||||||
} |
|
||||||
|
|
||||||
public int getUseNumber() { |
|
||||||
return useNumber; |
|
||||||
} |
|
||||||
|
|
||||||
private static class Holder { |
|
||||||
private static PredefinedStyleInfoCollector collector = new PredefinedStyleInfoCollector(); |
|
||||||
} |
|
||||||
|
|
||||||
private PredefinedStyleInfoCollector() { |
|
||||||
loadFromFile(); |
|
||||||
} |
|
||||||
|
|
||||||
public static PredefinedStyleInfoCollector getInstance() { |
|
||||||
return Holder.collector; |
|
||||||
} |
|
||||||
|
|
||||||
public void collectClickNumber() { |
|
||||||
clickNumber++; |
|
||||||
saveInfo(); |
|
||||||
} |
|
||||||
|
|
||||||
public void collectUseNumber(String predefinedName) { |
|
||||||
if (!ComparatorUtils.equals(Toolkit.i18nText("Fine-Engine_Predefined_Style_Compatibility"), predefinedName) && |
|
||||||
!ComparatorUtils.equals(Toolkit.i18nText("Fine-Engine_Report_DEFAULT"), predefinedName)) { |
|
||||||
useNumber++; |
|
||||||
} |
|
||||||
saveInfo(); |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
protected String getInfoFilePath() { |
|
||||||
return XML_FILE_NAME; |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
protected void addIdleDayCount() { |
|
||||||
|
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public void sendPointInfo() { |
|
||||||
if (System.currentTimeMillis() - lastSendTime < DELTA) { |
|
||||||
return; |
|
||||||
} |
|
||||||
String content = generateTotalInfo(); |
|
||||||
SendHelper.sendSinglePointInfo(CLOUD_URL, content); |
|
||||||
this.lastSendTime = System.currentTimeMillis(); |
|
||||||
this.clickNumber = 0; |
|
||||||
this.useNumber = 0; |
|
||||||
saveInfo(); |
|
||||||
} |
|
||||||
|
|
||||||
public String generateTotalInfo() { |
|
||||||
|
|
||||||
JSONObject jo = JSONObject.create(); |
|
||||||
jo.put(ATTR_FUNCTION_NAME, FUNCTION_NAME); |
|
||||||
jo.put(ATTR_FUNCTION_ID, FUNCTION_ID); |
|
||||||
jo.put(ATTR_UUID, DesignerEnvManager.getEnvManager().getUUID()); |
|
||||||
jo.put(ATTR_UID, MarketConfig.getInstance().getBBSAttr().getBbsUid()); |
|
||||||
jo.put(ATTR_JAR_TIME, GeneralUtils.readFullVersionNO()); |
|
||||||
jo.put(ATTR_CLICK_NUMBER, this.clickNumber); |
|
||||||
jo.put(ATTR_USE_NUMBER, this.useNumber); |
|
||||||
jo.put(ATTR_TIME, DateTime.now().toString(SIMPLE_DATE_PATTERN)); |
|
||||||
return jo.toString(); |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
@Override |
|
||||||
public void readXML(XMLableReader reader) { |
|
||||||
if (reader.isAttr()) { |
|
||||||
String name = reader.getTagName(); |
|
||||||
if (XML_TAG.equals(name)) { |
|
||||||
this.clickNumber = reader.getAttrAsInt(ATTR_CLICK_NUMBER, 0); |
|
||||||
this.useNumber = reader.getAttrAsInt(ATTR_USE_NUMBER, 0); |
|
||||||
this.lastSendTime = reader.getAttrAsLong(XML_LAST_TIME, System.currentTimeMillis()); |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public void writeXML(XMLPrintWriter writer) { |
|
||||||
writer.startTAG(XML_TAG); |
|
||||||
writer.attr(ATTR_CLICK_NUMBER, this.clickNumber).attr(ATTR_USE_NUMBER, this.useNumber) |
|
||||||
.attr(XML_LAST_TIME, this.lastSendTime); |
|
||||||
writer.end(); |
|
||||||
} |
|
||||||
} |
|
@ -1,59 +1,197 @@ |
|||||||
package com.fr.design.style.background.impl; |
package com.fr.design.style.background.impl; |
||||||
|
|
||||||
|
import com.fr.base.GraphHelper; |
||||||
|
import com.fr.base.background.TextureBackground; |
||||||
import com.fr.design.layout.FRGUIPaneFactory; |
import com.fr.design.layout.FRGUIPaneFactory; |
||||||
import com.fr.design.style.background.BackgroundDetailPane; |
|
||||||
import com.fr.design.style.background.texture.TextureDetailPane; |
|
||||||
import com.fr.general.Background; |
import com.fr.general.Background; |
||||||
|
import com.fr.general.ComparatorUtils; |
||||||
|
|
||||||
|
|
||||||
import javax.swing.BorderFactory; |
import javax.swing.*; |
||||||
import javax.swing.JPanel; |
import javax.swing.event.ChangeEvent; |
||||||
import javax.swing.event.ChangeListener; |
import javax.swing.event.ChangeListener; |
||||||
import java.awt.BorderLayout; |
import java.awt.*; |
||||||
|
import java.awt.event.ActionEvent; |
||||||
|
import java.awt.event.ActionListener; |
||||||
|
import java.awt.geom.Rectangle2D; |
||||||
|
|
||||||
/** |
/** |
||||||
* Texture background pane. TODO kunsnat: 拆出去. 真特么的长.. |
* Texture background pane. TODO kunsnat: 拆出去. 真特么的长.. |
||||||
*/ |
*/ |
||||||
public class TextureBackgroundPane extends BackgroundDetailPane { |
public class TextureBackgroundPane extends BPane { |
||||||
|
|
||||||
|
private static final TexturePaint[] EMBED_TEXTURE_PAINT_ARRAY = new TexturePaint[]{ |
||||||
private TextureDetailPane detailPane; |
TextureBackground.NEWSPRINT_TEXTURE_PAINT, |
||||||
|
TextureBackground.RECYCLED_PAPER_TEXTURE_PAINT, |
||||||
|
TextureBackground.PARCHMENT_TEXTURE_PAINT, |
||||||
|
TextureBackground.STATIONERY_TEXTURE_PAINT, |
||||||
|
TextureBackground.GREEN_MARBLE_TEXTURE_PAINT, |
||||||
|
TextureBackground.WHITE_MARBLE_TEXTURE_PAINT, |
||||||
|
TextureBackground.BROWN_MARBLE_TEXTURE_PAINT, |
||||||
|
TextureBackground.GRANITE_TEXTURE_PAINT, |
||||||
|
TextureBackground.BLUE_TISSUE_PAPER_TEXTURE_PAINT, |
||||||
|
TextureBackground.PINK_TISSUE_PAPER_TEXTURE_PAINT, |
||||||
|
TextureBackground.PURPLE_MESH_TEXTURE_PAINT, |
||||||
|
TextureBackground.BOUQUET_TEXTURE_PAINT, |
||||||
|
TextureBackground.PAPYRUS_TEXTURE_PAINT, |
||||||
|
TextureBackground.CANVAS_TEXTURE_PAINT, |
||||||
|
TextureBackground.DENIM_TEXTURE_PAINT, |
||||||
|
TextureBackground.WOVEN_MAT_TEXTURE_PAINT, |
||||||
|
TextureBackground.WATER_DROPLETS_TEXTURE_PAINT, |
||||||
|
TextureBackground.PAPER_BAG_TEXTURE_PAINT, |
||||||
|
TextureBackground.FISH_FOSSIL_TEXTURE_PAINT, |
||||||
|
TextureBackground.SAND_TEXTURE_PAINT, |
||||||
|
TextureBackground.CORK_TEXTURE_PAINT, |
||||||
|
TextureBackground.WALNUT_TEXTURE_PAINT, |
||||||
|
TextureBackground.OAK_TEXTURE_PAINT, |
||||||
|
TextureBackground.MEDIUM_WOOD_TEXTURE_PAINT}; |
||||||
|
|
||||||
|
private static final String[] EMBED_TEXTURE_PAINT_DES_ARRAY = new String[]{ |
||||||
|
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Background_Texture_Newsprint"), |
||||||
|
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Background_Texture_Recycled_Paper"), |
||||||
|
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Background_Texture_Parchment"), |
||||||
|
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Background_Texture_Stationery"), |
||||||
|
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Background_Texture_Green_Marble"), |
||||||
|
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Background_Texture_White_Marble"), |
||||||
|
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Background_Texture_Brown_Marble"), |
||||||
|
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Background_Texture_Granite"), |
||||||
|
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Background_Texture_Blue_Tissue_Paper"), |
||||||
|
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Background_Texture_Pink_Tissue_Paper"), |
||||||
|
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Background_Texture_Purple_Mesh"), |
||||||
|
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Background_Texture_Bouquet"), |
||||||
|
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Background_Texture_Papyrus"), |
||||||
|
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Background_Texture_Canvas"), |
||||||
|
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Background_Texture_Denim"), |
||||||
|
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Background_Texture_Woven_Mat"), |
||||||
|
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Background_Texture_Water_Droplets"), |
||||||
|
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Background_Texture_PaperBag"), |
||||||
|
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Background_Texture_FishFossil"), |
||||||
|
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Background_Texture_Sand"), |
||||||
|
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Background_Texture_Cork"), |
||||||
|
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Background_Texture_Walnut"), |
||||||
|
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Background_Texture_Oak"), |
||||||
|
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Background_Texture_Medium_Wood") |
||||||
|
}; |
||||||
|
|
||||||
|
private TexturePaint texturePaint; |
||||||
|
private TextureButton[] textureButtonArray; |
||||||
|
|
||||||
public TextureBackgroundPane() { |
public TextureBackgroundPane() { |
||||||
this(8);// 默认的.
|
super(8);// 默认的.
|
||||||
} |
} |
||||||
|
|
||||||
public TextureBackgroundPane(int column) { |
public TextureBackgroundPane(int colum) { |
||||||
this.detailPane = TextureDetailPane.createNormalTextureDetailPane(column); |
super(colum);// 自定义的.
|
||||||
this.setLayout(FRGUIPaneFactory.createBorderLayout()); |
|
||||||
this.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4)); |
|
||||||
|
|
||||||
JPanel contentPane = FRGUIPaneFactory.createY_AXISBoxInnerContainer_S_Pane(); |
|
||||||
this.add(contentPane, BorderLayout.NORTH); |
|
||||||
|
|
||||||
JPanel typePane = FRGUIPaneFactory.createTitledBorderPane(titleOfTypePane()); |
|
||||||
contentPane.add(typePane); |
|
||||||
typePane.add(this.detailPane); |
|
||||||
} |
} |
||||||
|
|
||||||
|
protected LayoutManager layoutOfTypePane(int nColumn) { |
||||||
|
return FRGUIPaneFactory.createNColumnGridLayout(nColumn); |
||||||
|
} |
||||||
|
|
||||||
protected String titleOfTypePane() { |
protected String titleOfTypePane() { |
||||||
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Background_Texture"); |
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Background_Texture"); |
||||||
} |
} |
||||||
|
protected void setChildrenOfTypePane(JPanel typePane2) { |
||||||
|
ButtonGroup patternButtonGroup = new ButtonGroup(); |
||||||
|
textureButtonArray = new TextureButton[EMBED_TEXTURE_PAINT_ARRAY.length]; |
||||||
|
for (int i = 0; i < EMBED_TEXTURE_PAINT_ARRAY.length; i++) { |
||||||
|
textureButtonArray[i] = new TextureButton( |
||||||
|
EMBED_TEXTURE_PAINT_ARRAY[i], EMBED_TEXTURE_PAINT_DES_ARRAY[i]); |
||||||
|
patternButtonGroup.add(textureButtonArray[i]); |
||||||
|
typePane2.add(textureButtonArray[i]); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
public void populate(Background background) { |
public void populate(Background background) { |
||||||
this.detailPane.populate(background); |
if (background instanceof TextureBackground) { |
||||||
|
TextureBackground textureBackground = (TextureBackground) background; |
||||||
|
|
||||||
|
this.texturePaint = textureBackground.getTexturePaint(); |
||||||
|
|
||||||
|
for (int i = 0; i < textureButtonArray.length; i++) { |
||||||
|
if (ComparatorUtils.equals(textureButtonArray[i].getTexturePaint(), this.texturePaint)) { |
||||||
|
textureButtonArray[i].setSelected(true); |
||||||
|
break; |
||||||
|
} |
||||||
|
} |
||||||
|
} else { |
||||||
|
this.textureButtonArray[0].setSelected(true); |
||||||
|
this.texturePaint = textureButtonArray[0].getTexturePaint(); |
||||||
|
} |
||||||
} |
} |
||||||
|
|
||||||
public Background update() throws Exception { |
public Background update() throws Exception { |
||||||
return this.detailPane.update(); |
return new TextureBackground(this.texturePaint); |
||||||
} |
} |
||||||
|
|
||||||
@Override |
|
||||||
public void addChangeListener(ChangeListener changeListener) { |
public void addChangeListener(ChangeListener changeListener) { |
||||||
this.detailPane.addChangeListener(changeListener); |
for (int i = 0; i < this.textureButtonArray.length; i++) { |
||||||
|
this.textureButtonArray[i].addChangeListener(changeListener); |
||||||
|
} |
||||||
} |
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Texture type button. |
||||||
|
*/ |
||||||
|
class TextureButton extends JToggleButton implements ActionListener { |
||||||
|
|
||||||
|
private TexturePaint buttonTexturePaint; |
||||||
|
|
||||||
|
public TextureButton(TexturePaint buttonTexturePaint, String tooltip) { |
||||||
|
this.buttonTexturePaint = buttonTexturePaint; |
||||||
|
this.setToolTipText(tooltip); |
||||||
|
|
||||||
|
this.setCursor(new Cursor(Cursor.HAND_CURSOR)); |
||||||
|
this.addActionListener(this); |
||||||
|
this.setBorder(null); |
||||||
|
} |
||||||
|
|
||||||
|
public void paintComponent(Graphics g) { |
||||||
|
Graphics2D g2d = (Graphics2D) g; |
||||||
|
|
||||||
|
Dimension d = getSize(); |
||||||
|
|
||||||
|
g2d.setPaint(this.buttonTexturePaint); |
||||||
|
GraphHelper.fill(g2d, new Rectangle2D.Double(0, 0, d.width - 1d, |
||||||
|
d.height - 1d)); |
||||||
|
|
||||||
|
if (ComparatorUtils.equals(texturePaint, this.buttonTexturePaint)) {// it's
|
||||||
|
// selected.
|
||||||
|
g2d.setPaint(Color.black); |
||||||
|
} else { |
||||||
|
g2d.setPaint(Color.gray); |
||||||
|
} |
||||||
|
GraphHelper.draw(g2d, new Rectangle2D.Double(0, 0, d.width - 1d, |
||||||
|
d.height - 1d)); |
||||||
|
} |
||||||
|
|
||||||
|
public Dimension getPreferredSize() { |
||||||
|
return new Dimension(36, 32); |
||||||
|
} |
||||||
|
|
||||||
|
public TexturePaint getTexturePaint() { |
||||||
|
return this.buttonTexturePaint; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* set Pattern setIndex. |
||||||
|
*/ |
||||||
|
public void actionPerformed(ActionEvent evt) { |
||||||
|
TextureBackgroundPane.this.texturePaint = this.getTexturePaint(); |
||||||
|
|
||||||
|
fireChagneListener(); |
||||||
|
TextureBackgroundPane.this.repaint(); // repaint.
|
||||||
|
} |
||||||
|
|
||||||
|
public void addChangeListener(ChangeListener changeListener) { |
||||||
|
this.changeListener = changeListener; |
||||||
|
} |
||||||
|
|
||||||
|
private void fireChagneListener() { |
||||||
|
if (this.changeListener != null) { |
||||||
|
ChangeEvent evt = new ChangeEvent(this); |
||||||
|
this.changeListener.stateChanged(evt); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
} |
} |
||||||
|
@ -1,97 +0,0 @@ |
|||||||
package com.fr.design.mainframe.predefined.info; |
|
||||||
|
|
||||||
import com.fr.config.BBSAttr; |
|
||||||
import com.fr.config.MarketConfig; |
|
||||||
import com.fr.design.DesignerEnvManager; |
|
||||||
import com.fr.general.GeneralUtils; |
|
||||||
import com.fr.json.JSON; |
|
||||||
import com.fr.json.JSONFactory; |
|
||||||
import com.fr.json.JSONObject; |
|
||||||
import com.fr.stable.ProductConstants; |
|
||||||
import com.fr.third.org.apache.commons.io.FileUtils; |
|
||||||
import org.easymock.EasyMock; |
|
||||||
import org.junit.After; |
|
||||||
import org.junit.Assert; |
|
||||||
import org.junit.Before; |
|
||||||
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; |
|
||||||
import java.io.IOException; |
|
||||||
|
|
||||||
/** |
|
||||||
* Created by kerry on 2020-09-05 |
|
||||||
*/ |
|
||||||
@RunWith(PowerMockRunner.class) |
|
||||||
@PrepareForTest({ProductConstants.class, MarketConfig.class, DesignerEnvManager.class, GeneralUtils.class}) |
|
||||||
@SuppressStaticInitializationFor({"com.fr.jvm.assist.FineAssist"}) |
|
||||||
public class PredefinedStyleInfoCollectorTest { |
|
||||||
private String filePath; |
|
||||||
private String initialFileContent; |
|
||||||
|
|
||||||
|
|
||||||
@Before |
|
||||||
public void setUp() throws IOException { |
|
||||||
PowerMock.mockStatic(ProductConstants.class); |
|
||||||
|
|
||||||
filePath = getClass().getResource("predefinedStyle.info").getPath(); |
|
||||||
String dirPath = filePath.substring(0, filePath.indexOf("predefinedStyle.info")); |
|
||||||
EasyMock.expect(ProductConstants.getEnvHome()).andReturn(dirPath).anyTimes(); |
|
||||||
|
|
||||||
EasyMock.replay(); |
|
||||||
PowerMock.replayAll(); |
|
||||||
initialFileContent = FileUtils.readFileToString(new File(filePath), "utf-8"); |
|
||||||
} |
|
||||||
|
|
||||||
@After |
|
||||||
public void tearDown() throws IOException { |
|
||||||
FileUtils.writeStringToFile(new File(filePath), initialFileContent, "utf-8"); |
|
||||||
} |
|
||||||
|
|
||||||
@Test |
|
||||||
public void testCollectClickNumber() { |
|
||||||
PredefinedStyleInfoCollector.getInstance().collectClickNumber(); |
|
||||||
Assert.assertEquals(1, PredefinedStyleInfoCollector.getInstance().getClickNumber()); |
|
||||||
} |
|
||||||
|
|
||||||
@Test |
|
||||||
public void testCollectUseNumber() { |
|
||||||
PredefinedStyleInfoCollector.getInstance().collectUseNumber("test"); |
|
||||||
Assert.assertEquals(1, PredefinedStyleInfoCollector.getInstance().getUseNumber()); |
|
||||||
} |
|
||||||
|
|
||||||
@Test |
|
||||||
public void testGenerateTotalInfo() { |
|
||||||
PowerMock.mockStatic(DesignerEnvManager.class); |
|
||||||
PowerMock.mockStatic(MarketConfig.class); |
|
||||||
PowerMock.mockStatic(GeneralUtils.class); |
|
||||||
|
|
||||||
DesignerEnvManager envManager = EasyMock.mock(DesignerEnvManager.class); |
|
||||||
EasyMock.expect(envManager.getUUID()).andReturn("xxxxx-12345-xxxxx").once(); |
|
||||||
EasyMock.expect(DesignerEnvManager.getEnvManager()).andReturn(envManager).once(); |
|
||||||
|
|
||||||
|
|
||||||
MarketConfig marketConfig = EasyMock.mock(MarketConfig.class); |
|
||||||
BBSAttr bbsAttr = new BBSAttr(); |
|
||||||
bbsAttr.setBbsUid(12345); |
|
||||||
EasyMock.expect(marketConfig.getBBSAttr()).andReturn(bbsAttr).once(); |
|
||||||
EasyMock.expect(MarketConfig.getInstance()).andReturn(marketConfig).once(); |
|
||||||
|
|
||||||
EasyMock.expect(GeneralUtils.readFullVersionNO()).andReturn("10.0.9.2020.0817.final"); |
|
||||||
|
|
||||||
EasyMock.replay(envManager, marketConfig); |
|
||||||
|
|
||||||
PowerMock.replayAll(); |
|
||||||
String content = PredefinedStyleInfoCollector.getInstance().generateTotalInfo(); |
|
||||||
JSONObject jsonObject = JSONFactory.createJSON(JSON.OBJECT, content); |
|
||||||
Assert.assertEquals("predefinedStyle", jsonObject.getString("functionName")); |
|
||||||
Assert.assertEquals("FR-F7003", jsonObject.getString("functionId")); |
|
||||||
Assert.assertEquals("xxxxx-12345-xxxxx", jsonObject.getString("uuid")); |
|
||||||
Assert.assertEquals(12345, jsonObject.getInt("uid")); |
|
||||||
Assert.assertEquals("10.0.9.2020.0817.final", jsonObject.getString("jatTime")); |
|
||||||
} |
|
||||||
|
|
||||||
} |
|
@ -1,2 +0,0 @@ |
|||||||
<?xml version="1.0" encoding="UTF-8"?> |
|
||||||
<PredefinedStyleInfo xmlVersion="20170720" releaseVersion="10.0.0" clickNumber="0" useNumber="0"/> |
|
Loading…
Reference in new issue