|
|
|
@ -1,9 +1,9 @@
|
|
|
|
|
package com.fr.design.gui.itree.filetree; |
|
|
|
|
|
|
|
|
|
import com.fr.base.extension.FileExtension; |
|
|
|
|
import com.fr.design.ExtraDesignClassManager; |
|
|
|
|
import com.fr.design.fun.ReportSupportedFileUIProvider; |
|
|
|
|
import com.fr.design.fun.impl.AbstractReportSupportedFileUIProvider; |
|
|
|
|
import com.fr.report.ExtraReportClassManager; |
|
|
|
|
import com.fr.report.fun.ReportSupportedFileProvider; |
|
|
|
|
import com.fr.report.fun.impl.AbstractReportSupportedFileProvider; |
|
|
|
|
import com.fr.stable.fun.mark.Mutable; |
|
|
|
|
import org.easymock.EasyMock; |
|
|
|
|
import org.junit.Assert; |
|
|
|
@ -19,38 +19,38 @@ import java.util.Set;
|
|
|
|
|
* Created by alex sung on 2019/7/25. |
|
|
|
|
*/ |
|
|
|
|
@RunWith(PowerMockRunner.class) |
|
|
|
|
@PrepareForTest(ExtraDesignClassManager.class) |
|
|
|
|
@PrepareForTest(ExtraReportClassManager.class) |
|
|
|
|
public class FileNodeConstantsTest { |
|
|
|
|
@Test |
|
|
|
|
public void supportFileTypesTest() { |
|
|
|
|
ExtraDesignClassManager extra = mockExtraDesignClassManager(); |
|
|
|
|
Assert.assertEquals(1, extra.getArray(ReportSupportedFileUIProvider.XML_TAG).size()); |
|
|
|
|
ReportSupportedFileUIProvider option = (ReportSupportedFileUIProvider) extra.getArray(ReportSupportedFileUIProvider.XML_TAG).iterator().next(); |
|
|
|
|
ExtraReportClassManager extra = mockExtraReportClassManager(); |
|
|
|
|
Assert.assertEquals(1, extra.getArray(ReportSupportedFileProvider.XML_TAG).size()); |
|
|
|
|
ReportSupportedFileProvider option = (ReportSupportedFileProvider) extra.getArray(ReportSupportedFileProvider.XML_TAG).iterator().next(); |
|
|
|
|
Assert.assertEquals(FileExtension.CPTX, option.getFileExtensions()[0]); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
public void testSupportFileTypesOrder() { |
|
|
|
|
ExtraDesignClassManager extra = mockExtraDesignClassManager(); |
|
|
|
|
PowerMock.mockStatic(ExtraDesignClassManager.class); |
|
|
|
|
EasyMock.expect(ExtraDesignClassManager.getInstance()).andReturn(extra).once(); |
|
|
|
|
ExtraReportClassManager extra = mockExtraReportClassManager(); |
|
|
|
|
PowerMock.mockStatic(ExtraReportClassManager.class); |
|
|
|
|
EasyMock.expect(ExtraReportClassManager.getInstance()).andReturn(extra).once(); |
|
|
|
|
PowerMock.replayAll(); |
|
|
|
|
String[] fileTypes = FileNodeConstants.getSupportFileTypes(); |
|
|
|
|
Assert.assertEquals("cptx", fileTypes[0]); |
|
|
|
|
Assert.assertEquals("cpt", fileTypes[1]); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private ExtraDesignClassManager mockExtraDesignClassManager() { |
|
|
|
|
ExtraDesignClassManager extra = EasyMock.mock(ExtraDesignClassManager.class); |
|
|
|
|
private ExtraReportClassManager mockExtraReportClassManager() { |
|
|
|
|
ExtraReportClassManager extra = EasyMock.mock(ExtraReportClassManager.class); |
|
|
|
|
Set<Mutable> options = new HashSet<Mutable>() {{ |
|
|
|
|
add(new MockNewTemplateFileOption()); |
|
|
|
|
}}; |
|
|
|
|
EasyMock.expect(extra.getArray(ReportSupportedFileUIProvider.XML_TAG)).andReturn(options).anyTimes(); |
|
|
|
|
EasyMock.expect(extra.getArray(ReportSupportedFileProvider.XML_TAG)).andReturn(options).anyTimes(); |
|
|
|
|
EasyMock.replay(extra); |
|
|
|
|
return extra; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private class MockNewTemplateFileOption extends AbstractReportSupportedFileUIProvider { |
|
|
|
|
private class MockNewTemplateFileOption extends AbstractReportSupportedFileProvider { |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public FileExtension[] getFileExtensions() { |
|
|
|
|