2 * ============LICENSE_START=======================================================
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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=========================================================
21 package org.onap.so.client.aai.entities.uri;
23 import static org.hamcrest.CoreMatchers.equalTo;
24 import static org.mockito.Mockito.mock;
25 import static org.mockito.Mockito.when;
26 import org.junit.Rule;
27 import org.junit.Test;
28 import org.junit.rules.ExpectedException;
29 import org.onap.so.client.aai.AAIObjectPlurals;
30 import org.onap.so.client.aai.AAIObjectType;
31 import org.onap.so.client.graphinventory.exceptions.IncorrectNumberOfUriKeys;
33 public class IncorrectNumberOfUriKeysTest {
36 public ExpectedException thrown = ExpectedException.none();
39 public void verifyIncorrectNumberOfKeysSingle() {
41 thrown.expect(IncorrectNumberOfUriKeys.class);
42 thrown.expectMessage(equalTo("Expected 3 variables: [cloud-owner, cloud-region-id, volume-group-id]"));
43 AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.VOLUME_GROUP, "volume-group-id");
48 public void verifyIncorrectNumberOfKeysPlural() {
50 thrown.expect(IncorrectNumberOfUriKeys.class);
51 AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectPlurals.VOLUME_GROUP, "my-cloud-owner");
56 public void verifyIncorrectNumberOfKeysFromParent() {
58 thrown.expect(IncorrectNumberOfUriKeys.class);
59 AAIResourceUri parentUri =
60 AAIUriFactory.createResourceUri(AAIObjectType.CLOUD_REGION, "my-cloud-owner", "my-cloud-region-id");
61 AAIResourceUri uri = AAIUriFactory.createResourceFromParentURI(parentUri, AAIObjectType.VOLUME_GROUP);
65 public void verifyIncorrectNumberOfKeysHttpAware() {
67 thrown.expect(IncorrectNumberOfUriKeys.class);
69 AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, "customer-id", "subscription-id");