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