2 * Copyright © 2019 iconectiv
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.openecomp.core.externaltesting.impl;
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;
25 import java.io.FileInputStream;
26 import java.io.InputStream;
28 public class ConfigurationTests {
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();
36 Assert.assertTrue("client configuration setter", cc.isEnabled());
38 Assert.assertFalse("client configuration setter", cc.isEnabled());
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());
52 public void testEndpointDefinition() {
53 RemoteTestingEndpointDefinition def = new RemoteTestingEndpointDefinition();
57 def.setApiKey("FOOBARBAZ");
58 def.setUrl("http://example.com/vtptesting");
59 def.setScenarioFilter("c.*");
61 RemoteTestingEndpointDefinition def2 = new RemoteTestingEndpointDefinition();
63 def2.setEnabled(true);
65 def2.setUrl("http://example.com/vtptesting");
66 def2.setApiKey("FOOBARBAZ");
67 def2.setScenarioFilter("c.*");
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());
74 boolean matches = def.getScenarioFilterPattern().matcher("certification").matches();
75 Assert.assertTrue("pattern", matches);