Fix aai response parse wrong. 55/19255/1
authorLuji7 <lu.ji3@zte.com.cn>
Tue, 17 Oct 2017 10:52:54 +0000 (18:52 +0800)
committerLuji7 <lu.ji3@zte.com.cn>
Tue, 17 Oct 2017 10:53:02 +0000 (18:53 +0800)
Change-Id: Ib5d8a6be6f21b716078c691adbc682c996c7ccb8
Issue-id: USECASEUI-36
Signed-off-by: Luji7 <lu.ji3@zte.com.cn>
12 files changed:
server/src/main/java/org/onap/usecaseui/server/service/lcm/domain/aai/AAIService.java
server/src/main/java/org/onap/usecaseui/server/service/lcm/domain/aai/bean/AAICustomerRsp.java [new file with mode: 0644]
server/src/main/java/org/onap/usecaseui/server/service/lcm/domain/aai/bean/ServiceInstanceRsp.java [new file with mode: 0644]
server/src/main/java/org/onap/usecaseui/server/service/lcm/domain/aai/bean/ServiceSubscriptionRsp.java [new file with mode: 0644]
server/src/main/java/org/onap/usecaseui/server/service/lcm/domain/aai/bean/VimInfoRsp.java [new file with mode: 0644]
server/src/main/java/org/onap/usecaseui/server/service/lcm/impl/DefaultCustomerService.java
server/src/main/java/org/onap/usecaseui/server/service/lcm/impl/DefaultServiceInstanceService.java
server/src/main/java/org/onap/usecaseui/server/service/lcm/impl/DefaultServiceTemplateService.java
server/src/test/java/org/onap/usecaseui/server/service/lcm/impl/DefaultCustomerServiceTest.java
server/src/test/java/org/onap/usecaseui/server/service/lcm/impl/DefaultPackageDistributionServiceTest.java
server/src/test/java/org/onap/usecaseui/server/service/lcm/impl/DefaultServiceInstanceServiceTest.java
server/src/test/java/org/onap/usecaseui/server/service/lcm/impl/DefaultServiceTemplateServiceTest.java

index eb46596..45b399b 100644 (file)
  */
 package org.onap.usecaseui.server.service.lcm.domain.aai;
 
-import org.onap.usecaseui.server.service.lcm.domain.aai.bean.AAICustomer;
-import org.onap.usecaseui.server.service.lcm.domain.aai.bean.AAIServiceSubscription;
-import org.onap.usecaseui.server.service.lcm.domain.aai.bean.ServiceInstance;
-import org.onap.usecaseui.server.service.lcm.domain.aai.bean.VimInfo;
+import org.onap.usecaseui.server.service.lcm.domain.aai.bean.*;
 import retrofit2.Call;
 import retrofit2.http.GET;
 import retrofit2.http.Headers;
@@ -36,7 +33,7 @@ public interface AAIService {
     })
 //    @GET("/api/aai-business/v11/customers")
     @GET("/aai-business/v11/customers")
