Merge "Reorder modifiers"
[so.git] / adapters / mso-catalog-db-adapter / src / test / java / org / openecomp / mso / adapters / catalogdb / catalogrest / QueryServiceVnfsTest.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP - SO
4  * ================================================================================
5  * Copyright (C) 2017 AT&T 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.openecomp.mso.adapters.catalogdb.catalogrest;
22
23 import static org.junit.Assert.assertTrue;
24
25 import java.io.StringReader;
26 import java.util.ArrayList;
27 import java.util.List;
28
29 import javax.json.Json;
30 import javax.json.JsonArray;
31 import javax.json.JsonObject;
32 import javax.json.JsonReader;
33
34 import org.junit.Test;
35 import org.junit.runner.RunWith;
36 import org.mockito.runners.MockitoJUnitRunner;
37 import org.openecomp.mso.db.catalog.beans.NetworkResourceCustomization;
38 import org.openecomp.mso.db.catalog.beans.VnfResourceCustomization;
39
40 @RunWith(MockitoJUnitRunner.class)
41 public class QueryServiceVnfsTest {
42
43         @Test
44         public void JSON2_Test()
45         {
46             List<VnfResourceCustomization> paramList;                   
47         paramList = new ArrayList<>();
48         VnfResourceCustomization d1 = new VnfResourceCustomization();
49         d1.setModelInstanceName("0cb9b26a-9820-48a7-86e5-16c510e993d9");
50         d1.setVnfResourceModelUuid("0cb9b26a-9820-48a7-86e5-16c510e993d9");
51         paramList.add(d1);
52         QueryServiceVnfs qsn = new QueryServiceVnfs(paramList);
53         
54                 String s = qsn.JSON2(true, true); 
55                 s = "{" + s + "}";
56                 System.out.println(s);
57                 
58                 // prepare to inspect response
59         JsonReader reader = Json.createReader(new StringReader(s.replaceAll("\r?\n", "")));
60         JsonObject respObj = reader.readObject();
61         reader.close();
62         JsonArray objArr = respObj.getJsonArray("serviceVnfs");
63         
64         assertTrue(objArr.size() == 1);
65         
66         JsonObject obj2 = objArr.getJsonObject(0).getJsonObject("modelInfo");
67         String modelName = obj2.getString("modelInstanceName");
68         
69         assertTrue(modelName.equals("0cb9b26a-9820-48a7-86e5-16c510e993d9"));
70         // end                  
71                 
72         }
73 }