alex.sung
6 years ago
3 changed files with 214 additions and 0 deletions
@ -0,0 +1,77 @@
|
||||
package com.fr.design.mainframe.alphafine.cell.model; |
||||
|
||||
import com.fr.design.mainframe.alphafine.AlphaFineConstants; |
||||
import com.fr.design.mainframe.alphafine.CellType; |
||||
import com.fr.json.JSONException; |
||||
import com.fr.json.JSONObject; |
||||
import org.junit.Assert; |
||||
import org.junit.Test; |
||||
|
||||
public class ModelTest { |
||||
@Test |
||||
public void documentModelTest(){ |
||||
DocumentModel documentModel = new DocumentModel("name","content",1); |
||||
Assert.assertEquals("name",documentModel.getName()); |
||||
Assert.assertEquals("content",documentModel.getContent()); |
||||
Assert.assertEquals(1,documentModel.getDocumentId()); |
||||
Assert.assertEquals(AlphaFineConstants.DOCUMENT_DOC_URL + documentModel.getDocumentId() + ".html", documentModel.getDocumentUrl()); |
||||
Assert.assertEquals(AlphaFineConstants.DOCUMENT_INFORMATION_URL + documentModel.getDocumentId(), documentModel.getInformationUrl()); |
||||
Assert.assertEquals(documentModel.getStoreInformation(), documentModel.getInformationUrl()); |
||||
Assert.assertEquals(CellType.DOCUMENT, documentModel.getType()); |
||||
Assert.assertEquals(true, documentModel.hasAction()); |
||||
Assert.assertEquals(true, documentModel.isNeedToSendToServer()); |
||||
|
||||
documentModel.setDescription("test"); |
||||
Assert.assertEquals("test", documentModel.getDescription()); |
||||
|
||||
DocumentModel another = new DocumentModel("another","another",1); |
||||
documentModel.doAction(); |
||||
Assert.assertTrue(another.equals(documentModel)); |
||||
Assert.assertNotNull(documentModel.modelToJson()); |
||||
} |
||||
|
||||
@Test |
||||
public void bottomModelTest(){ |
||||
BottomModel bottomModel = new BottomModel(); |
||||
Assert.assertEquals(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_AlphaFine_Internet_Forum"), bottomModel.getGoToWeb()); |
||||
Assert.assertEquals(CellType.BOTTOM, bottomModel.getType()); |
||||
try { |
||||
Assert.assertEquals(JSONObject.EMPTY, bottomModel.modelToJson()); |
||||
} catch (JSONException e) { |
||||
e.printStackTrace(); |
||||
} |
||||
Assert.assertEquals(true, bottomModel.hasAction()); |
||||
bottomModel.doAction(); |
||||
|
||||
} |
||||
|
||||
@Test |
||||
public void fileModelTest(){ |
||||
FileModel fileModel = new FileModel("name", "test\\\\"); |
||||
Assert.assertEquals(CellType.FILE, fileModel.getType()); |
||||
Assert.assertNotNull(fileModel.modelToJson()); |
||||
FileModel anotherFileModel = new FileModel("anotherFileModel", "test\\\\"); |
||||
Assert.assertTrue(anotherFileModel.equals(fileModel)); |
||||
} |
||||
|
||||
@Test |
||||
public void moreModelTest(){ |
||||
MoreModel moreModel = new MoreModel("name"); |
||||
Assert.assertTrue(!moreModel.hasAction()); |
||||
Assert.assertTrue(!moreModel.isNeedToSendToServer()); |
||||
Assert.assertEquals(CellType.MORE, moreModel.getType()); |
||||
} |
||||
|
||||
@Test |
||||
public void noResultModelTest(){ |
||||
NoResultModel noResultModel = new NoResultModel("test"); |
||||
Assert.assertTrue(!noResultModel.hasAction()); |
||||
Assert.assertTrue(!noResultModel.isNeedToSendToServer()); |
||||
Assert.assertEquals(CellType.NO_RESULT, noResultModel.getType()); |
||||
} |
||||
|
||||
@Test |
||||
public void pluginModelTest(){ |
||||
// PluginModel pluginModel = new PluginModel("name","content");
|
||||
} |
||||
} |
@ -0,0 +1,33 @@
|
||||
package com.fr.design.mainframe.alphafine.component; |
||||
|
||||
import org.junit.Before; |
||||
import org.junit.Test; |
||||
|
||||
public class AlphaFineDialogTest { |
||||
|
||||
// AlphaFineDialog alphaFineDialog;
|
||||
|
||||
@Before |
||||
public void setUp() { |
||||
// alphaFineDialog = EasyMock.createMock(AlphaFineDialog.class);
|
||||
|
||||
} |
||||
|
||||
|
||||
@Test |
||||
public void doNormalSearchTest() { |
||||
// try {
|
||||
// EasyMock.expect(AlphaFineConfigManager.isALPHALicAvailable()).andReturn(true);
|
||||
// AlphaFineHelper.showAlphaFineDialog(false);
|
||||
// Method format = AlphaFineDialog.class.getDeclaredMethod("doNormalSearch", String.class);
|
||||
// format.setAccessible(true);
|
||||
// EasyMock.expect(alphaFineDialog.getSegmentationResult()).andReturn(new String[]{"数据集"});
|
||||
// format.invoke(alphaFineDialog, "数据集");
|
||||
//// EasyMock.replay(alphaFineDialog);
|
||||
// Assert.assertNotNull(alphaFineDialog.getSegmentationResult());
|
||||
// } catch (Exception e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
|
||||
} |
||||
} |
@ -0,0 +1,104 @@
|
||||
package com.fr.design.mainframe.alphafine.search.manager.impl; |
||||
|
||||
import com.fr.design.mainframe.alphafine.AlphaFineHelper; |
||||
import com.fr.design.mainframe.alphafine.CellType; |
||||
import com.fr.design.mainframe.alphafine.model.SearchResult; |
||||
import com.fr.json.JSONObject; |
||||
import org.junit.Assert; |
||||
import org.junit.Before; |
||||
import org.junit.Test; |
||||
|
||||
public class SearchManegerTest { |
||||
SimilarSearchManeger similarSearchManeger; |
||||
ComplementAdviceManager complementAdviceManager; |
||||
DocumentSearchManager documentSearchManager; |
||||
PluginSearchManager pluginSearchManager; |
||||
RecommendSearchManager recommendSearchManager; |
||||
RecentSearchManager recentSearchManager; |
||||
ActionSearchManager actionSearchManager; |
||||
FileSearchManager fileSearchManager; |
||||
SegmentationManager segmentationManager; |
||||
|
||||
@Before |
||||
public void setUp() { |
||||
recentSearchManager = RecentSearchManager.getInstance(); |
||||
recommendSearchManager = RecommendSearchManager.getInstance(); |
||||
similarSearchManeger = SimilarSearchManeger.getInstance(); |
||||
complementAdviceManager = ComplementAdviceManager.getInstance(); |
||||
documentSearchManager = DocumentSearchManager.getInstance(); |
||||
pluginSearchManager = PluginSearchManager.getInstance(); |
||||
actionSearchManager = ActionSearchManager.getInstance(); |
||||
fileSearchManager = FileSearchManager.getInstance(); |
||||
segmentationManager = SegmentationManager.getInstance(); |
||||
} |
||||
|
||||
@Test |
||||
public void getSearchResultTest() { |
||||
|
||||
//断网情况
|
||||
SearchResult noConnectList; |
||||
noConnectList = similarSearchManeger.getLessSearchResult(new String[]{"数据集"}); |
||||
Assert.assertEquals(noConnectList.get(1).getName(), AlphaFineHelper.getNoConnectList(similarSearchManeger).get(1).getName()); |
||||
|
||||
noConnectList = documentSearchManager.getLessSearchResult(new String[]{"数据集"}); |
||||
Assert.assertEquals(noConnectList.get(1).getName(), AlphaFineHelper.getNoConnectList(documentSearchManager).get(1).getName()); |
||||
|
||||
noConnectList = pluginSearchManager.getLessSearchResult(new String[]{"数据集"}); |
||||
Assert.assertEquals(noConnectList.get(1).getName(), AlphaFineHelper.getNoConnectList(pluginSearchManager).get(1).getName()); |
||||
|
||||
noConnectList = recommendSearchManager.getLessSearchResult(new String[]{"数据集"}); |
||||
Assert.assertEquals(noConnectList.get(1).getName(), AlphaFineHelper.getNoConnectList(recommendSearchManager).get(1).getName()); |
||||
|
||||
//正常搜索情况
|
||||
String[][] hotData = HotIssuesManager.getInstance().getHotIssues(); |
||||
SearchResult lessModelList; |
||||
lessModelList = recentSearchManager.getLessSearchResult(new String[]{"数据集"}); |
||||
Assert.assertNotNull(lessModelList); |
||||
|
||||
lessModelList = similarSearchManeger.getLessSearchResult(new String[]{"数据集"}); |
||||
Assert.assertEquals(lessModelList.get(1).getType(), CellType.ROBOT); |
||||
|
||||
lessModelList = complementAdviceManager.getAllSearchResult(new String[]{"数据集"}); |
||||
Assert.assertEquals(lessModelList.get(1).getType(), CellType.ROBOT); |
||||
|
||||
lessModelList = documentSearchManager.getLessSearchResult(new String[]{"数据集"}); |
||||
Assert.assertEquals(lessModelList.get(1).getType(), CellType.DOCUMENT); |
||||
|
||||
lessModelList = pluginSearchManager.getLessSearchResult(new String[]{"数据集"}); |
||||
Assert.assertEquals(lessModelList.get(1).getType(), CellType.PLUGIN); |
||||
|
||||
//返回MoreSearchResult
|
||||
SearchResult moreModelList; |
||||
moreModelList = similarSearchManeger.getMoreSearchResult("数据集"); |
||||
Assert.assertNotNull(moreModelList); |
||||
|
||||
moreModelList = documentSearchManager.getMoreSearchResult("数据集"); |
||||
Assert.assertNotNull(moreModelList); |
||||
|
||||
moreModelList = pluginSearchManager.getMoreSearchResult("数据集"); |
||||
Assert.assertNotNull(moreModelList); |
||||
|
||||
moreModelList = recommendSearchManager.getMoreSearchResult("数据集"); |
||||
Assert.assertNotNull(moreModelList); |
||||
} |
||||
|
||||
@Test |
||||
public void getModelFromCloudTest() { |
||||
Assert.assertNotNull(SimilarSearchManeger.getModelFromCloud(new JSONObject())); |
||||
Assert.assertNotNull(DocumentSearchManager.getModelFromCloud(new JSONObject())); |
||||
Assert.assertNotNull(PluginSearchManager.getModelFromCloud(new JSONObject())); |
||||
} |
||||
|
||||
@Test |
||||
public void isNeedSegmentationTest() { |
||||
Assert.assertEquals(segmentationManager.isNeedSegmentation("多维数据集"), true); |
||||
} |
||||
|
||||
@Test |
||||
public void startSegmentationTest() { |
||||
String[] result = {"结果报表", "结果", "报表"}; |
||||
Assert.assertEquals(segmentationManager.startSegmentation("结果报表"), result); |
||||
|
||||
} |
||||
|
||||
} |
Loading…
Reference in new issue