|
|
|
@ -1,7 +1,14 @@
|
|
|
|
|
package com.fanruan.api.decision; |
|
|
|
|
|
|
|
|
|
import com.fr.decision.authorize.AuthorizeAttr; |
|
|
|
|
import com.fr.decision.config.FSConfig; |
|
|
|
|
import org.easymock.EasyMock; |
|
|
|
|
import org.junit.Assert; |
|
|
|
|
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.modules.junit4.PowerMockRunner; |
|
|
|
|
|
|
|
|
|
import java.lang.reflect.Method; |
|
|
|
|
|
|
|
|
@ -10,6 +17,8 @@ import java.lang.reflect.Method;
|
|
|
|
|
* @version 10.0 |
|
|
|
|
* Created by Zed on 2020/4/30 |
|
|
|
|
*/ |
|
|
|
|
@RunWith(PowerMockRunner.class) |
|
|
|
|
@PrepareForTest({FSConfig.class}) |
|
|
|
|
public class AuthorityKitTest { |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@ -27,4 +36,25 @@ public class AuthorityKitTest {
|
|
|
|
|
Method method3 = classBook.getDeclaredMethod("setDepAuth", String.class, int.class, String.class, int.class); |
|
|
|
|
Assert.assertNotNull(method3); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
public void testIsAuthorizeAttrOpen() { |
|
|
|
|
AuthorizeAttr authorizeAttr = EasyMock.createMock(AuthorizeAttr.class); |
|
|
|
|
EasyMock.expect(authorizeAttr.isGradeAuthority()).andReturn(true).anyTimes(); |
|
|
|
|
EasyMock.expect(authorizeAttr.isDataConnectionAuthority()).andReturn(true).anyTimes(); |
|
|
|
|
EasyMock.expect(authorizeAttr.isEditReportAuthority()).andReturn(true).anyTimes(); |
|
|
|
|
EasyMock.replay(authorizeAttr); |
|
|
|
|
|
|
|
|
|
FSConfig fsConfig = EasyMock.createMock(FSConfig.class); |
|
|
|
|
EasyMock.expect(fsConfig.getAuthorizeAttr()).andReturn(authorizeAttr).anyTimes(); |
|
|
|
|
EasyMock.replay(fsConfig); |
|
|
|
|
|
|
|
|
|
PowerMock.mockStatic(FSConfig.class); |
|
|
|
|
EasyMock.expect(FSConfig.getInstance()).andReturn(fsConfig).anyTimes(); |
|
|
|
|
PowerMock.replay(FSConfig.class); |
|
|
|
|
|
|
|
|
|
Assert.assertEquals(AuthorityKit.isGradeAuthority(), FSConfig.getInstance().getAuthorizeAttr().isGradeAuthority()); |
|
|
|
|
Assert.assertEquals(AuthorityKit.isDataConnectionAuthority(), FSConfig.getInstance().getAuthorizeAttr().isDataConnectionAuthority()); |
|
|
|
|
Assert.assertEquals(AuthorityKit.isEditReportAuthority(), FSConfig.getInstance().getAuthorizeAttr().isEditReportAuthority()); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|