X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=restapi-call-node%2Fprovider%2Fsrc%2Ftest%2Fjava%2Forg%2Fonap%2Fccsdk%2Fsli%2Fplugins%2Frestapicall%2FTestRestapiCallNode.java;h=a993bb9468f163b93e07511fff0c191ed613b34e;hb=ad5c70ad6ab8514c5a5e4ed87d76877b1b451ccd;hp=b2f75bcd126be1283aadc5a5541a652ba7dff954;hpb=5b620a76c08ee7420f96bf8ddd6fde2ed4f0e97f;p=ccsdk%2Fsli%2Fplugins.git 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 b2f75bcd..a993bb94 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 @@ -22,8 +22,11 @@ package org.onap.ccsdk.sli.plugins.restapicall; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; + import java.util.HashMap; import java.util.Map; import org.codehaus.jettison.json.JSONObject; @@ -562,5 +565,40 @@ public class TestRestapiCallNode { //This will throw a JSONException and fail the test case if rest api call node doesn't form valid JSON assertNotNull(new JSONObject(request)); } + + @Test + public void testGetMultipleUrls() throws Exception{ + String[] urls = RestapiCallNode.getMultipleUrls("http://localhost:8008/rest/restconf/data/abc:def/abc:action=Create,deviceType=Banana,https://localhost:8008/rest/restconf/data/abc:def/abc:action=Create,deviceType=Potato"); + assertEquals("http://localhost:8008/rest/restconf/data/abc:def/abc:action=Create,deviceType=Banana",urls[0]); + assertEquals("https://localhost:8008/rest/restconf/data/abc:def/abc:action=Create,deviceType=Potato",urls[1]); + + urls = RestapiCallNode.getMultipleUrls("https://wiki.onap.org/,http://localhost:7001/,http://wiki.onap.org/"); + assertEquals("https://wiki.onap.org/",urls[0]); + assertEquals("http://localhost:7001/",urls[1]); + assertEquals("http://wiki.onap.org/",urls[2]); + + urls = RestapiCallNode.getMultipleUrls("https://wiki.onap.org/test=4,5,6,http://localhost:7001/test=1,2,3,http://wiki.onap.org/test=7,8,9,10"); + assertEquals("https://wiki.onap.org/test=4,5,6",urls[0]); + assertEquals("http://localhost:7001/test=1,2,3",urls[1]); + assertEquals("http://wiki.onap.org/test=7,8,9,10",urls[2]); + + urls = RestapiCallNode.getMultipleUrls("https://wiki.onap.org/,https://readthedocs.org/projects/onap/"); + assertEquals("https://wiki.onap.org/",urls[0]); + assertEquals("https://readthedocs.org/projects/onap/",urls[1]); + } + + @Test + public void testContainsMultipleUrls() throws Exception{ + assertFalse(RestapiCallNode.containsMultipleUrls("https://wiki.onap.org/")); + assertFalse(RestapiCallNode.containsMultipleUrls("http://wiki.onap.org/")); + assertFalse(RestapiCallNode.containsMultipleUrls("http://localhost:8008/rest/restconf/data/abc:def/abc:action=Create,deviceType=Banana")); + assertFalse(RestapiCallNode.containsMultipleUrls("https://localhost:8008/params=1,2,3,4,5,6")); + + assertTrue(RestapiCallNode.containsMultipleUrls("https://wiki.onap.org/,https://readthedocs.org/projects/onap/")); + assertTrue(RestapiCallNode.containsMultipleUrls("http://localhost:7001/,http://localhost:7002")); + assertTrue(RestapiCallNode.containsMultipleUrls("http://localhost:8008/rest/restconf/data/abc:def/abc:action=Create,deviceType=Banana,https://localhost:8008/rest/restconf/data/abc:def/abc:action=Create,deviceType=Potato")); + assertTrue(RestapiCallNode.containsMultipleUrls("https://wiki.onap.org/,http://localhost:7001/,http://wiki.onap.org/")); + assertTrue(RestapiCallNode.containsMultipleUrls("https://wiki.onap.org/test=4,5,6,http://localhost:7001/test=1,2,3,http://wiki.onap.org/test=7,8,9,10")); + } }