2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright © 2017-2018 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=========================================================
20 package org.onap.aai.rest;
22 import com.jayway.jsonpath.JsonPath;
23 import org.junit.Before;
24 import org.junit.Ignore;
25 import org.junit.Test;
26 import org.junit.runner.RunWith;
27 import org.onap.aai.AAIJunitRunner;
28 import org.onap.aai.HttpTestUtil;
29 import org.onap.aai.PayloadUtil;
30 import org.onap.aai.exceptions.AAIException;
31 import org.skyscreamer.jsonassert.JSONAssert;
33 import javax.ws.rs.core.Response;
34 import java.io.IOException;
36 import static org.junit.Assert.assertEquals;
39 * <b>CloudRegionTest</b> is testing if you put a cloud region with all
40 * children nodes associated to it then you should be able to
41 * remove the cloud region without removing the individual child nodes first
43 @RunWith(AAIJunitRunner.class)
44 public class CloudRegionTest {
46 private HttpTestUtil httpTestUtil;
50 httpTestUtil = new HttpTestUtil();
53 @Ignore("Test is failing due to the deletion of node with children not correct will be fixed soon")
55 public void testPutWithAllCloudRegionChildrenNodesAndCheckIfDeleteIsSuccessful() throws IOException, AAIException {
57 String cloudRegionPayload = PayloadUtil.getResourcePayload("cloud-region-with-all-children.json");
58 String cloudRegionUri = "/aai/v12/cloud-infrastructure/cloud-regions/cloud-region/junit-cloud-owner/junit-cloud-region";
60 Response response = httpTestUtil.doPut(cloudRegionUri, cloudRegionPayload);
61 assertEquals("Expected the cloud region to be created", 201, response.getStatus());
63 response = httpTestUtil.doGet(cloudRegionUri);
64 assertEquals("Expected the cloud region to be found", 200, response.getStatus());
65 String jsonResponse = response.getEntity().toString();
67 JSONAssert.assertEquals(cloudRegionPayload, jsonResponse, false);
68 String resourceVersion = JsonPath.read(jsonResponse, "$.resource-version");
70 response = httpTestUtil.doDelete(cloudRegionUri, resourceVersion);
71 assertEquals("Expected the cloud region to be deleted", 204, response.getStatus());