00db6d593859d99d8f36b5af35972a792dafecb2
[so.git] /
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP - SO
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
10  * 
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  * 
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=========================================================
19  */
20
21 package org.onap.so.adapters.catalogdb.catalogrest;
22
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;
36
37 public class QueryGroupsTest {
38
39     @Test
40     public void convertToJson_successful() {
41         QueryGroups queryGroups = new QueryGroups(createList());
42         String jsonResult = queryGroups.JSON2(true, false);
43
44         Assertions.assertThat(JsonPathUtil.getInstance().locateResult(jsonResult, "$.groups[0].modelInfo.modelName"))
45                 .contains("test");
46         Assertions
47                 .assertThat(
48                         JsonPathUtil.getInstance().locateResult(jsonResult, "$.groups[0].vnfcs[0].modelInfo.modelName"))
49                 .contains("test");
50     }
51
52     private List<VnfcInstanceGroupCustomization> createList() {
53
54         VnfcCustomization vnfcCustomization = new VnfcCustomization();
55         vnfcCustomization.setModelCustomizationUUID("test");
56         vnfcCustomization.setModelVersion("test");
57         vnfcCustomization.setModelInvariantUUID("test");
58         vnfcCustomization.setModelName("test");
59
60         VFCInstanceGroup vfcInstanceGroup = new VFCInstanceGroup();
61         vfcInstanceGroup.setModelName("test");
62         vfcInstanceGroup.setModelUUID("test");
63         vfcInstanceGroup.setModelInvariantUUID("test");
64         vfcInstanceGroup.setModelVersion("test");
65
66         VnfcInstanceGroupCustomization vnfcInstanceGroupCustomization = new VnfcInstanceGroupCustomization();
67         vnfcInstanceGroupCustomization.setVnfcCustomizations(Arrays.asList(vnfcCustomization));
68         vnfcInstanceGroupCustomization.setInstanceGroup(vfcInstanceGroup);
69
70
71         vfcInstanceGroup.setVnfcInstanceGroupCustomizations(Arrays.asList(vnfcInstanceGroupCustomization));
72         return Arrays.asList(vnfcInstanceGroupCustomization);
73     }
74 }