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