3c8b2e87436298889dacec75c4ddb46d8459f30e
[so.git] /
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP - SO
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.onap.aaiclient.client.aai.entities.uri;
22
23 import static org.junit.Assert.assertEquals;
24 import javax.ws.rs.core.UriBuilder;
25 import org.junit.Test;
26 import org.onap.aaiclient.client.aai.AAIObjectType;
27 import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder;
28
29 public class AAISimpleUriFromUriTest {
30
31
32
33     @Test
34     public void removeHost() {
35
36         AAIResourceUri uri = new AAISimpleUri(AAIObjectType.UNKNOWN,
37                 UriBuilder
38                         .fromUri("https://localhost:8443/aai/v9/network/vces/vce/a9fec18e-1ea3-40e4-a6c0-a89b3de07053")
39                         .build());
40
41         assertEquals("root and version removed", "/network/vces/vce/a9fec18e-1ea3-40e4-a6c0-a89b3de07053",
42                 uri.build().toString());
43
44     }
45
46     @Test
47     public void noChange() {
48
49         AAIResourceUri uri = new AAISimpleUri(AAIObjectType.UNKNOWN,
50                 UriBuilder.fromUri("/network/vces/vce/a9fec18e-1ea3-40e4-a6c0-a89b3de07053").build());
51
52         assertEquals("no change", "/network/vces/vce/a9fec18e-1ea3-40e4-a6c0-a89b3de07053", uri.build().toString());
53
54     }
55
56     @Test
57     public void encodingPreserved() {
58
59         AAIResourceUri uri = new AAISimpleUri(AAIObjectType.UNKNOWN,
60                 UriBuilder.fromUri("/network/vces/vce/a9f%20%20ec18e-1ea3-40e4-a6c0-a89b3de07053").build());
61
62         assertEquals("encoding preserved", "/network/vces/vce/a9f%20%20ec18e-1ea3-40e4-a6c0-a89b3de07053",
63                 uri.build().toString());
64
65     }
66
67     @Test
68     public void beforeBuildEquality() {
69
70         AAIResourceUri uri = new AAISimpleUri(AAIFluentTypeBuilder.network().vce("").build(),
71                 UriBuilder.fromUri("/network/vces/vce/a9f%20%20ec18e-1ea3-40e4-a6c0-a89b3de07053").build());
72
73         AAIResourceUri uri2 = new AAISimpleUri(AAIFluentTypeBuilder.network().vce("").build(),
74                 "a9f  ec18e-1ea3-40e4-a6c0-a89b3de07053");
75         assertEquals("are equal", uri2, uri);
76
77     }
78 }