-    Call<List<AAICustomer>> listCustomer();
+    Call<AAICustomerRsp> listCustomer();
 
     @Headers({
             "X-TransactionId: 7777",
@@ -46,7 +43,7 @@ public interface AAIService {
     })
 //    @GET("/api/aai-business/v11/customers/customer/{global-customer-id}/service-subscriptions/service-subscription/{service-type}/service-instances")
     @GET("/aai-business/v11/customers/customer/{global-customer-id}/service-subscriptions/service-subscription/{service-type}/service-instances")
-    Call<List<ServiceInstance>> listServiceInstances(@Path("global-customer-id") String customerId, @Path("service-type") String serviceType);
+    Call<ServiceInstanceRsp> listServiceInstances(@Path("global-customer-id") String customerId, @Path("service-type") String serviceType);
 
     @Headers({
             "X-TransactionId: 7777",
@@ -56,7 +53,7 @@ public interface AAIService {
     })
 //    @GET("/cloud-infrastructure/cloud-regions")
     @GET("/aai-cloudInfrastructure/v11/cloud-regions")
-    Call<List<VimInfo>> listVimInfo();
+    Call<VimInfoRsp> listVimInfo();
 
     @Headers({
             "X-TransactionId: 7777",
@@ -66,5 +63,5 @@ public interface AAIService {
     })
 //    @GET("/api/aai-business/v11/customers/customer/{global-customer-id}/service-subscriptions")
     @GET("/aai-business/v11/customers/customer/{global-customer-id}/service-subscriptions")
-    Call<List<AAIServiceSubscription>> listServiceSubscriptions(@Path("global-customer-id") String customerId);
+    Call<ServiceSubscriptionRsp> listServiceSubscriptions(@Path("global-customer-id") String customerId);
 }
diff --git a/server/src/main/java/org/onap/usecaseui/server/service/lcm/domain/aai/bean/AAICustomerRsp.java b/server/src/main/java/org/onap/usecaseui/server/service/lcm/domain/aai/bean/AAICustomerRsp.java
new file mode 100644 (file)
index 0000000..7f3eb66
--- /dev/null
@@ -0,0 +1,31 @@
+/**
+ * Copyright 2016-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.usecaseui.server.service.lcm.domain.aai.bean;
+
+import java.util.List;
+
+public class AAICustomerRsp {
+
+    private List<AAICustomer> customer;
+
+    public List<AAICustomer> getCustomer() {
+        return customer;
+    }
+
+    public void setCustomer(List<AAICustomer> customer) {
+        this.customer = customer;
+    }
+}
diff --git a/server/src/main/java/org/onap/usecaseui/server/service/lcm/domain/aai/bean/ServiceInstanceRsp.java b/server/src/main/java/org/onap/usecaseui/server/service/lcm/domain/aai/bean/ServiceInstanceRsp.java
new file mode 100644 (file)
index 0000000..8c3efb6
--- /dev/null
@@ -0,0 +1,35 @@
+/**
+ * Copyright 2016-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.usecaseui.server.service.lcm.domain.aai.bean;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+import java.util.List;
+
+public class ServiceInstanceRsp {
+
+    private List<ServiceInstance> serviceInstances;
+
+    @JsonProperty("service-instances")
+    public List<ServiceInstance> getServiceInstances() {
+        return serviceInstances;
+    }
+
+    @JsonProperty("service-instances")
+    public void setServiceInstances(List<ServiceInstance> serviceInstances) {
+        this.serviceInstances = serviceInstances;
+    }
+}
diff --git a/server/src/main/java/org/onap/usecaseui/server/service/lcm/domain/aai/bean/ServiceSubscriptionRsp.java b/server/src/main/java/org/onap/usecaseui/server/service/lcm/domain/aai/bean/ServiceSubscriptionRsp.java
new file mode 100644 (file)
index 0000000..8ddbdf6
--- /dev/null
@@ -0,0 +1,35 @@
+/**
+ * Copyright 2016-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.usecaseui.server.service.lcm.domain.aai.bean;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+import java.util.List;
+
+public class ServiceSubscriptionRsp {
+
+    private List<AAIServiceSubscription> serviceSubscriptions;
+
+    @JsonProperty("service-subscription")
+    public List<AAIServiceSubscription> getServiceSubscriptions() {
+        return serviceSubscriptions;
+    }
+
+    @JsonProperty("service-subscription")
+    public void setServiceSubscriptions(List<AAIServiceSubscription> serviceSubscriptions) {
+        this.serviceSubscriptions = serviceSubscriptions;
+    }
+}
diff --git a/server/src/main/java/org/onap/usecaseui/server/service/lcm/domain/aai/bean/VimInfoRsp.java b/server/src/main/java/org/onap/usecaseui/server/service/lcm/domain/aai/bean/VimInfoRsp.java
new file mode 100644 (file)
index 0000000..bf43ab0
--- /dev/null
@@ -0,0 +1,35 @@
+/**
+ * Copyright 2016-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.usecaseui.server.service.lcm.domain.aai.bean;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+import java.util.List;
+
+public class VimInfoRsp {
+
+    private List<VimInfo> cloudRegion;
+
+    @JsonProperty("cloud-region")
+    public List<VimInfo> getCloudRegion() {
+        return cloudRegion;
+    }
+
+    @JsonProperty("cloud-region")
+    public void setCloudRegion(List<VimInfo> cloudRegion) {
+        this.cloudRegion = cloudRegion;
+    }
+}
index 9ece03e..fbd9db8 100644 (file)
@@ -49,7 +49,7 @@ public class DefaultCustomerService implements CustomerService {
     @Override
     public List<AAICustomer> listCustomer() {
         try {
-            return this.aaiService.listCustomer().execute().body();
+            return this.aaiService.listCustomer().execute().body().getCustomer();
         } catch (IOException e) {
             logger.error("list customers occur exception");
             throw new AAIException("AAI is not available.", e);
@@ -59,7 +59,7 @@ public class DefaultCustomerService implements CustomerService {
     @Override
     public List<AAIServiceSubscription> listServiceSubscriptions(String customerId) {
         try {
-            return this.aaiService.listServiceSubscriptions(customerId).execute().body();
+            return this.aaiService.listServiceSubscriptions(customerId).execute().body().getServiceSubscriptions();
         } catch (IOException e) {
             logger.error("list customers occur exception");
             throw new AAIException("AAI is not available.", e);
index 540a0da..586135f 100644 (file)
@@ -48,7 +48,7 @@ public class DefaultServiceInstanceService implements ServiceInstanceService {
     @Override
     public List<ServiceInstance> listServiceInstances(String customerId, String serviceType) {
         try {
-            return aaiService.listServiceInstances(customerId, serviceType).execute().body();
+            return aaiService.listServiceInstances(customerId, serviceType).execute().body().getServiceInstances();
         } catch (IOException e) {
             logger.error("list services instances occur exception");
             throw new AAIException("AAI is not available.", e);
index c2644f8..111e45b 100644 (file)
@@ -25,6 +25,7 @@ import org.onap.usecaseui.server.service.lcm.domain.aai.bean.VimInfo;
 import org.onap.usecaseui.server.service.lcm.domain.aai.exceptions.AAIException;
 import org.onap.usecaseui.server.service.lcm.domain.sdc.SDCCatalogService;
 import org.onap.usecaseui.server.service.lcm.domain.sdc.bean.SDCServiceTemplate;
+import org.onap.usecaseui.server.service.lcm.domain.sdc.consts.SDCConsts;
 import org.onap.usecaseui.server.service.lcm.domain.sdc.exceptions.SDCCatalogException;
 import org.onap.usecaseui.server.util.RestfulServices;
 import org.openecomp.sdc.toscaparser.api.NodeTemplate;
@@ -166,6 +167,19 @@ public class DefaultServiceTemplateService implements ServiceTemplateService {
                     String.valueOf(input.getDefault())
             ));
         }
+        if (SDCConsts.CATEGORY_NS.equals(type)) {
+//            templateInputs.add(new TemplateInput(
+//
+//            ));
+        }
+        // sdn controller
+//        templateInputs.add(new TemplateInput(
+//                "sdncontroller",
+//                "enum",
+//                "sdn controller for the service",
+//                "false",
+//                ""
+//        ));
         return new ServiceTemplateInput(
                 invariantUUID,
                 uuid,
@@ -181,7 +195,7 @@ public class DefaultServiceTemplateService implements ServiceTemplateService {
     @Override
     public List<VimInfo> listVim() {
         try {
-            return aaiService.listVimInfo().execute().body();
+            return aaiService.listVimInfo().execute().body().getCloudRegion();
         } catch (IOException e) {
             logger.error("Visit AAI occur exception");
             throw new AAIException("AAI is not available.", e);
index ebe70c7..889ce02 100644 (file)
@@ -20,6 +20,7 @@ import org.junit.Test;
 import org.onap.usecaseui.server.service.lcm.CustomerService;
 import org.onap.usecaseui.server.service.lcm.domain.aai.AAIService;
 import org.onap.usecaseui.server.service.lcm.domain.aai.bean.AAICustomer;
+import org.onap.usecaseui.server.service.lcm.domain.aai.bean.AAICustomerRsp;
 import org.onap.usecaseui.server.service.lcm.domain.aai.exceptions.AAIException;
 import retrofit2.Call;
 
@@ -38,7 +39,9 @@ public class DefaultCustomerServiceTest {
         List<AAICustomer> customers = singletonList(new AAICustomer("1", "name", "type"));
 
         AAIService aaiService = mock(AAIService.class);
-        Call<List<AAICustomer>> call = successfulCall(customers);
+        AAICustomerRsp rsp = new AAICustomerRsp();
+        rsp.setCustomer(customers);
+        Call<AAICustomerRsp> call = successfulCall(rsp);
         when(aaiService.listCustomer()).thenReturn(call);
 
         CustomerService customerService = new DefaultCustomerService(aaiService);
@@ -48,7 +51,7 @@ public class DefaultCustomerServiceTest {
     @Test(expected = AAIException.class)
     public void itWillThrowExceptionWhenAAIIsNotAvailable() {
         AAIService aaiService = mock(AAIService.class);
-        Call<List<AAICustomer>> call = failedCall("AAI is not available!");
+        Call<AAICustomerRsp> call = failedCall("AAI is not available!");
         when(aaiService.listCustomer()).thenReturn(call);
 
         CustomerService customerService = new DefaultCustomerService(aaiService);
index 766aca7..fd25879 100644 (file)
@@ -21,6 +21,7 @@ import org.onap.usecaseui.server.bean.lcm.VfNsPackageInfo;
 import org.onap.usecaseui.server.service.lcm.PackageDistributionService;
 import org.onap.usecaseui.server.service.lcm.domain.aai.AAIService;
 import org.onap.usecaseui.server.service.lcm.domain.aai.bean.VimInfo;
+import org.onap.usecaseui.server.service.lcm.domain.aai.bean.VimInfoRsp;
 import org.onap.usecaseui.server.service.lcm.domain.sdc.SDCCatalogService;
 import org.onap.usecaseui.server.service.lcm.domain.sdc.bean.SDCServiceTemplate;
 import org.onap.usecaseui.server.service.lcm.domain.sdc.bean.Vnf;
@@ -61,8 +62,9 @@ public class DefaultPackageDistributionServiceTest {
 
     private AAIService newAAIService(List<VimInfo> vim) {
         AAIService aaiService = mock(AAIService.class);
-
-        Call<List<VimInfo>> vimCall = successfulCall(vim);
+        VimInfoRsp rsp = new VimInfoRsp();
+        rsp.setCloudRegion(vim);
+        Call<VimInfoRsp> vimCall = successfulCall(rsp);
         when(aaiService.listVimInfo()).thenReturn(vimCall);
         return aaiService;
     }
index 6f193fb..54555fa 100644 (file)
@@ -20,6 +20,7 @@ import org.junit.Test;
 import org.onap.usecaseui.server.service.lcm.ServiceInstanceService;
 import org.onap.usecaseui.server.service.lcm.domain.aai.AAIService;
 import org.onap.usecaseui.server.service.lcm.domain.aai.bean.ServiceInstance;
+import org.onap.usecaseui.server.service.lcm.domain.aai.bean.ServiceInstanceRsp;
 import org.onap.usecaseui.server.service.lcm.domain.aai.exceptions.AAIException;
 
 import java.util.Collections;
@@ -38,7 +39,9 @@ public class DefaultServiceInstanceServiceTest {
         String customerId = "1";
         String serviceType = "service";
         List<ServiceInstance> instances = Collections.singletonList(new ServiceInstance("1","service","1","VoLTE","e2eservice","abc","vim1"));
-        when(aaiService.listServiceInstances(customerId, serviceType)).thenReturn(successfulCall(instances));
+        ServiceInstanceRsp rsp = new ServiceInstanceRsp();
+        rsp.setServiceInstances(instances);
+        when(aaiService.listServiceInstances(customerId, serviceType)).thenReturn(successfulCall(rsp));
 
         ServiceInstanceService service = new DefaultServiceInstanceService(aaiService);
 
index 9696a77..acb1295 100644 (file)
@@ -22,6 +22,7 @@ import org.onap.usecaseui.server.bean.lcm.TemplateInput;
 import org.onap.usecaseui.server.service.lcm.ServiceTemplateService;
 import org.onap.usecaseui.server.service.lcm.domain.aai.AAIService;
 import org.onap.usecaseui.server.service.lcm.domain.aai.bean.VimInfo;
+import org.onap.usecaseui.server.service.lcm.domain.aai.bean.VimInfoRsp;
 import org.onap.usecaseui.server.service.lcm.domain.sdc.SDCCatalogService;
 import org.onap.usecaseui.server.service.lcm.domain.sdc.bean.SDCServiceTemplate;
 import org.onap.usecaseui.server.service.lcm.domain.sdc.exceptions.SDCCatalogException;
@@ -170,8 +171,9 @@ public class DefaultServiceTemplateServiceTest {
 
     private AAIService newAAIService(List<VimInfo> vim) {
         AAIService aaiService = mock(AAIService.class);
-
-        Call<List<VimInfo>> vimCall = successfulCall(vim);
+        VimInfoRsp rsp = new VimInfoRsp();
+        rsp.setCloudRegion(vim);
+        Call<VimInfoRsp> vimCall = successfulCall(rsp);
         when(aaiService.listVimInfo()).thenReturn(vimCall);
         return aaiService;
     }