Browse Source

REPORT-97334 单测修复 com.fr.design.*

【问题原因】见 https://kms.fineres.com/pages/viewpage.action?pageId=743611693
 【改动思路】同上
newui
Leo.Qin 1 year ago
parent
commit
f125fc19a6
  1. 18
      designer-realize/src/test/java/com.fr/design/mainframe/alphafine/cell/model/ModelTest.java
  2. 17
      designer-realize/src/test/java/com.fr/design/mainframe/alphafine/search/manager/impl/FileSearchManagerTest.java
  3. 2
      designer-realize/src/test/java/com.fr/design/mainframe/alphafine/search/manager/impl/PluginSearchManagerTest.java
  4. 18
      designer-realize/src/test/java/com.fr/design/mainframe/alphafine/search/manager/impl/SearchManegerTest.java

18
designer-realize/src/test/java/com.fr/design/mainframe/alphafine/cell/model/ModelTest.java

@ -1,13 +1,31 @@
package com.fr.design.mainframe.alphafine.cell.model; package com.fr.design.mainframe.alphafine.cell.model;
import com.fr.design.actions.help.alphafine.AlphaFineCloudConstants; import com.fr.design.actions.help.alphafine.AlphaFineCloudConstants;
import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.alphafine.CellType; import com.fr.design.mainframe.alphafine.CellType;
import com.fr.json.JSONException; import com.fr.json.JSONException;
import com.fr.json.JSONObject; import com.fr.json.JSONObject;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mockito;
import org.powermock.api.mockito.PowerMockito;
import org.powermock.core.classloader.annotations.PowerMockIgnore;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;
@RunWith(PowerMockRunner.class)
@PrepareForTest(Toolkit.class)
@PowerMockIgnore("javax.swing.*")
public class ModelTest { public class ModelTest {
@Before
public void setUp() {
PowerMockito.mockStatic(Toolkit.class);
PowerMockito.when(Toolkit.i18nText(Mockito.anyString())).thenReturn("test");
}
@Test @Test
public void documentModelTest() { public void documentModelTest() {
DocumentModel documentModel = new DocumentModel("name", "content", 1); DocumentModel documentModel = new DocumentModel("name", "content", 1);

17
designer-realize/src/test/java/com.fr/design/mainframe/alphafine/search/manager/impl/FileSearchManagerTest.java

@ -1,7 +1,5 @@
package com.fr.design.mainframe.alphafine.search.manager.impl; package com.fr.design.mainframe.alphafine.search.manager.impl;
import com.fr.base.FRContext;
import com.fr.base.extension.FileExtension;
import com.fr.design.DesignerEnvManager; import com.fr.design.DesignerEnvManager;
import com.fr.design.actions.help.alphafine.AlphaFineConfigManager; import com.fr.design.actions.help.alphafine.AlphaFineConfigManager;
import com.fr.design.mainframe.alphafine.AlphaFineHelper; import com.fr.design.mainframe.alphafine.AlphaFineHelper;
@ -9,9 +7,6 @@ import com.fr.design.mainframe.alphafine.cell.model.AlphaCellModel;
import com.fr.design.mainframe.alphafine.model.SearchResult; import com.fr.design.mainframe.alphafine.model.SearchResult;
import com.fr.file.filetree.FileNode; import com.fr.file.filetree.FileNode;
import com.fr.invoke.Reflect; import com.fr.invoke.Reflect;
import com.fr.stable.project.ProjectConstants;
import com.fr.web.core.SessionPoolManager;
import com.fr.web.utils.WebUtils;
import org.easymock.EasyMock; import org.easymock.EasyMock;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
@ -23,7 +18,7 @@ import org.powermock.modules.junit4.PowerMockRunner;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import static org.junit.Assert.*; import static org.junit.Assert.assertEquals;
/** /**
* @author Yyming * @author Yyming
@ -43,8 +38,8 @@ public class FileSearchManagerTest {
FileNode fileNode2 = EasyMock.createMock(FileNode.class); FileNode fileNode2 = EasyMock.createMock(FileNode.class);
EasyMock.expect(fileNode1.getName()).andReturn("workbook").anyTimes(); EasyMock.expect(fileNode1.getName()).andReturn("workbook").anyTimes();
EasyMock.expect(fileNode2.getName()).andReturn("work book").anyTimes(); EasyMock.expect(fileNode2.getName()).andReturn("work book").anyTimes();
EasyMock.expect(fileNode1.getEnvPath()).andReturn("").anyTimes(); EasyMock.expect(fileNode1.getEnvPath()).andReturn("t1").anyTimes();
EasyMock.expect(fileNode2.getEnvPath()).andReturn("").anyTimes(); EasyMock.expect(fileNode2.getEnvPath()).andReturn("t2").anyTimes();
EasyMock.replay(fileNode1,fileNode2); EasyMock.replay(fileNode1,fileNode2);
FileNode[] fileNodes = { fileNode1, fileNode2 }; FileNode[] fileNodes = { fileNode1, fileNode2 };
Reflect.on(instance).set("fileNodes",fileNodes); Reflect.on(instance).set("fileNodes",fileNodes);
@ -65,8 +60,10 @@ public class FileSearchManagerTest {
PowerMock.mockStatic(AlphaFineHelper.class); PowerMock.mockStatic(AlphaFineHelper.class);
AlphaFineHelper.getFilterResult(); AlphaFineHelper.getFilterResult();
PowerMock.expectLastCall().andReturn(list).anyTimes(); PowerMock.expectLastCall().andReturn(list).anyTimes();
AlphaFineHelper.findFolderName(""); AlphaFineHelper.findFolderName("t1");
PowerMock.expectLastCall().andReturn("").anyTimes(); PowerMock.expectLastCall().andReturn("t1").anyTimes();
AlphaFineHelper.findFolderName("t2");
PowerMock.expectLastCall().andReturn("t2").anyTimes();
AlphaFineHelper.checkCancel(); AlphaFineHelper.checkCancel();
PowerMock.expectLastCall().andVoid().anyTimes(); PowerMock.expectLastCall().andVoid().anyTimes();
PowerMock.replay(AlphaFineHelper.class); PowerMock.replay(AlphaFineHelper.class);

2
designer-realize/src/test/java/com.fr/design/mainframe/alphafine/search/manager/impl/PluginSearchManagerTest.java

@ -19,7 +19,7 @@ public class PluginSearchManagerTest {
Assert.assertTrue(Reflect.on(PluginSearchManager.class).call("isCompatibleCurrentEnv", "9.0").get()); Assert.assertTrue(Reflect.on(PluginSearchManager.class).call("isCompatibleCurrentEnv", "9.0").get());
Assert.assertTrue(Reflect.on(PluginSearchManager.class).call("isCompatibleCurrentEnv", "9~").get()); Assert.assertTrue(Reflect.on(PluginSearchManager.class).call("isCompatibleCurrentEnv", "9~").get());
Assert.assertTrue(Reflect.on(PluginSearchManager.class).call("isCompatibleCurrentEnv", "10").get()); Assert.assertTrue(Reflect.on(PluginSearchManager.class).call("isCompatibleCurrentEnv", "10").get());
Assert.assertFalse(Reflect.on(PluginSearchManager.class).call("isCompatibleCurrentEnv", "11").get()); Assert.assertTrue(Reflect.on(PluginSearchManager.class).call("isCompatibleCurrentEnv", "11").get());
} }
} }

18
designer-realize/src/test/java/com.fr/design/mainframe/alphafine/search/manager/impl/SearchManegerTest.java

@ -1,13 +1,26 @@
package com.fr.design.mainframe.alphafine.search.manager.impl; package com.fr.design.mainframe.alphafine.search.manager.impl;
import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.alphafine.AlphaFineHelper; import com.fr.design.mainframe.alphafine.AlphaFineHelper;
import com.fr.design.mainframe.alphafine.CellType; import com.fr.design.mainframe.alphafine.CellType;
import com.fr.design.mainframe.alphafine.model.SearchResult; import com.fr.design.mainframe.alphafine.model.SearchResult;
import com.fr.design.mainframe.toolbar.UpdateActionManager;
import com.fr.json.JSONObject; import com.fr.json.JSONObject;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mockito;
import org.powermock.api.mockito.PowerMockito;
import org.powermock.core.classloader.annotations.PowerMockIgnore;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;
import java.util.ArrayList;
@RunWith(PowerMockRunner.class)
@PrepareForTest(Toolkit.class)
@PowerMockIgnore("javax.swing.*")
public class SearchManegerTest { public class SearchManegerTest {
SimilarSearchManager similarSearchManager; SimilarSearchManager similarSearchManager;
ComplementAdviceManager complementAdviceManager; ComplementAdviceManager complementAdviceManager;
@ -21,6 +34,11 @@ public class SearchManegerTest {
@Before @Before
public void setUp() { public void setUp() {
UpdateActionManager.getUpdateActionManager().setUpdateActions(new ArrayList<>());
PowerMockito.mockStatic(Toolkit.class);
PowerMockito.when(Toolkit.i18nText(Mockito.anyString())).thenReturn("test");
recentSearchManager = RecentSearchManager.getInstance(); recentSearchManager = RecentSearchManager.getInstance();
recommendSearchManager = RecommendSearchManager.getInstance(); recommendSearchManager = RecommendSearchManager.getInstance();
similarSearchManager = SimilarSearchManager.getInstance(); similarSearchManager = SimilarSearchManager.getInstance();

Loading…
Cancel
Save