2 * Copyright © 2016-2018 European Support Limited
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 package org.onap.config.test;
19 import java.io.IOException;
20 import java.util.HashMap;
22 import org.junit.After;
23 import org.junit.Assert;
24 import org.junit.Before;
25 import org.junit.Test;
26 import org.onap.config.api.ConfigurationManager;
27 import org.onap.config.impl.CliConfigurationImpl;
28 import org.onap.config.util.ConfigTestConstant;
29 import org.onap.config.util.TestUtil;
32 * Created by sheetalm on 10/18/2016.
34 * Verify Configuration Management System - Command Line Interface for query, update and list operations
36 public class CliTest {
38 private static final String NAMESPACE = "CLI";
39 private static final String TENANT = "OPENECOMP";
42 public void setUp() throws IOException {
43 String data = "{name:\"SCM\"}";
44 TestUtil.writeFile(data);
48 public void testCliApi() throws Exception {
49 //Verify without fallback
50 Map<String, Object> input = new HashMap<>();
51 input.put("ImplClass", "org.onap.config.type.ConfigurationQuery");
52 input.put("tenant", TENANT);
53 input.put("namespace", NAMESPACE);
54 input.put("key", ConfigTestConstant.ARTIFACT_NAME_MAXLENGTH);
56 ConfigurationManager conf = new CliConfigurationImpl();
57 String maxLength = conf.getConfigurationValue(input);
58 Assert.assertEquals("14", maxLength);
60 Map<String, String> outputMap = conf.listConfiguration(input);
61 validateCliListConfig(outputMap);
64 private void validateCliListConfig(Map<String, String> outputMap) {
66 Assert.assertEquals("@" + System.getProperty("user.home") + "/TestResources/GeneratorsList.json",
67 outputMap.get(ConfigTestConstant.ARTIFACT_JSON_SCHEMA));
68 Assert.assertEquals("appc,catalog", outputMap.get(ConfigTestConstant.ARTIFACT_CONSUMER));
69 Assert.assertEquals("6", outputMap.get(ConfigTestConstant.ARTIFACT_NAME_MINLENGTH));
70 Assert.assertEquals("true", outputMap.get(ConfigTestConstant.ARTIFACT_ENCODED));
71 Assert.assertEquals("14", outputMap.get(ConfigTestConstant.ARTIFACT_NAME_MAXLENGTH));
72 Assert.assertEquals("pdf,zip,xml,pdf,tgz,xls", outputMap.get(ConfigTestConstant.ARTIFACT_EXT));
73 Assert.assertEquals("Base64,MD5", outputMap.get(ConfigTestConstant.ARTIFACT_ENC));
74 Assert.assertEquals("@" + TestUtil.getenv(ConfigTestConstant.PATH) + "/myschema.json",
75 outputMap.get(ConfigTestConstant.ARTIFACT_XML_SCHEMA));
76 Assert.assertEquals("a-zA-Z_0-9", outputMap.get(ConfigTestConstant.ARTIFACT_NAME_UPPER));
77 Assert.assertEquals("/opt/spool," + System.getProperty("user.home") + "/asdc",
78 outputMap.get(ConfigTestConstant.ARTIFACT_LOC));
79 Assert.assertEquals("deleted,Deleted", outputMap.get(ConfigTestConstant.ARTIFACT_STATUS));
83 public void tearDown() throws Exception {