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