2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright © 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
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 * ECOMP is a trademark and service mark of AT&T Intellectual Property.
22 package org.onap.aai.rest;
24 import org.json.JSONObject;
25 import org.junit.Before;
26 import org.junit.Test;
27 import org.junit.runner.RunWith;
28 import org.onap.aai.AAIJunitRunner;
29 import org.onap.aai.HttpTestUtil;
30 import org.onap.aai.PayloadUtil;
31 import org.skyscreamer.jsonassert.JSONAssert;
33 import javax.ws.rs.core.Response;
34 import java.util.HashMap;
37 import static org.junit.Assert.assertEquals;
39 @RunWith(AAIJunitRunner.class)
40 public class GenericVnfLInterfaceTest {
42 private HttpTestUtil httpTestUtil;
46 httpTestUtil = new HttpTestUtil();
50 public void testPutTwoLInterfacesToGenericVnf() throws Exception {
52 Map<String, String> templateValueMap = new HashMap<>();
53 templateValueMap.put("ip-address", "ipv1");
55 String resource = PayloadUtil.getTemplatePayload("generic-vnf-with-lag-interface.json", templateValueMap);
56 Response response = httpTestUtil.doPut("/aai/v12/network/generic-vnfs/generic-vnf/vnf1", resource);
57 assertEquals("Expecting the generic vnf to be created", 201, response.getStatus());
59 response = httpTestUtil.doGet("/aai/v12/network/generic-vnfs/generic-vnf/vnf1");
60 assertEquals("Expecting the generic vnf to be updated", 200, response.getStatus());
62 resource = response.getEntity().toString().replaceAll("ipv1\",\"resource-version\":\"\\d+\"", "ipv2\"");
63 response = httpTestUtil.doPut("/aai/v12/network/generic-vnfs/generic-vnf/vnf1", resource);
64 assertEquals("Expecting the generic vnf to be updated", 200, response.getStatus());
66 response = httpTestUtil.doGet("/aai/v12/network/generic-vnfs/generic-vnf/vnf1");
67 assertEquals("Expecting the generic vnf to be updated", 200, response.getStatus());
69 String expected = PayloadUtil.getExpectedPayload("generic-vnf-with-lag-interface.json");
70 JSONAssert.assertEquals(expected, response.getEntity().toString(), false);
72 JSONObject jsonObject = new JSONObject(response.getEntity().toString());
73 String resourceVersion = (String) jsonObject.get("resource-version");
75 response = httpTestUtil.doDelete("/aai/v12/network/generic-vnfs/generic-vnf/vnf1", resourceVersion);
76 assertEquals("Expecting the generic vnf to be deleted", 204, response.getStatus());