Search service configurable index settings
[aai/search-data-service.git] / src / test / java / org / onap / aai / sa / rest / SettingConfigurationTest.java
1 /**
2  * ============LICENSE_START=======================================================
3  * org.onap.aai
4  * ================================================================================
5  * Copyright © 2019 AT&T Intellectual Property. All rights reserved.
6  * Copyright © 2019 Amdocs
7  * ================================================================================
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  *       http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  * ============LICENSE_END=========================================================
20  */
21 package org.onap.aai.sa.rest;
22
23 import org.junit.Assert;
24 import org.junit.Test;
25
26
27 public class SettingConfigurationTest {
28
29     @Test
30     public void settingConfigTest() throws Exception {
31         SettingConfiguration config = new SettingConfiguration();
32         config.init("src/test/resources/json/settings-config.json");
33         String settings = config.getSettings();
34         System.out.println("SettingsConfig:\n" + settings);
35         Assert.assertTrue(settings.contains("number_of_shards"));
36     }
37     
38     @Test
39     public void settingConfigAnalysisTest() throws Exception {
40         AnalysisConfiguration ac = new AnalysisConfiguration();
41         ac.init("src/test/resources/json/filter-config.json", "src/test/resources/json/analysis-config.json");
42         System.out.println("AnalysisConfig:\n" + ac.buildEsIndexSettings());
43         
44         SettingConfiguration config = new SettingConfiguration();
45         config.init("src/test/resources/json/settings-config.json");
46         String settings = config.getSettingsWithAnalysis(ac);
47         System.out.println("SettingsAnalysisConfig:\n" + settings);
48         Assert.assertTrue(settings.contains("number_of_shards"));
49         Assert.assertTrue(settings.contains("nGram_analyzer"));
50         
51         config = new SettingConfiguration();
52         config.init("src/test/resources/json/missing-file.json");
53         settings = config.getSettingsWithAnalysis(ac);
54         System.out.println("SettingsAnalysisConfigMissing:\n" + settings);
55         Assert.assertFalse(ac.getEsIndexSettings().isEmpty());
56     }
57 }