Merge "Reorder modifiers"
[so.git] / common / src / test / java / org / openecomp / mso / client / aai / AAIConfigurationTest.java
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.openecomp.mso.client.aai;
22
23 import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
24 import static com.github.tomakehurst.wiremock.client.WireMock.get;
25 import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo;
26 import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.wireMockConfig;
27 import static org.junit.Assert.assertEquals;
28
29 import java.util.UUID;
30
31 import org.junit.Ignore;
32 import org.junit.Rule;
33 import org.junit.Test;
34 import org.openecomp.mso.client.aai.entities.uri.AAIUri;
35 import org.openecomp.mso.client.aai.entities.uri.AAIUriFactory;
36 import org.openecomp.mso.serviceinstancebeans.ModelInfo;
37 import org.openecomp.mso.serviceinstancebeans.RequestDetails;
38
39 import com.github.tomakehurst.wiremock.junit.WireMockRule;
40
41 public class AAIConfigurationTest {
42
43         @Rule
44         public WireMockRule wireMockRule = new WireMockRule(wireMockConfig().port(8443));
45         
46         @Ignore
47         @Test
48         public void verifyCreate() {
49                 AAIConfigurationClient aaiConfiguration = new AAIConfigurationClient();
50                 ModelInfo modelInfo = new ModelInfo();
51                 modelInfo.setModelInvariantId("testInvariantID");
52                 modelInfo.setModelVersionId("testVersionID");
53                 modelInfo.setModelCustomizationId("testCustomizationID");
54                 RequestDetails requestDetails = new RequestDetails();
55                 requestDetails.setModelInfo(modelInfo);
56                 String configurationType = "test";
57                 String configurationSubType = "test";
58                 aaiConfiguration.createConfiguration(requestDetails, UUID.randomUUID().toString(), configurationType, configurationSubType);
59         }
60         
61         @Test
62         public void verifyNotExists() {
63                 AAIUri path = AAIUriFactory.createResourceUri(AAIObjectType.CONFIGURATION, "test2");
64                 wireMockRule.stubFor(get(
65                                 urlPathEqualTo("/aai/v11" + path.build()))
66                                 .willReturn(
67                                         aResponse()
68                                         .withHeader("Content-Type", "text/plain")
69                                         .withBody("hello")
70                                         .withStatus(404)));
71                 AAIConfigurationClient aaiConfiguration = new AAIConfigurationClient();
72                 boolean result = aaiConfiguration.configurationExists("test2");
73                 assertEquals("path not found", false, result);
74         }
75 }