2cbf5bb09016185d5a297230ae73f953875d32a5
[so.git] /
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP - SO
4  * ================================================================================
5  * Copyright (C) 2017 - 2019 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.hamcrest.CoreMatchers.equalTo;
24 import org.junit.Rule;
25 import org.junit.Test;
26 import org.junit.rules.ExpectedException;
27 import org.onap.aaiclient.client.aai.AAIObjectPlurals;
28 import org.onap.aaiclient.client.aai.AAIObjectType;
29 import org.onap.aaiclient.client.graphinventory.exceptions.IncorrectNumberOfUriKeys;
30
31 public class IncorrectNumberOfUriKeysTest {
32
33     @Rule
34     public ExpectedException thrown = ExpectedException.none();
35
36     @Test
37     public void verifyIncorrectNumberOfKeysSingle() {
38
39         thrown.expect(IncorrectNumberOfUriKeys.class);
40         thrown.expectMessage(equalTo("Expected 3 variables: [cloud-owner, cloud-region-id, volume-group-id]"));
41         AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.VOLUME_GROUP, "volume-group-id");
42
43     }
44
45     @Test
46     public void verifyIncorrectNumberOfKeysPlural() {
47
48         thrown.expect(IncorrectNumberOfUriKeys.class);
49         AAISimplePluralUri uri = AAIUriFactory.createResourceUri(AAIObjectPlurals.VOLUME_GROUP, "my-cloud-owner");
50
51     }
52
53     @Test
54     public void verifyIncorrectNumberOfKeysFromParent() {
55
56         thrown.expect(IncorrectNumberOfUriKeys.class);
57         AAIResourceUri parentUri =
58                 AAIUriFactory.createResourceUri(AAIObjectType.CLOUD_REGION, "my-cloud-owner", "my-cloud-region-id");
59         AAIResourceUri uri = AAIUriFactory.createResourceFromParentURI(parentUri, AAIObjectType.VOLUME_GROUP);
60     }
61
62     @Test
63     public void verifyIncorrectNumberOfKeysHttpAware() {
64
65         thrown.expect(IncorrectNumberOfUriKeys.class);
66         AAIResourceUri uri =
67                 AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, "customer-id", "subscription-id");
68     }
69 }