Browse Source

Pull request #3248: REPORT-46495 新版本插件管理,在设计器语言为中文时会显示语言筛选的标签

Merge in DESIGN/design from ~LUCIAN.CHEN/design:release/10.0 to release/10.0

* commit '7166140eefb0e2b7f1618b966c8c2ed3e38db94a':
  REPORT-46495 新版本插件管理,在设计器语言为中文时会显示语言筛选的标签
feature/big-screen
Lucian.Chen 4 years ago
parent
commit
08d5e1fe2e
  1. 2
      designer-base/src/main/java/com/fr/design/upm/UpmUtils.java
  2. 57
      designer-base/src/test/java/com/fr/design/upm/UpmUtilsTest.java

2
designer-base/src/main/java/com/fr/design/upm/UpmUtils.java

@ -3,6 +3,7 @@ package com.fr.design.upm;
import com.fr.common.annotations.Negative;
import com.fr.config.ServerPreferenceConfig;
import com.fr.general.CloudCenter;
import com.fr.general.GeneralContext;
import com.fr.stable.StringUtils;
import java.util.ArrayList;
@ -31,6 +32,7 @@ public class UpmUtils {
Map<String, String> map4Tpl = new HashMap<>();
map4Tpl.put("version", ServerPreferenceConfig.getInstance().getOptimizedUPMVersion());
map4Tpl.put("new_version", fetchLatestVersion());
map4Tpl.put("language", GeneralContext.getLocale().toString());
return map4Tpl;
}

57
designer-base/src/test/java/com/fr/design/upm/UpmUtilsTest.java

@ -0,0 +1,57 @@
package com.fr.design.upm;
import com.fr.config.ServerPreferenceConfig;
import com.fr.general.CloudCenter;
import com.fr.general.GeneralContext;
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.core.classloader.annotations.SuppressStaticInitializationFor;
import org.powermock.modules.junit4.PowerMockRunner;
import java.util.Locale;
import java.util.Map;
/**
* @author Lucian.Chen
* @version 10.0
* Created by Lucian.Chen on 2021/1/5
*/
@RunWith(PowerMockRunner.class)
@PrepareForTest({ServerPreferenceConfig.class, CloudCenter.class})
@SuppressStaticInitializationFor("com.fr.general.CloudCenter")
public class UpmUtilsTest {
@Test
public void testRenderMap() {
ServerPreferenceConfig serverPreferenceConfig = EasyMock.mock(ServerPreferenceConfig.class);
EasyMock.expect(serverPreferenceConfig.getOptimizedUPMVersion()).andReturn("1.0").anyTimes();
PowerMock.mockStatic(ServerPreferenceConfig.class);
EasyMock.expect(ServerPreferenceConfig.getInstance()).andReturn(serverPreferenceConfig).anyTimes();
CloudCenter cloudCenter = EasyMock.mock(CloudCenter.class);
EasyMock.expect(cloudCenter.acquireUrlByKind("upm.script.version")).andReturn("2.0").anyTimes();
PowerMock.mockStatic(CloudCenter.class);
EasyMock.expect(CloudCenter.getInstance()).andReturn(cloudCenter).anyTimes();
EasyMock.replay(serverPreferenceConfig, cloudCenter);
PowerMock.replayAll();
GeneralContext.setLocale(Locale.CHINA);
Map<String, String> map4Tpl = UpmUtils.renderMap();
Assert.assertEquals(map4Tpl.size(), 3);
Assert.assertEquals(map4Tpl.get("version"), "1.0");
Assert.assertEquals(map4Tpl.get("new_version"), "2.0");
Assert.assertEquals(map4Tpl.get("language"), "zh_CN");
EasyMock.verify(serverPreferenceConfig, cloudCenter);
PowerMock.verifyAll();
}
}
Loading…
Cancel
Save