Add unit test cases to increase sonar coverage
[aai/sparky-be.git] / src / test / java / org / onap / aai / sparky / search / VnfSearchQueryBuilderTest.java
1 /**\r
2  * ============LICENSE_START=======================================================\r
3  * org.onap.aai\r
4  * ================================================================================\r
5  * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
6  * Copyright © 2017 Amdocs\r
7  * ================================================================================\r
8  * Licensed under the Apache License, Version 2.0 (the "License");\r
9  * you may not use this file except in compliance with the License.\r
10  * You may obtain a copy of the License at\r
11  *\r
12  *       http://www.apache.org/licenses/LICENSE-2.0\r
13  *\r
14  * Unless required by applicable law or agreed to in writing, software\r
15  * distributed under the License is distributed on an "AS IS" BASIS,\r
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
17  * See the License for the specific language governing permissions and\r
18  * limitations under the License.\r
19  * ============LICENSE_END=========================================================\r
20  *\r
21  * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
22  */\r
23 package org.onap.aai.sparky.search;\r
24 \r
25 import java.util.HashMap;\r
26 import java.util.Map;\r
27 \r
28 import javax.json.JsonArray;\r
29 import javax.json.JsonObject;\r
30 \r
31 import org.junit.Assert;\r
32 import org.junit.Test;\r
33 import org.onap.aai.sparky.search.VnfSearchQueryBuilder;\r
34 \r
35 public class VnfSearchQueryBuilderTest {\r
36 \r
37         @Test\r
38         public void testCreateSuggestionsQuery() {\r
39                 String maxResults = "maxResults-1";\r
40                 String queryStr = "queryStr-1";\r
41                 JsonObject object = VnfSearchQueryBuilder.createSuggestionsQuery(maxResults, queryStr);\r
42                 Assert.assertNotNull(object);\r
43         }\r
44         \r
45         @Test\r
46         public void testSortCriteria() {\r
47                 JsonArray array = VnfSearchQueryBuilder.getSortCriteria("field-1", "sortOrder-1");\r
48                 Assert.assertNotNull(array);\r
49         }\r
50         \r
51         @Test\r
52         public void testCreateEntityCountsQuery_SingleAttribute() {\r
53                 Map<String, String> attributes = new HashMap<>();\r
54                 attributes.put("key-1", "value-1");\r
55                 JsonObject object = VnfSearchQueryBuilder.createEntityCountsQuery(attributes);\r
56                 Assert.assertNotNull(object);\r
57         }\r
58         \r
59         @Test\r
60         public void testCreateSummaryByEntityTypeQuery_Single() {\r
61                 Map<String, String> attributes = new HashMap<>();\r
62                 attributes.put("key-1", "value-1");\r
63                 JsonObject object = VnfSearchQueryBuilder.createSummaryByEntityTypeQuery(attributes, "groupkey-1");\r
64                 Assert.assertNotNull(object);\r
65         }\r
66         \r
67         @Test\r
68         public void testCreateSummaryByEntityTypeQuery_Multiple() {\r
69                 Map<String, String> attributes = new HashMap<>();\r
70                 attributes.put("key-1", "value-1");\r
71                 attributes.put("key-2", "value-2");\r
72                 JsonObject object = VnfSearchQueryBuilder.createSummaryByEntityTypeQuery(attributes, "groupkey-1");\r
73                 Assert.assertNotNull(object);\r
74         }\r
75 }\r