Add unit test for app Configuration.
Clean the static method from ExtsysUtil.
Change-Id: If95bedde42b553e4ce80bf62514cabe06dea9068
Issue-ID: AAI-363
Signed-off-by: lizi00164331 <li.zi30@zte.com.cn>
}
@JsonProperty
- public String setMsbDiscoveryIp() {
- return msbDiscoveryIp;
+ public void setMsbDiscoveryIp(String discoveryIp) {
+ this.msbDiscoveryIp = discoveryIp;
}
@JsonProperty
import org.onap.aai.esr.entity.rest.FtpAddr;
public class EmsManagerUtil {
+ private static ExtsysUtil extsysUtil = new ExtsysUtil();
public EsrEmsDetail emsRegisterInfo2EsrEms(EmsRegisterInfo emsRegisterInfo) {
EsrEmsDetail esrEms = new EsrEmsDetail();
esrEms.setEmsId(ExtsysUtil.generateId());
ArrayList<EsrSystemInfo> authInfos = new ArrayList<EsrSystemInfo>();
authInfos = getAuthInfosFromRegisterData(emsRegisterInfo);
- esrEms.setEsrSystemInfoList(ExtsysUtil.getEsrSystemInfoListFromAuthInfoList(authInfos));
+ esrEms.setEsrSystemInfoList(extsysUtil.getEsrSystemInfoListFromAuthInfoList(authInfos));
return esrEms;
}
//import org.slf4j.Logger;
//import org.slf4j.LoggerFactory;
-import java.text.SimpleDateFormat;
import java.util.ArrayList;
-import java.util.Date;
import java.util.UUID;
import org.onap.aai.esr.entity.aai.EsrSystemInfo;
import org.onap.aai.esr.entity.aai.EsrSystemInfoList;
public class ExtsysUtil {
-// private final static Logger logger = LoggerFactory.getLogger(ExtsysUtil.class);
public static String generateId() {
return UUID.randomUUID().toString();
}
- public static boolean isNotEmpty(String str) {
- return str != null && !"".equals(str) && str.length() > 0;
- }
-
/**
* change object to str.
*/
}
}
- public static String getNowTime() {
- SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
- return sdf.format(new Date());
- }
-
- public static EsrSystemInfoList getEsrSystemInfoListFromAuthInfo(EsrSystemInfo esrSystemInfoObj) {
+ public EsrSystemInfoList getEsrSystemInfoListFromAuthInfo(EsrSystemInfo esrSystemInfoObj) {
EsrSystemInfoList esrSystemInfoList = new EsrSystemInfoList();
ArrayList<EsrSystemInfo> esrSystemInfo = new ArrayList<EsrSystemInfo>();
esrSystemInfo.add(esrSystemInfoObj);
return esrSystemInfoList;
}
- public static EsrSystemInfoList getEsrSystemInfoListFromAuthInfoList(ArrayList<EsrSystemInfo> esrSystemInfo) {
+ public EsrSystemInfoList getEsrSystemInfoListFromAuthInfoList(ArrayList<EsrSystemInfo> esrSystemInfo) {
EsrSystemInfoList esrSystemInfoList = new EsrSystemInfoList();
esrSystemInfoList.setEsrSystemInfo(esrSystemInfo);;
return esrSystemInfoList;
public class VimManagerUtil {
+ private static ExtsysUtil extsysUtil = new ExtsysUtil();
public CloudRegionDetail vimRegisterInfo2CloudRegion(VimRegisterInfo vimRegisterInfo) {
CloudRegionDetail cloudRegion = new CloudRegionDetail();
esrSystemInfoObj = vimAuthInfo2EsrSystemInfoObj(vimRegisterInfo.getVimAuthInfos());
esrSystemInfoObj.setSystemStatus(vimRegisterInfo.getStatus());
- esrSystemInfoList = ExtsysUtil.getEsrSystemInfoListFromAuthInfo(esrSystemInfoObj);
+ esrSystemInfoList = extsysUtil.getEsrSystemInfoListFromAuthInfo(esrSystemInfoObj);
cloudRegion.setEsrSystemInfoList(esrSystemInfoList);
return cloudRegion;
}
import org.onap.aai.esr.entity.rest.VnfmRegisterInfo;
public class VnfmManagerUtil {
+ private static ExtsysUtil extsysUtil = new ExtsysUtil();
public EsrVnfmDetail vnfmRegisterInfo2EsrVnfm(VnfmRegisterInfo vnfmRegisterInfo) {
EsrVnfmDetail esrVnfm = new EsrVnfmDetail();
esrVnfm.setVimId(vnfmRegisterInfo.getVimId());
esrVnfm.setVnfmId(ExtsysUtil.generateId());
authInfo = getAuthInfoFromVnfmRegisterInfo(vnfmRegisterInfo);
- esrSystemInfo = ExtsysUtil.getEsrSystemInfoListFromAuthInfo(authInfo);
+ esrSystemInfo = extsysUtil.getEsrSystemInfoListFromAuthInfo(authInfo);
esrVnfm.setEsrSystemInfoList(esrSystemInfo);
return esrVnfm;
}
import org.onap.aai.esr.entity.aai.EsrSystemInfo;
import org.onap.aai.esr.entity.aai.EsrThirdpartySdncDetail;
import org.onap.aai.esr.entity.aai.EsrThirdpartySdncList;
-import org.onap.aai.esr.entity.aai.EsrVnfmDetail;
import org.onap.aai.esr.entity.rest.CommonRegisterResponse;
import org.onap.aai.esr.entity.rest.ThirdpartySdncRegisterInfo;
import org.onap.aai.esr.externalservice.aai.ExternalSystemProxy;
import org.onap.aai.esr.util.ThirdpartySdncManagerUtil;
-import org.onap.aai.esr.util.VnfmManagerUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
--- /dev/null
+/**
+ * Copyright 2017 ZTE Corporation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onap.aai.esr;
+
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Test;
+
+public class ExtsysAppConfigurationTest {
+
+ @Test
+ public void getterAndSetter4template(){
+ final String template = "Hello ESR";
+ ExtsysAppConfiguration appConfiguration = new ExtsysAppConfiguration();
+ appConfiguration.setTemplate(template);
+ assertEquals(appConfiguration.getTemplate(), template);
+ }
+
+ @Test
+ public void getterAndSetter4defaultName(){
+ final String defaultName = "ONAP-A&AI-ESR";
+ ExtsysAppConfiguration appConfiguration = new ExtsysAppConfiguration();
+ appConfiguration.setDefaultName(defaultName);
+ assertEquals(appConfiguration.getDefaultName(), defaultName);
+ }
+
+ @Test
+ public void getterAndSetter4msbDiscoveryIp(){
+ final String msbDiscoveryIp = "127.0.0.1";
+ ExtsysAppConfiguration appConfiguration = new ExtsysAppConfiguration();
+ appConfiguration.setMsbDiscoveryIp(msbDiscoveryIp);
+ assertEquals(appConfiguration.getMsbDiscoveryIp(), msbDiscoveryIp);
+ }
+
+ @Test
+ public void getterAndSetter4msbDiscoveryPort(){
+ final String msbDiscoveryPort = "10081";
+ ExtsysAppConfiguration appConfiguration = new ExtsysAppConfiguration();
+ appConfiguration.setMsbDiscoveryPort(msbDiscoveryPort);
+ assertEquals(appConfiguration.getMsbDiscoveryPort(), msbDiscoveryPort);
+ }
+
+ @Test
+ public void getterAndSetter4registByHand(){
+ final String registByHand = "true";
+ ExtsysAppConfiguration appConfiguration = new ExtsysAppConfiguration();
+ appConfiguration.setRegistByHand(registByHand);
+ assertEquals(appConfiguration.getRegistByHand(), registByHand);
+ }
+
+ @Test
+ public void getterAndSetter4msbServerAddr(){
+ final String msbServerAddr = "http://127.0.0.1:80";
+ ExtsysAppConfiguration appConfiguration = new ExtsysAppConfiguration();
+ appConfiguration.setMsbServerAddr(msbServerAddr);
+ assertEquals(appConfiguration.getMsbServerAddr(), msbServerAddr);
+ }
+
+ @Test
+ public void getterAndSetter4serviceIp(){
+ final String serviceIp = "true";
+ ExtsysAppConfiguration appConfiguration = new ExtsysAppConfiguration();
+ appConfiguration.setServiceIp(serviceIp);
+ assertEquals(appConfiguration.getServiceIp(), serviceIp);
+ }
+}