1fd4f19e2913fff42ad98d17ea91f413a1a985d9
[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 static org.assertj.core.api.Assertions.assertThat;
24 import org.junit.Test;
25 import org.onap.so.db.catalog.beans.VnfcCustomization;
26 import org.onap.so.jsonpath.JsonPathUtil;
27 import java.util.ArrayList;
28 import java.util.List;
29
30 public class QueryVnfcsTest {
31
32     @Test
33     public void convertToJson_successful() {
34         QueryVnfcs queryVnfcs = new QueryVnfcs(createList());
35         String jsonResult = queryVnfcs.JSON2(true, false);
36         System.out.println(jsonResult);
37         assertThat(JsonPathUtil.getInstance().locateResult(jsonResult, "$.vnfcs[0].modelInfo.modelName"))
38                 .contains("model1");
39         assertThat(JsonPathUtil.getInstance().locateResult(jsonResult, "$.vnfcs[1].modelInfo.modelName"))
40                 .contains("model2");
41
42     }
43
44     private List<VnfcCustomization> createList() {
45         List<VnfcCustomization> customizations = new ArrayList();
46
47         VnfcCustomization c1 = new VnfcCustomization();
48         c1.setModelName("model1");
49         c1.setModelUUID("uuid1");
50         c1.setModelInvariantUUID("inv1");
51         c1.setModelVersion("v1");
52         c1.setModelCustomizationUUID("cust1");
53
54         VnfcCustomization c2 = new VnfcCustomization();
55         c2.setModelName("model2");
56         c2.setModelUUID("uuid2");
57         c2.setModelInvariantUUID("inv2");
58         c2.setModelVersion("v2");
59         c2.setModelCustomizationUUID("cust2");
60
61         customizations.add(c1);
62         customizations.add(c2);
63         return customizations;
64     }
65 }