Update the dependencies to use project version
[aai/sparky-be.git] / src / test / java / org / onap / aai / sparky / dal / aai / ActiveInventoryAdapterTest.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.dal.aai;\r
24 \r
25 import java.io.File;\r
26 import java.io.IOException;\r
27 import java.util.NoSuchElementException;\r
28 \r
29 import org.junit.Before;\r
30 import org.junit.Test;\r
31 import org.mockito.Mockito;\r
32 import org.onap.aai.sparky.config.oxm.OxmModelLoader;\r
33 import org.onap.aai.sparky.dal.exception.ElasticSearchOperationException;\r
34 import org.onap.aai.sparky.dal.rest.RestClientBuilder;\r
35 import org.onap.aai.sparky.viewandinspect.config.TierSupportUiConstants;\r
36 \r
37 public class ActiveInventoryAdapterTest {\r
38 \r
39   OxmModelLoader oxmModelLoader;\r
40   ActiveInventoryAdapter adapter;\r
41 \r
42   @Before\r
43   public void init() throws IOException, ElasticSearchOperationException {\r
44     String version = "v11";\r
45     System.setProperty("AJSC_HOME", new File(".").getCanonicalPath().replace('\\', '/'));\r
46     TierSupportUiConstants.DYNAMIC_CONFIG_APP_LOCATION =\r
47         System.getProperty("AJSC_HOME") + "/src/test/resources/appconfig/";\r
48     oxmModelLoader = Mockito.spy(new OxmModelLoader());\r
49     Mockito.when(oxmModelLoader.loadOxmFileName(version)).thenReturn(\r
50         System.getProperty("AJSC_HOME") + "/bundleconfig-local/oxm/aai_oxm_" + version + ".xml");\r
51 \r
52     adapter = new ActiveInventoryAdapter(new RestClientBuilder());\r
53   }\r
54 \r
55   @Test\r
56   public void testQueryActiveInventoryWithRetries() {\r
57 \r
58     adapter.queryActiveInventoryWithRetries("https://localhost:9517/model/aai/webapp/index.html",\r
59         "response-type-1", 1);\r
60   }\r
61 \r
62   @Test(expected = NullPointerException.class)\r
63   public void testGetSelfLinkForEntity_NullEntityType() throws Exception {\r
64 \r
65     adapter.getSelfLinkForEntity(null, "key", "value");\r
66   }\r
67 \r
68   @Test(expected = NullPointerException.class)\r
69   public void testGetSelfLinkForEntity_NullKeyName() throws Exception {\r
70 \r
71     adapter.getSelfLinkForEntity("entity", null, "value");\r
72   }\r
73 \r
74   @Test(expected = NullPointerException.class)\r
75   public void testGetSelfLinkForEntity_NullKeyValue() throws Exception {\r
76 \r
77     adapter.getSelfLinkForEntity("entity", "key", null);\r
78   }\r
79 \r
80   @Test\r
81   public void testGetSelfLinkForEntity_ServiceInstance() throws Exception {\r
82 \r
83     adapter.getSelfLinkForEntity("service-instance", "key", "value");\r
84   }\r
85 \r
86   @Test\r
87   public void testGetSelfLinkForEntity_NotServiceInstance() throws Exception {\r
88 \r
89     adapter.getSelfLinkForEntity("service", "key", "value");\r
90   }\r
91 \r
92   @Test(expected = NullPointerException.class)\r
93   public void testGetSelfLinkByEntityType_NullEntity() throws Exception {\r
94 \r
95     adapter.getSelfLinksByEntityType(null);\r
96   }\r
97 \r
98   @Test(expected = NoSuchElementException.class)\r
99   public void testGetSelfLinkByEntityType_NullEntityDescriptor() throws Exception {\r
100 \r
101     adapter.getSelfLinksByEntityType("entity-1");\r
102   }\r
103 \r
104 }\r