2 * ============LICENSE_START===================================================
3 * SPARKY (AAI UI service)
4 * ============================================================================
5 * Copyright © 2017 AT&T Intellectual Property.
6 * Copyright © 2017 Amdocs
8 * ============================================================================
9 * Licensed under the Apache License, Version 2.0 (the "License");
10 * you may not use this file except in compliance with the License.
11 * You may obtain a copy of the License at
13 * http://www.apache.org/licenses/LICENSE-2.0
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
20 * ============LICENSE_END=====================================================
22 * ECOMP and OpenECOMP are trademarks
23 * and service marks of AT&T Intellectual Property.
26 package org.onap.aai.sparky.viewandinspect;
29 * The Class SearchableGroupsTest.
31 public class SearchableGroupsTest {
33 static final String TEST_RESOURCE_PATH = "/src/test/resources";
35 static final String GOOD_TEST_CONFIG = "{\"groups\": [" + "{" + "\"group-name\" : \"inventory\","
36 + "\"search-paths\" : [\"cloud-infrastructure\", \"business\", \"network\"]" + "}," + "{"
37 + "\"group-name\" : \"cloud-infrastructure\","
38 + "\"search-paths\" : [\"complexes\", \"cloud-regions\", \"pservers\"]" + "}" + "]" + "}";
40 * @Before public void init() throws NoSuchFieldException, SecurityException,
41 * IllegalArgumentException, IllegalAccessException { Field instance =
42 * SearchableGroups.class.getDeclaredField("instance"); instance.setAccessible(true);
43 * instance.set(null, null); }
45 * @Test public void test_FileNotFound() throws ElasticSearchOperationException {
46 * System.setProperty("AJSC_HOME", ""); SearchableGroups testGroups =
47 * SearchableGroups.getTestInstance(); assertTrue(testGroups.getGroups().isEmpty()); }
49 * @Test public void test_FileFoundWithProperlyFormatedConfig() throws
50 * ElasticSearchOperationException { ResolverUtils testUtils =
51 * Mockito.mock(ResolverUtils.class);
52 * Mockito.when(testUtils.getConfigSettings(anyString())).thenReturn(GOOD_TEST_CONFIG);
53 * SearchableGroups testGroups = SearchableGroups.getTestInstance();
55 * testGroups.setUtils(testUtils); testGroups.initSearchableGroups();
57 * assertFalse(testGroups.getGroups().isEmpty());
59 * assertFalse(testGroups.getSearchableGroups("inventory").isEmpty()); }
61 * @Test public void test_FileFoundGroupDoesNotExist() throws
62 * ElasticSearchOperationException {
63 * ResolverUtils testUtils = Mockito.mock(ResolverUtils.class);
64 * Mockito.when(testUtils.getConfigSettings(anyString())).thenReturn(GOOD_TEST_CONFIG);
65 * SearchableGroups testGroups = SearchableGroups.getTestInstance();
67 * testGroups.setUtils(testUtils); testGroups.initSearchableGroups();
69 * assertFalse(testGroups.getGroups().isEmpty());
71 * assertEquals(null, testGroups.getSearchableGroups("Test")); }