List of Input Parameters for VSP
[sdc.git] / openecomp-be / lib / openecomp-sdc-externaltesting-lib / openecomp-sdc-externaltesting-impl / src / test / java / org / openecomp / core / externaltesting / impl / ConfigurationTests.java
1 /*
2  * Copyright © 2019 iconectiv
3  *
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
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16
17 package org.openecomp.core.externaltesting.impl;
18
19 import com.fasterxml.jackson.databind.ObjectMapper;
20 import org.junit.Assert;
21 import org.junit.Test;
22 import org.onap.sdc.tosca.services.YamlUtil;
23
24 import java.io.File;
25 import java.io.FileInputStream;
26 import java.io.InputStream;
27
28 public class ConfigurationTests {
29
30   @Test
31   public void testClientConfig() {
32     // a brain dead test of the setter and getter.
33     // future tests for more complex config to come.
34     ClientConfiguration cc = new ClientConfiguration();
35     cc.setEnabled(true);
36     Assert.assertTrue("client configuration setter", cc.isEnabled());
37     cc.setEnabled(false);
38     Assert.assertFalse("client configuration setter", cc.isEnabled());
39   }
40
41   @Test
42   public void testConfig() throws Exception {
43     try (InputStream fileInput = new FileInputStream(new File("src/test/data/testconfiguration.yaml"))) {
44       YamlUtil yamlUtil = new YamlUtil();
45       Object raw = yamlUtil.yamlToMap(fileInput);
46       TestingAccessConfig accessConfig = new ObjectMapper().convertValue(raw, TestingAccessConfig.class);
47       Assert.assertNotNull("client config available", accessConfig.getClient());
48     }
49   }
50
51   @Test
52   public void testEndpointDefinition() {
53     RemoteTestingEndpointDefinition def = new RemoteTestingEndpointDefinition();
54     def.setId("vtp");
55     def.setEnabled(true);
56     def.setTitle("VTP");
57     def.setApiKey("FOOBARBAZ");
58     def.setUrl("http://example.com/vtptesting");
59     def.setScenarioFilter("c.*");
60
61     RemoteTestingEndpointDefinition def2 = new RemoteTestingEndpointDefinition();
62     def2.setId("vtp");
63     def2.setEnabled(true);
64     def2.setTitle("VTP");
65     def2.setUrl("http://example.com/vtptesting");
66     def2.setApiKey("FOOBARBAZ");
67     def2.setScenarioFilter("c.*");
68
69     Assert.assertEquals("code", "VTP", def.getTitle());
70     Assert.assertEquals("API keys equals", def.getApiKey(), def2.getApiKey());
71     Assert.assertEquals("code equals", def.getTitle(), def2.getTitle());
72     Assert.assertEquals("url equals", def.getUrl(), def2.getUrl());
73
74     boolean matches = def.getScenarioFilterPattern().matcher("certification").matches();
75     Assert.assertTrue("pattern", matches);
76
77   }
78 }