X-Git-Url: https://gerrit.onap.org/r/gitweb?p=aai%2Fesr-server.git;a=blobdiff_plain;f=esr-mgr%2Fsrc%2Fmain%2Fjava%2Forg%2Fonap%2Faai%2Fesr%2Fexternalservice%2Faai%2FExternalSystemProxy.java;h=2e19f7da67b59d5e6f2e794bd6ec75612d8bd38b;hp=0361747572c6cecc6677210d44ca60d371ad9799;hb=486ed42762fedbc7cd0cc43704389ed41434eacd;hpb=ed26992f976741031237ead3a5dc0565d4318b05 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 0361747..2e19f7d 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 @@ -150,17 +150,34 @@ public class ExternalSystemProxy { } public static void registerEms(String emsId, EsrEmsDetail emsDetail) throws ExtsysException { - ClientConfig config = new ClientConfig(new EmsRegisterProvider()); - IExternalSystem registerEmsServiceproxy = - ConsumerFactory.createConsumer(MsbConfig.getExternalSystemAddr(), config, IExternalSystem.class); - try { - registerEmsServiceproxy.registerEMS(transactionId, fromAppId, authorization, emsId, emsDetail); - } catch (Exception e) { - throw new ExtsysException("PUT EMS to A&AI failed.", e); + if (!isTest) { + ClientConfig config = new ClientConfig(new EmsRegisterProvider()); + IExternalSystem registerEmsServiceproxy = + ConsumerFactory.createConsumer(MsbConfig.getExternalSystemAddr(), config, IExternalSystem.class); + try { + registerEmsServiceproxy.registerEMS(transactionId, fromAppId, authorization, emsId, emsDetail); + } catch (Exception e) { + throw new ExtsysException("PUT EMS to A&AI failed.", e); + } } } public static String queryEmsDetail(String emsId) throws ExtsysException { + if (isTest) { + 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\"," + + "\"system-type\":\"EMS_RESOUCE\"," + "\"ip-address\":\"127.0.0.1\"," + "\"port\":\"5000\"," + + "\"passive\":true," + "\"remote-path\":\"/home/per\"}," + "{\"esr-system-info-id\":\"345678\"," + + "\"system-name\":\"EMS_TEST\"," + "\"type\":\"sftp\"," + "\"vendor\":\"ZTE\"," + "\"version\":\"V1\"," + + "\"user-name\":\"nancy\"," + "\"password\":\"asdf\"," + "\"system-type\":\"EMS_PERFORMANCE\"," + + "\"ip-address\":\"127.0.0.1\"," + "\"port\":\"5000\"," + "\"passive\":true," + + "\"remote-path\":\"/home/per\"}," + "{\"esr-system-info-id\":\"456789\"," + + "\"system-name\":\"EMS_TEST\"," + "\"vendor\":\"ZTE\"," + "\"version\":\"V1\"," + + "\"user-name\":\"nancy\"," + "\"password\":\"987654\"," + "\"system-type\":\"EMS_ALARM\"," + + "\"ip-address\":\"127.0.0.1\"," + "\"port\":\"5000\"}]}}"; + return emsDetailStr; + } try { return externalSystemproxy.queryEMSDetail(transactionId, fromAppId, authorization, emsId); } catch (Exception e) { @@ -169,6 +186,9 @@ public class ExternalSystemProxy { } public static String queryEmsList() throws ExtsysException { + if (isTest) { + return "{\"esr-ems\": [ {\"ems-id\": \"123456\",\"resource-version\": \"1\"}]}"; + } try { return externalSystemproxy.queryEMSList(transactionId, fromAppId, authorization); } catch (Exception e) { @@ -177,10 +197,12 @@ public class ExternalSystemProxy { } public static void deleteEms(String emsId, String resourceVersion) throws ExtsysException { - try { - externalSystemproxy.deleteEMS(transactionId, fromAppId, authorization, emsId, resourceVersion); - } catch (Exception e) { - throw new ExtsysException("Delete EMS from A&AI failed.", e); + if (!isTest) { + try { + externalSystemproxy.deleteEMS(transactionId, fromAppId, authorization, emsId, resourceVersion); + } catch (Exception e) { + throw new ExtsysException("Delete EMS from A&AI failed.", e); + } } } }