ca64ec76c57a334e29a1d97e73a26e04bd2dfdf1
[aai/aai-common.git] / aai-core / src / test / java / org / onap / aai / parsers / uri / URIToExtensionInformationTest.java
1 /**
2  * ============LICENSE_START=======================================================
3  * org.onap.aai
4  * ================================================================================
5  * Copyright © 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
10  *
11  *    http://www.apache.org/licenses/LICENSE-2.0
12  *
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=========================================================
19  *
20  * ECOMP is a trademark and service mark of AT&T Intellectual Property.
21  */
22 package org.onap.aai.parsers.uri;
23
24 import org.junit.Ignore;
25 import org.junit.Test;
26 import org.onap.aai.AAISetup;
27 import org.onap.aai.exceptions.AAIException;
28 import org.onap.aai.introspection.Loader;
29 import org.onap.aai.introspection.LoaderFactory;
30 import org.onap.aai.introspection.ModelType;
31 import org.onap.aai.introspection.Version;
32 import org.onap.aai.restcore.HttpMethod;
33
34 import javax.ws.rs.core.UriBuilder;
35 import javax.xml.bind.JAXBException;
36 import java.io.UnsupportedEncodingException;
37 import java.net.URI;
38
39 import static org.junit.Assert.assertEquals;
40
41
42 public class URIToExtensionInformationTest extends AAISetup {
43
44         private Loader v8Loader = LoaderFactory.createLoaderForVersion(ModelType.MOXY, Version.v10);
45         
46         /**
47          * Vservers V 7.
48          *
49          * @throws JAXBException the JAXB exception
50          * @throws AAIException the AAI exception
51          * @throws IllegalArgumentException the illegal argument exception
52          * @throws UnsupportedEncodingException the unsupported encoding exception
53          */
54         @Test
55     public void vserversV8() throws JAXBException, AAIException, IllegalArgumentException, UnsupportedEncodingException {
56                 URI uri = UriBuilder.fromPath("/aai/" + v8Loader.getVersion() + "/cloud-infrastructure/cloud-regions/cloud-region/testOwner1/testRegion1/tenants/tenant/key1/vservers/vserver/key2").build();
57                 URIToExtensionInformation parse = new URIToExtensionInformation(v8Loader, uri);
58                 
59                 String namespace = "cloudInfrastructure";
60                 String preMethodName = "DynamicAddCloudInfrastructureCloudRegionsCloudRegionTenantsTenantVserversVserverPreProc";
61                 String postMethodName = "DynamicAddCloudInfrastructureCloudRegionsCloudRegionTenantsTenantVserversVserverPostProc";
62                 String topLevel = "CloudRegion";
63                 testSpec(parse, HttpMethod.PUT, namespace, preMethodName, postMethodName, topLevel);
64
65         }
66
67         /**
68          * Test spec.
69          *
70          * @param info the info
71          * @param httpMethod the http method
72          * @param namespace the namespace
73          * @param preMethodName the pre method name
74          * @param postMethodName the post method name
75          * @param topLevel the top level
76          */
77         private void testSpec(URIToExtensionInformation info, HttpMethod httpMethod, String namespace, String preMethodName, String postMethodName, String topLevel) {
78                 
79
80                 String namespaceResult = info.getNamespace();
81                 String methodNameResult = info.getMethodName(httpMethod, true);
82                 
83                 assertEquals("namespace", namespace, namespaceResult);
84                 assertEquals("preprocess method name", preMethodName, methodNameResult);
85                 methodNameResult = info.getMethodName(httpMethod, false);
86
87                 assertEquals("postprocess method name", postMethodName, methodNameResult);
88
89                 String topLevelResult = info.getTopObject();
90                 
91                 assertEquals("topLevel", topLevel, topLevelResult);
92         }
93         
94         
95 }