2 * ============LICENSE_START=======================================================
\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
12 * http://www.apache.org/licenses/LICENSE-2.0
\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
21 * ECOMP is a trademark and service mark of AT&T Intellectual Property.
\r
23 package org.onap.aai.sparky.dal.aai;
\r
25 import java.io.File;
\r
26 import java.io.IOException;
\r
27 import java.util.NoSuchElementException;
\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
37 public class ActiveInventoryAdapterTest {
\r
39 OxmModelLoader oxmModelLoader;
\r
40 ActiveInventoryAdapter adapter;
\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 = System.getProperty("AJSC_HOME")+"/src/test/resources/appconfig/";
\r
47 oxmModelLoader = Mockito.spy(new OxmModelLoader());
\r
48 Mockito.when(oxmModelLoader.loadOxmFileName(version)).thenReturn(
\r
49 System.getProperty("AJSC_HOME") + "/bundleconfig-local/oxm/aai_oxm_" + version + ".xml");
\r
51 adapter = new ActiveInventoryAdapter(new RestClientBuilder());
\r
55 public void testQueryActiveInventoryWithRetries() {
\r
57 adapter.queryActiveInventoryWithRetries("https://localhost:9517/model/aai/webapp/index.html", "response-type-1", 1);
\r
60 @Test(expected=NullPointerException.class)
\r
61 public void testGetSelfLinkForEntity_NullEntityType() throws Exception {
\r
63 adapter.getSelfLinkForEntity(null, "key", "value");
\r
66 @Test(expected=NullPointerException.class)
\r
67 public void testGetSelfLinkForEntity_NullKeyName() throws Exception {
\r
69 adapter.getSelfLinkForEntity("entity", null, "value");
\r
72 @Test(expected=NullPointerException.class)
\r
73 public void testGetSelfLinkForEntity_NullKeyValue() throws Exception {
\r
75 adapter.getSelfLinkForEntity("entity", "key", null);
\r
79 public void testGetSelfLinkForEntity_ServiceInstance() throws Exception {
\r
81 adapter.getSelfLinkForEntity("service-instance", "key", "value");
\r
85 public void testGetSelfLinkForEntity_NotServiceInstance() throws Exception {
\r
87 adapter.getSelfLinkForEntity("service", "key", "value");
\r
90 @Test(expected=NullPointerException.class)
\r
91 public void testGetSelfLinkByEntityType_NullEntity() throws Exception {
\r
93 adapter.getSelfLinksByEntityType(null);
\r
96 @Test(expected=NoSuchElementException.class)
\r
97 public void testGetSelfLinkByEntityType_NullEntityDescriptor() throws Exception {
\r
99 adapter.getSelfLinksByEntityType("entity-1");
\r