2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2019 Huawei Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
21 package org.onap.so.adapters.catalogdb.catalogrest;
23 import org.assertj.core.api.Assertions;
24 import org.junit.Test;
25 import org.onap.so.db.catalog.beans.Service;
26 import org.onap.so.db.catalog.beans.VFCInstanceGroup;
27 import org.onap.so.db.catalog.beans.VnfResource;
28 import org.onap.so.db.catalog.beans.VnfResourceCustomization;
29 import org.onap.so.db.catalog.beans.VnfcCustomization;
30 import org.onap.so.db.catalog.beans.VnfcInstanceGroupCustomization;
31 import org.onap.so.db.catalog.rest.beans.ServiceMacroHolder;
32 import org.onap.so.jsonpath.JsonPathUtil;
33 import java.util.ArrayList;
34 import java.util.Arrays;
35 import java.util.List;
37 public class QueryGroupsTest {
40 public void convertToJson_successful() {
41 QueryGroups queryGroups = new QueryGroups(createList());
42 String jsonResult = queryGroups.JSON2(true, false);
44 Assertions.assertThat(JsonPathUtil.getInstance().locateResult(jsonResult, "$.groups[0].modelInfo.modelName"))
48 JsonPathUtil.getInstance().locateResult(jsonResult, "$.groups[0].vnfcs[0].modelInfo.modelName"))
52 private List<VnfcInstanceGroupCustomization> createList() {
54 VnfcCustomization vnfcCustomization = new VnfcCustomization();
55 vnfcCustomization.setModelCustomizationUUID("test");
56 vnfcCustomization.setModelVersion("test");
57 vnfcCustomization.setModelInvariantUUID("test");
58 vnfcCustomization.setModelName("test");
60 VFCInstanceGroup vfcInstanceGroup = new VFCInstanceGroup();
61 vfcInstanceGroup.setModelName("test");
62 vfcInstanceGroup.setModelUUID("test");
63 vfcInstanceGroup.setModelInvariantUUID("test");
64 vfcInstanceGroup.setModelVersion("test");
66 VnfcInstanceGroupCustomization vnfcInstanceGroupCustomization = new VnfcInstanceGroupCustomization();
67 vnfcInstanceGroupCustomization.setVnfcCustomizations(Arrays.asList(vnfcCustomization));
68 vnfcInstanceGroupCustomization.setInstanceGroup(vfcInstanceGroup);
71 vfcInstanceGroup.setVnfcInstanceGroupCustomizations(Arrays.asList(vnfcInstanceGroupCustomization));
72 return Arrays.asList(vnfcInstanceGroupCustomization);