2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
20 package org.onap.aai.workarounds;
22 import org.junit.Test;
23 import org.onap.aai.AAISetup;
24 import org.onap.aai.introspection.Version;
26 import java.net.MalformedURLException;
28 import java.net.URISyntaxException;
30 import static org.junit.Assert.assertEquals;
33 public class LegacyURITransformerTest extends AAISetup {
35 private LegacyURITransformer uriTransformer = LegacyURITransformer.getInstance();
36 private String fromSuccess = "http://myhostname.com:8443/aai/{version}/cloud-infrastructure/tenants/tenant/key1/vservers/vserver/key2";
37 private String toSuccess = "http://myhostname.com:8443/aai/servers/{version}/key1/vservers/key2";
42 * @throws URISyntaxException
44 * @throws MalformedURLException the malformed URL exception
47 public void v5() throws URISyntaxException {
48 testSpec(Version.v8, fromSuccess, fromSuccess);
55 * @param version the version
56 * @param toExpected the to expected
57 * @param fromExpected the from expected
58 * @throws URISyntaxException
59 * @throws MalformedURLException the malformed URL exception
61 public void testSpec(Version version, String toExpected, String fromExpected) throws URISyntaxException {
63 URI toExpectedUri = new URI(toExpected.replace("{version}",version.toString()));
64 URI fromExpectedUri = new URI(fromExpected.replace("{version}",version.toString()));
66 URI result = toLegacyURISpec(version, fromExpectedUri);
68 assertEquals("to", toExpectedUri, result);
70 result = fromLegacyURISpec(version, toExpectedUri);
72 assertEquals("from", fromExpectedUri, result);
79 * @param version the version
82 * @throws URISyntaxException
83 * @throws MalformedURLException the malformed URL exception
85 public URI toLegacyURISpec(Version version, URI uri) throws URISyntaxException {
90 * From legacy URL spec.
92 * @param version the version
95 * @throws URISyntaxException
96 * @throws MalformedURLException the malformed URL exception
98 public URI fromLegacyURISpec(Version version, URI uri) throws URISyntaxException {