2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 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=========================================================
21 package org.onap.aai.workarounds;
23 import org.junit.Test;
24 import org.onap.aai.AAISetup;
25 import org.onap.aai.introspection.Version;
27 import java.net.MalformedURLException;
29 import java.net.URISyntaxException;
31 import static org.junit.Assert.assertEquals;
34 public class LegacyURITransformerTest extends AAISetup {
36 private LegacyURITransformer uriTransformer = LegacyURITransformer.getInstance();
37 private String fromSuccess = "http://myhostname.com:8443/aai/{version}/cloud-infrastructure/tenants/tenant/key1/vservers/vserver/key2";
38 private String toSuccess = "http://myhostname.com:8443/aai/servers/{version}/key1/vservers/key2";
43 * @throws URISyntaxException
45 * @throws MalformedURLException the malformed URL exception
48 public void v5() throws URISyntaxException {
49 testSpec(Version.v8, fromSuccess, fromSuccess);
56 * @param version the version
57 * @param toExpected the to expected
58 * @param fromExpected the from expected
59 * @throws URISyntaxException
60 * @throws MalformedURLException the malformed URL exception
62 public void testSpec(Version version, String toExpected, String fromExpected) throws URISyntaxException {
64 URI toExpectedUri = new URI(toExpected.replace("{version}",version.toString()));
65 URI fromExpectedUri = new URI(fromExpected.replace("{version}",version.toString()));
67 URI result = toLegacyURISpec(version, fromExpectedUri);
69 assertEquals("to", toExpectedUri, result);
71 result = fromLegacyURISpec(version, toExpectedUri);
73 assertEquals("from", fromExpectedUri, result);
80 * @param version the version
83 * @throws URISyntaxException
84 * @throws MalformedURLException the malformed URL exception
86 public URI toLegacyURISpec(Version version, URI uri) throws URISyntaxException {
91 * From legacy URL spec.
93 * @param version the version
96 * @throws URISyntaxException
97 * @throws MalformedURLException the malformed URL exception
99 public URI fromLegacyURISpec(Version version, URI uri) throws URISyntaxException {