2 * ============LICENSE_START=======================================================
\r
4 * ================================================================================
\r
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
\r
6 * ================================================================================
\r
7 * Copyright (C) 2017 Amdocs
\r
8 * =============================================================================
\r
9 * Licensed under the Apache License, Version 2.0 (the "License");
\r
10 * you may not use this file except in compliance with the License.
\r
11 * You may obtain a copy of the License at
\r
13 * http://www.apache.org/licenses/LICENSE-2.0
\r
15 * Unless required by applicable law or agreed to in writing, software
\r
16 * distributed under the License is distributed on an "AS IS" BASIS,
\r
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
18 * See the License for the specific language governing permissions and
\r
19 * limitations under the License.
\r
21 * ECOMP is a trademark and service mark of AT&T Intellectual Property.
\r
22 * ============LICENSE_END=========================================================
\r
25 package org.onap.sdnc.config.params.transformer.tosca;
\r
27 import java.util.ArrayList;
\r
28 import java.util.List;
\r
29 import org.junit.Assert;
\r
30 import org.junit.Test;
\r
31 import org.onap.sdnc.config.params.data.RequestKey;
\r
32 import org.onap.sdnc.config.params.data.ResponseKey;
\r
34 public class TestPropertyQueryString {
\r
36 public void testBuildResponseKeys() {
\r
37 ArtifactProcessorImpl arp = new ArtifactProcessorImpl();
\r
38 String properties = arp.buildResponseKeyExpression(createResponseKeys());
\r
39 Assert.assertEquals(
\r
40 "<response-keys = address-fqdn:0000000000000:ipaddress-v4 , key2:value2:field2>",
\r
45 public void testBuildRequestKeys() {
\r
46 ArtifactProcessorImpl arp = new ArtifactProcessorImpl();
\r
47 String properties = arp.buildRequestKeyExpression(createRequestKeys());
\r
48 Assert.assertEquals(
\r
49 "<request-keys = class-type:interface-ip-address , address_fqdn:00000000000000 , address_type:v4>",
\r
54 public void testEncoding() {
\r
55 ArtifactProcessorImpl arp = new ArtifactProcessorImpl();
\r
57 String expected1 = "<class-type>";
\r
58 String encoded1 = arp.encode("<class-type>");
\r
59 Assert.assertEquals(expected1, encoded1);
\r
61 String expected2 = "<<<metallica<>iron_maiden>>>";
\r
62 String encoded2 = arp.encode("<<<metallica<>iron_maiden>>>");
\r
63 Assert.assertEquals(expected2, encoded2);
\r
65 String expected3 = "band-list:metallica,ironmaiden";
\r
66 String encoded3 = arp.encode("band-list:metallica,ironmaiden");
\r
67 Assert.assertEquals(expected3, encoded3);
\r
69 String expected4 = "motorhead=lemmy";
\r
70 String encoded4 = arp.encode("motorhead=lemmy");
\r
71 Assert.assertEquals(expected4, encoded4);
\r
73 String expected5 = "DreamTheater";
\r
74 String encoded5 = arp.encode(" DreamTheater ");
\r
75 Assert.assertEquals(expected5, encoded5);
\r
79 public void testBuildRuleType() {
\r
80 ArtifactProcessorImpl arp = new ArtifactProcessorImpl();
\r
81 String input = "IPV4";
\r
82 String expected = "<rule-type = IPV4>";
\r
83 Assert.assertEquals(expected, arp.buildRuleType(input));
\r
87 public void testRuleTypeSetNull() {
\r
88 ArtifactProcessorImpl arp = new ArtifactProcessorImpl();
\r
89 String expected = "<rule-type = >";
\r
90 Assert.assertEquals(expected, arp.buildRuleType(null));
\r
94 public void testBuildRequestKeysWithKeyNull() {
\r
95 ArtifactProcessorImpl arp = new ArtifactProcessorImpl();
\r
96 List<RequestKey> requestKeyList = new ArrayList<RequestKey>();
\r
97 requestKeyList.add(null);
\r
98 String properties = arp.buildRequestKeyExpression(requestKeyList);
\r
99 Assert.assertEquals("<request-keys = >", properties);
\r
103 public void testBuildResponseKeysWithKeyNull() {
\r
104 ArtifactProcessorImpl arp = new ArtifactProcessorImpl();
\r
105 List<ResponseKey> responseKeyList = new ArrayList<ResponseKey>();
\r
106 responseKeyList.add(null);
\r
107 String properties = arp.buildResponseKeyExpression(responseKeyList);
\r
108 Assert.assertEquals("<response-keys = >", properties);
\r
112 public void testBuildSourceSystem() {
\r
113 ArtifactProcessorImpl arp = new ArtifactProcessorImpl();
\r
114 Assert.assertEquals("<source-system = source>", arp.buildSourceSystem("source"));
\r
118 private List<RequestKey> createRequestKeys() {
\r
119 // Create RequestKey object 1
\r
120 RequestKey requestKey1 = new RequestKey();
\r
121 requestKey1.setKeyName("class-type");
\r
122 requestKey1.setKeyValue("interface-ip-address");
\r
124 // Create RequestKey object 2
\r
125 RequestKey requestKey2 = new RequestKey();
\r
126 requestKey2.setKeyName("address_fqdn");
\r
127 requestKey2.setKeyValue("00000000000000");
\r
129 // Create RequestKey object 3
\r
130 RequestKey requestKey3 = new RequestKey();
\r
131 requestKey3.setKeyName("address_type");
\r
132 requestKey3.setKeyValue("v4");
\r
134 // Add the RequestKey Objects to the List
\r
135 List<RequestKey> requestKeyList = new ArrayList<RequestKey>();
\r
136 requestKeyList.add(requestKey1);
\r
137 requestKeyList.add(requestKey2);
\r
138 requestKeyList.add(requestKey3);
\r
139 return requestKeyList;
\r
143 private List<ResponseKey> createResponseKeys() {
\r
144 // Create RequestKey object 1
\r
145 ResponseKey responseKey1 = new ResponseKey();
\r
147 responseKey1.setUniqueKeyName("address-fqdn");
\r
148 responseKey1.setUniqueKeyValue("0000000000000");
\r
149 responseKey1.setFieldKeyName("ipaddress-v4");
\r
151 ResponseKey responseKey2 = new ResponseKey();
\r
152 responseKey2.setUniqueKeyName("key2");
\r
153 responseKey2.setUniqueKeyValue("value2");
\r
154 responseKey2.setFieldKeyName("field2");
\r
156 // Add the RequestKey Objects to the List
\r
157 List<ResponseKey> responseKeyList = new ArrayList<ResponseKey>();
\r
158 responseKeyList.add(responseKey1);
\r
159 responseKeyList.add(responseKey2);
\r
161 return responseKeyList;
\r