diff options
author | Lizi <li.zi30@zte.com.cn> | 2018-01-22 12:02:50 +0000 |
---|---|---|
committer | Lizi <li.zi30@zte.com.cn> | 2018-01-22 12:04:28 +0000 |
commit | 41d59ecbd847f49c30d33941289c69ad5e2a1c62 (patch) | |
tree | dc73fdc777e61b5a12af6ef79c0f1373cf0b438f /esr-mgr | |
parent | 93934b27fdc08e18165766860949258ac3edb9a3 (diff) |
Fix the sonar issue.
Change-Id: Ie704a164dc9ed5d2be247708a24779d97d6b5c15
Issue-ID: AAI-638
Signed-off-by: Lizi <li.zi30@zte.com.cn>
Diffstat (limited to 'esr-mgr')
5 files changed, 54 insertions, 19 deletions
diff --git a/esr-mgr/src/main/java/org/onap/aai/esr/common/IsTest.java b/esr-mgr/src/main/java/org/onap/aai/esr/common/IsTest.java new file mode 100644 index 0000000..6c69295 --- /dev/null +++ b/esr-mgr/src/main/java/org/onap/aai/esr/common/IsTest.java @@ -0,0 +1,30 @@ +/** + * Copyright 2018 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.common; + +public class IsTest { + private boolean isTest; + + public IsTest(boolean isTest) + { + this.isTest = isTest; + } + + public boolean getIsTest() + { + return isTest; + } +} diff --git a/esr-mgr/src/main/java/org/onap/aai/esr/externalservice/aai/ExternalSystemProxy.java b/esr-mgr/src/main/java/org/onap/aai/esr/externalservice/aai/ExternalSystemProxy.java index 69d4e47..ae8a501 100644 --- a/esr-mgr/src/main/java/org/onap/aai/esr/externalservice/aai/ExternalSystemProxy.java +++ b/esr-mgr/src/main/java/org/onap/aai/esr/externalservice/aai/ExternalSystemProxy.java @@ -16,6 +16,7 @@ package org.onap.aai.esr.externalservice.aai; import org.glassfish.jersey.client.ClientConfig; +import org.onap.aai.esr.common.IsTest; import org.onap.aai.esr.common.MsbConfig; import org.onap.aai.esr.entity.aai.EsrEmsDetail; import org.onap.aai.esr.entity.aai.EsrThirdpartySdncDetail; @@ -25,7 +26,6 @@ import com.eclipsesource.jaxrs.consumer.ConsumerFactory; public class ExternalSystemProxy { - public static boolean isTest = false; private static IExternalSystem externalSystemproxy; private static String transactionId = "9999"; private static String fromAppId = "esr-server"; @@ -35,9 +35,11 @@ public class ExternalSystemProxy { externalSystemproxy = ConsumerFactory.createConsumer(MsbConfig.getExternalSystemAddr(), config, IExternalSystem.class); } + + public static IsTest test = new IsTest(false); public static void registerVnfm(String vnfmId, EsrVnfmDetail esrVnfmDetail) throws ExtsysException { - if (!isTest){ + if (!test.getIsTest()){ ClientConfig config = new ClientConfig(new VnfmRegisterProvider()); IExternalSystem registerVnfmServiceproxy = ConsumerFactory.createConsumer(MsbConfig.getExternalSystemAddr(), config, IExternalSystem.class); @@ -50,7 +52,7 @@ public class ExternalSystemProxy { } public static String queryVnfmDetail(String vnfmId) throws ExtsysException { - if (isTest) { + if (test.getIsTest()) { String esrVnfmDetailStr = "{\"vnfm-id\":\"123456\",\"vim-id\":\"987654\"," + "\"certificate-url\":\"http://ip:5000/v3\",\"esr-system-info-list\":{" + "\"esr-system-info\":[{\"esr-system-info-id\":\"qwerty\",\"system-name\":\"ONAP VNFM\"," @@ -67,7 +69,7 @@ public class ExternalSystemProxy { } public static String queryVnfmList() throws ExtsysException { - if (isTest) { + if (test.getIsTest()) { String vnfmListStr = "{\"esr-vnfm\": [{\"vnfm-id\": \"123456\",\"vim-id\": \"987654\"," + "\"certificate-url\": \"http://ip:5000/v3\",\"resource-version\": \"1\"}]}"; return vnfmListStr; @@ -80,7 +82,7 @@ public class ExternalSystemProxy { } public static void deleteVnfm(String vnfmId, String resourceVersion) throws ExtsysException { - if (!isTest) { + if (!test.getIsTest()) { try { externalSystemproxy.deleteVNFM(transactionId, fromAppId, authorization, vnfmId, resourceVersion); } catch (Exception e) { @@ -91,7 +93,7 @@ public class ExternalSystemProxy { public static void registerSdnc(String thirdpartySdncId, EsrThirdpartySdncDetail esrSdncDetail) throws ExtsysException { - if (!isTest) { + if (!test.getIsTest()) { ClientConfig config = new ClientConfig(new ThirdpartySdncRegisterProvider()); IExternalSystem registerSdncServiceproxy = ConsumerFactory.createConsumer(MsbConfig.getExternalSystemAddr(), config, IExternalSystem.class); @@ -105,7 +107,7 @@ public class ExternalSystemProxy { } public static String queryThirdpartySdncDetail(String thirdpartySdncId) throws ExtsysException { - if (isTest) { + if (test.getIsTest()) { String sdncDetail = "{\"thirdparty-sdnc-id\":\"123456\",\"location\":\"edge\"," + "\"product-name\":\"thirdparty SDNC\",\"esr-system-info-list\":{\"esr-system-info\":" + "[{\"esr-system-info-id\":\"987654\",\"system-name\":\"SDNC_TEST\",\"type\":\"SDNC\"," @@ -123,7 +125,7 @@ public class ExternalSystemProxy { } public static String querySdncList() throws ExtsysException { - if (isTest) { + if (test.getIsTest()) { String sdncList = "{\"esr-thirdparty-sdnc\": [{\"thirdparty-sdnc-id\": \"123456\",\"location\": \"edge\"," + "\"product-name\": \"thirdparty SDNC\",\"resource-version\": \"1\"}]}"; @@ -137,7 +139,7 @@ public class ExternalSystemProxy { } public static void deleteThirdpartySdnc(String sdncId, String resourceVersion) throws ExtsysException { - if (!isTest) { + if (!test.getIsTest()) { try { externalSystemproxy.deleteThirdpartySdnc(transactionId, fromAppId, authorization, sdncId, resourceVersion); @@ -148,7 +150,7 @@ public class ExternalSystemProxy { } public static void registerEms(String emsId, EsrEmsDetail emsDetail) throws ExtsysException { - if (!isTest) { + if (!test.getIsTest()) { ClientConfig config = new ClientConfig(new EmsRegisterProvider()); IExternalSystem registerEmsServiceproxy = ConsumerFactory.createConsumer(MsbConfig.getExternalSystemAddr(), config, IExternalSystem.class); @@ -161,7 +163,7 @@ public class ExternalSystemProxy { } public static String queryEmsDetail(String emsId) throws ExtsysException { - if (isTest) { + if (test.getIsTest()) { String emsDetailStr = "{\"ems-id\":\"123456\",\"esr-system-info-list\":{\"esr-system-info\":" + "[{\"esr-system-info-id\":\"234567\",\"system-name\":\"EMS_TEST\",\"type\":\"sftp\"," + "\"vendor\":\"ZTE\",\"version\":\"V1\",\"user-name\":\"nancy\",\"password\":\"asdf\"," @@ -184,7 +186,7 @@ public class ExternalSystemProxy { } public static String queryEmsList() throws ExtsysException { - if (isTest) { + if (test.getIsTest()) { return "{\"esr-ems\": [ {\"ems-id\": \"123456\",\"resource-version\": \"1\"}]}"; } try { @@ -195,7 +197,7 @@ public class ExternalSystemProxy { } public static void deleteEms(String emsId, String resourceVersion) throws ExtsysException { - if (!isTest) { + if (!test.getIsTest()) { try { externalSystemproxy.deleteEMS(transactionId, fromAppId, authorization, emsId, resourceVersion); } catch (Exception e) { diff --git a/esr-mgr/src/test/java/org/onap/aai/esr/wrapper/EmsManagerWrapperTest.java b/esr-mgr/src/test/java/org/onap/aai/esr/wrapper/EmsManagerWrapperTest.java index bf35019..94facb8 100644 --- a/esr-mgr/src/test/java/org/onap/aai/esr/wrapper/EmsManagerWrapperTest.java +++ b/esr-mgr/src/test/java/org/onap/aai/esr/wrapper/EmsManagerWrapperTest.java @@ -24,6 +24,7 @@ import org.junit.Assert; import org.junit.Before; import org.junit.BeforeClass; import org.junit.Test; +import org.onap.aai.esr.common.IsTest; import org.onap.aai.esr.common.MsbConfig; import org.onap.aai.esr.entity.rest.AlarmAddr; import org.onap.aai.esr.entity.rest.EmsRegisterInfo; @@ -39,12 +40,12 @@ public class EmsManagerWrapperTest { @BeforeClass public static void beforeClass() { - ExternalSystemProxy.isTest = true; + ExternalSystemProxy.test = new IsTest(true); }; @AfterClass public static void afterClass() { - ExternalSystemProxy.isTest = false; + ExternalSystemProxy.test = new IsTest(false); }; @Before diff --git a/esr-mgr/src/test/java/org/onap/aai/esr/wrapper/ThirdpartySdncWrapperTest.java b/esr-mgr/src/test/java/org/onap/aai/esr/wrapper/ThirdpartySdncWrapperTest.java index c236f30..d60fcce 100644 --- a/esr-mgr/src/test/java/org/onap/aai/esr/wrapper/ThirdpartySdncWrapperTest.java +++ b/esr-mgr/src/test/java/org/onap/aai/esr/wrapper/ThirdpartySdncWrapperTest.java @@ -24,6 +24,7 @@ import org.junit.Assert; import org.junit.Before; import org.junit.BeforeClass; import org.junit.Test; +import org.onap.aai.esr.common.IsTest; import org.onap.aai.esr.common.MsbConfig; import org.onap.aai.esr.entity.rest.ThirdpartySdncRegisterInfo; import org.onap.aai.esr.externalservice.aai.ExternalSystemProxy; @@ -38,12 +39,12 @@ public class ThirdpartySdncWrapperTest { @BeforeClass public static void beforeClass() { - ExternalSystemProxy.isTest = true; + ExternalSystemProxy.test = new IsTest(true); }; @AfterClass public static void afterClass() { - ExternalSystemProxy.isTest = false; + ExternalSystemProxy.test = new IsTest(false); }; @Before diff --git a/esr-mgr/src/test/java/org/onap/aai/esr/wrapper/VnfmManagerWrapperTest.java b/esr-mgr/src/test/java/org/onap/aai/esr/wrapper/VnfmManagerWrapperTest.java index 5f31241..575391b 100644 --- a/esr-mgr/src/test/java/org/onap/aai/esr/wrapper/VnfmManagerWrapperTest.java +++ b/esr-mgr/src/test/java/org/onap/aai/esr/wrapper/VnfmManagerWrapperTest.java @@ -24,6 +24,7 @@ import org.junit.Assert; import org.junit.Before; import org.junit.BeforeClass; import org.junit.Test; +import org.onap.aai.esr.common.IsTest; import org.onap.aai.esr.common.MsbConfig; import org.onap.aai.esr.entity.rest.VnfmRegisterInfo; import org.onap.aai.esr.externalservice.aai.ExternalSystemProxy; @@ -38,12 +39,12 @@ public class VnfmManagerWrapperTest { @BeforeClass public static void beforeClass() { - ExternalSystemProxy.isTest = true; + ExternalSystemProxy.test = new IsTest(true); }; @AfterClass public static void afterClass() { - ExternalSystemProxy.isTest = false; + ExternalSystemProxy.test = new IsTest(false); }; @Before |