From c185a9bf56303dc4ad9feb4ba5b6227a038f4153 Mon Sep 17 00:00:00 2001 From: "Singal, Kapil (ks220y)" Date: Thu, 19 Dec 2019 11:07:59 -0500 Subject: Fixing JSONParser for JSONArray element Refactoring Related JUnit and fixing test JSON Files Change-Id: I1cd7ba04f53798e4b3f5451de6bfed24054d3ea5 Issue-ID: CCSDK-2008 Signed-off-by: Singal, Kapil (ks220y) --- .../sli/plugins/restapicall/TestJsonParser.java | 18 +++++------------- .../plugins/restapicall/TestRestapiCallNode.java | 15 ++++++++------- .../src/test/resources/actokentemplate.json | 21 --------------------- .../test/resources/l2-dci-connects-template.json | 18 ------------------ .../test/resources/l3-dci-connects-template.json | 20 -------------------- .../src/test/resources/l3smsitetemplate.json | 21 --------------------- .../src/test/resources/l3smvpntemplate.json | 21 --------------------- .../src/test/resources/l3smvrftemplate.json | 21 --------------------- .../provider/src/test/resources/test-template.json | 21 --------------------- .../provider/src/test/resources/test.json | 21 --------------------- 10 files changed, 13 insertions(+), 184 deletions(-) (limited to 'restapi-call-node/provider/src/test') diff --git a/restapi-call-node/provider/src/test/java/org/onap/ccsdk/sli/plugins/restapicall/TestJsonParser.java b/restapi-call-node/provider/src/test/java/org/onap/ccsdk/sli/plugins/restapicall/TestJsonParser.java index 21b66b22..569719d6 100644 --- a/restapi-call-node/provider/src/test/java/org/onap/ccsdk/sli/plugins/restapicall/TestJsonParser.java +++ b/restapi-call-node/provider/src/test/java/org/onap/ccsdk/sli/plugins/restapicall/TestJsonParser.java @@ -8,9 +8,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -68,14 +68,7 @@ public class TestJsonParser { String path = "src/test/resources/ArrayMenu.json"; String content = new String(Files.readAllBytes(Paths.get(path))); Map mm = JsonParser.convertToProperties(content); - assertEquals("plain", mm.get("name")); - assertEquals("true", mm.get("vegetarian")); - assertEquals("1", mm.get("id")); - assertEquals("1000", mm.get("calories")); - assertEquals("pizza", mm.get("type")); - - // The below statements are how I expected it to work, but it does not work this way -/* + assertEquals("1000", mm.get("[0].calories")); assertEquals("1", mm.get("[0].id")); assertEquals("plain", mm.get("[0].name")); @@ -104,7 +97,6 @@ public class TestJsonParser { assertEquals("pizza", mm.get("[2].type")); assertEquals("true", mm.get("[2].vegetarian")); assertEquals("3", mm.get("_length")); -*/ } @Test @@ -222,8 +214,8 @@ public class TestJsonParser { // Break the embedded json object into properties mm = JsonParser.convertToProperties(mm.get("input.parameters[0].value")); - assertEquals("0.2.0.0/16", mm.get("id")); - // assertEquals("ge04::/64", mm.get("id")); this second value gets lost + assertEquals("0.2.0.0/16", mm.get("[0].id")); + assertEquals("ge04::/64", mm.get("[1].id")); } } diff --git a/restapi-call-node/provider/src/test/java/org/onap/ccsdk/sli/plugins/restapicall/TestRestapiCallNode.java b/restapi-call-node/provider/src/test/java/org/onap/ccsdk/sli/plugins/restapicall/TestRestapiCallNode.java index 0704d297..8cabaadc 100755 --- a/restapi-call-node/provider/src/test/java/org/onap/ccsdk/sli/plugins/restapicall/TestRestapiCallNode.java +++ b/restapi-call-node/provider/src/test/java/org/onap/ccsdk/sli/plugins/restapicall/TestRestapiCallNode.java @@ -29,15 +29,11 @@ import java.util.HashMap; import java.util.Map; import org.codehaus.jettison.json.JSONObject; -import org.glassfish.grizzly.http.server.HttpServer; -import org.glassfish.jersey.grizzly2.httpserver.GrizzlyHttpServerFactory; -import org.glassfish.jersey.media.multipart.MultiPartFeature; -import org.glassfish.jersey.server.ResourceConfig; +import org.junit.Before; import org.junit.Test; import org.onap.ccsdk.sli.core.sli.SvcLogicContext; import org.onap.ccsdk.sli.core.sli.SvcLogicException; -import org.onap.ccsdk.sli.plugins.restapicall.RestapiCallNode; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -46,6 +42,11 @@ public class TestRestapiCallNode { @SuppressWarnings("unused") private static final Logger log = LoggerFactory.getLogger(TestRestapiCallNode.class); + @Before + public void init() { + System.setProperty("SDNC_CONFIG_DIR", "src/test/resources"); + } + @Test public void testDelete() throws SvcLogicException { SvcLogicContext ctx = new SvcLogicContext(); @@ -476,7 +477,7 @@ public class TestRestapiCallNode { assertEquals(partnerTwoUsername,details.username); assertEquals(partnerTwoPassword,details.password); assertNull(rcn.partnerStore.get("partnerThree")); - + //In this scenario the caller expects username, password and url to be picked up from the partners json Map paramMap = new HashMap(); paramMap.put("partner", partnerTwoKey); @@ -497,7 +498,7 @@ public class TestRestapiCallNode { assertEquals(partnerTwoPassword,p.restapiPassword); assertEquals("http://localhost:7002/networking/v1/instance/3",p.restapiUrl); } - + @Test public void retryPolicyBean() throws Exception { Integer retries = 3; diff --git a/restapi-call-node/provider/src/test/resources/actokentemplate.json b/restapi-call-node/provider/src/test/resources/actokentemplate.json index 31bf0ee2..02e62400 100644 --- a/restapi-call-node/provider/src/test/resources/actokentemplate.json +++ b/restapi-call-node/provider/src/test/resources/actokentemplate.json @@ -1,24 +1,3 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP : SDN-C - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights - * reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - { "userName": ${prop.sdncRestApi.thirdpartySdnc.user}, "password": ${prop.sdncRestApi.thirdpartySdnc.password} diff --git a/restapi-call-node/provider/src/test/resources/l2-dci-connects-template.json b/restapi-call-node/provider/src/test/resources/l2-dci-connects-template.json index f1807568..e0896bba 100644 --- a/restapi-call-node/provider/src/test/resources/l2-dci-connects-template.json +++ b/restapi-call-node/provider/src/test/resources/l2-dci-connects-template.json @@ -1,21 +1,3 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP : SDN-C - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - { "l2-dci-connect": { "id": ${prop.dci-connects.id}, diff --git a/restapi-call-node/provider/src/test/resources/l3-dci-connects-template.json b/restapi-call-node/provider/src/test/resources/l3-dci-connects-template.json index c011b077..41df794f 100644 --- a/restapi-call-node/provider/src/test/resources/l3-dci-connects-template.json +++ b/restapi-call-node/provider/src/test/resources/l3-dci-connects-template.json @@ -1,23 +1,3 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP : SDN-C - * ================================================================================ - * Copyright (C) 2017 Intel Corp. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - { "l3-dci-connect": { "id": ${prop.dci-connects.id}, diff --git a/restapi-call-node/provider/src/test/resources/l3smsitetemplate.json b/restapi-call-node/provider/src/test/resources/l3smsitetemplate.json index 016879c3..8f815669 100644 --- a/restapi-call-node/provider/src/test/resources/l3smsitetemplate.json +++ b/restapi-call-node/provider/src/test/resources/l3smsitetemplate.json @@ -1,24 +1,3 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP : SDN-C - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights - * reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - { "site":[ { diff --git a/restapi-call-node/provider/src/test/resources/l3smvpntemplate.json b/restapi-call-node/provider/src/test/resources/l3smvpntemplate.json index 67f127ce..30f30a24 100644 --- a/restapi-call-node/provider/src/test/resources/l3smvpntemplate.json +++ b/restapi-call-node/provider/src/test/resources/l3smvpntemplate.json @@ -1,24 +1,3 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP : SDN-C - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights - * reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - { "vpn-service": [ { diff --git a/restapi-call-node/provider/src/test/resources/l3smvrftemplate.json b/restapi-call-node/provider/src/test/resources/l3smvrftemplate.json index 732af278..52359a7f 100644 --- a/restapi-call-node/provider/src/test/resources/l3smvrftemplate.json +++ b/restapi-call-node/provider/src/test/resources/l3smvrftemplate.json @@ -1,24 +1,3 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP : SDN-C - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights - * reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - { "vrf-attribute": [ { diff --git a/restapi-call-node/provider/src/test/resources/test-template.json b/restapi-call-node/provider/src/test/resources/test-template.json index faefef31..ae519a73 100644 --- a/restapi-call-node/provider/src/test/resources/test-template.json +++ b/restapi-call-node/provider/src/test/resources/test-template.json @@ -1,24 +1,3 @@ -/*- - * ============LICENSE_START======================================================= - * openECOMP : SDN-C - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights - * reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - { "sdn-circuit-request": [ ${repeat:tmp.sdn-circuit-req-row_length: diff --git a/restapi-call-node/provider/src/test/resources/test.json b/restapi-call-node/provider/src/test/resources/test.json index b48eb6b4..75155393 100644 --- a/restapi-call-node/provider/src/test/resources/test.json +++ b/restapi-call-node/provider/src/test/resources/test.json @@ -1,24 +1,3 @@ -/*- - * ============LICENSE_START======================================================= - * openECOMP : SDN-C - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights - * reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - { "equipment-data": [ { -- cgit 1.2.3-korg