From 1fe45f8292b6ff00d394fa6530e00cba1664f1ae Mon Sep 17 00:00:00 2001 From: Kanagaraj Manickam k00365106 Date: Wed, 9 May 2018 11:43:34 +0000 Subject: Fix assertion in http inputoutput test Issue-ID: CLI-100 Change-Id: I32dce5365f2fdf30a064cbf9bd4fa917b062f0dc Signed-off-by: Kanagaraj Manickam k00365106 --- .../src/test/java/org/onap/cli/fw/http/HttpInputOutputTest.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'profiles') diff --git a/profiles/http/src/test/java/org/onap/cli/fw/http/HttpInputOutputTest.java b/profiles/http/src/test/java/org/onap/cli/fw/http/HttpInputOutputTest.java index 7a7a31c7..597a3280 100644 --- a/profiles/http/src/test/java/org/onap/cli/fw/http/HttpInputOutputTest.java +++ b/profiles/http/src/test/java/org/onap/cli/fw/http/HttpInputOutputTest.java @@ -43,9 +43,9 @@ public class HttpInputOutputTest { inp.setReqHeaders(new HashMap()); inp.setReqQueries(new HashMap()); - assertTrue( - "\nURL: uri\nMethod: method\nRequest Queries: {}\nRequest Body: body\nRequest Headers: {}\nRequest Cookies: {}\nbinaryData=false\nContext={}" - .equals(inp.toString())); + String msg = "\nURL: uri\nMethod: method\nRequest Queries: {}\nRequest Body: body\nRequest Headers: " + + "{}\nRequest Cookies: {}\nbinaryData=false\nContext={}"; + assertTrue(msg.equals(inp.toString())); } @Test -- cgit 1.2.3-korg From 15e7a9622f615ad2e1b635711255c612d5018220 Mon Sep 17 00:00:00 2001 From: Kanagaraj Manickam k00365106 Date: Wed, 9 May 2018 11:44:11 +0000 Subject: Correct the order of imports in http conn Issue-ID: CLI-100 Change-Id: Ieab2c89218d4f7b83e658c365e0e15e46e335fb7 Signed-off-by: Kanagaraj Manickam k00365106 --- .../src/test/java/org/onap/cli/fw/http/OnapHttpConnectionTest.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'profiles') diff --git a/profiles/http/src/test/java/org/onap/cli/fw/http/OnapHttpConnectionTest.java b/profiles/http/src/test/java/org/onap/cli/fw/http/OnapHttpConnectionTest.java index fe29936a..fab02ff2 100644 --- a/profiles/http/src/test/java/org/onap/cli/fw/http/OnapHttpConnectionTest.java +++ b/profiles/http/src/test/java/org/onap/cli/fw/http/OnapHttpConnectionTest.java @@ -22,6 +22,10 @@ import java.io.IOException; import java.util.HashMap; import java.util.Map; +import mockit.Invocation; +import mockit.Mock; +import mockit.MockUp; + import org.apache.http.client.ClientProtocolException; import org.apache.http.client.methods.CloseableHttpResponse; import org.apache.http.client.methods.HttpUriRequest; @@ -34,9 +38,6 @@ import org.onap.cli.fw.http.connect.HttpResult; import org.onap.cli.fw.http.connect.OnapHttpConnection; import org.onap.cli.fw.http.error.OnapCommandHttpFailure; -import mockit.Invocation; -import mockit.Mock; -import mockit.MockUp; public class OnapHttpConnectionTest { HttpInput inp = null; -- cgit 1.2.3-korg From da3ada5bd9e3ec7e64af14e9358fde1d158eb4e1 Mon Sep 17 00:00:00 2001 From: Kanagaraj Manickam k00365106 Date: Wed, 9 May 2018 11:44:46 +0000 Subject: Remove extra line into multiple Issue-ID: CLI-100 Change-Id: Ie711ce9f3166a94e0ef0cfc2be3419adf21d388f Signed-off-by: Kanagaraj Manickam k00365106 --- .../fw/http/auth/OnapAuthClientCommandBasedTest.java | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'profiles') diff --git a/profiles/http/src/test/java/org/onap/cli/fw/http/auth/OnapAuthClientCommandBasedTest.java b/profiles/http/src/test/java/org/onap/cli/fw/http/auth/OnapAuthClientCommandBasedTest.java index d3059449..174c066c 100644 --- a/profiles/http/src/test/java/org/onap/cli/fw/http/auth/OnapAuthClientCommandBasedTest.java +++ b/profiles/http/src/test/java/org/onap/cli/fw/http/auth/OnapAuthClientCommandBasedTest.java @@ -33,14 +33,16 @@ public class OnapAuthClientCommandBasedTest { @Before public void setup() throws OnapCommandProductVersionInvalid, OnapCommandException { - OnapCommandRegistrar.getRegistrar().setEnabledProductVersion(OnapCommandConfig.getPropertyValue(OnapCommandConstants.OPEN_CLI_PRODUCT_NAME)); + OnapCommandRegistrar.getRegistrar().setEnabledProductVersion( + OnapCommandConfig.getPropertyValue(OnapCommandConstants.OPEN_CLI_PRODUCT_NAME)); } @Test public void yesCatalogYesAuthTest() throws OnapCommandException { try { OnapHttpCommand cmd = getCommand("sample-test-schema-yes-auth-yes-catalog.yaml"); - cmd.getParametersMap().get(OnapCommandHttpConstants.DEAFULT_PARAMETER_HOST_URL).setValue("http://localhost:8080"); + cmd.getParametersMap().get(OnapCommandHttpConstants.DEAFULT_PARAMETER_HOST_URL) + .setValue("http://localhost:8080"); cmd.getParametersMap().get(OnapCommandHttpConstants.DEAFULT_PARAMETER_USERNAME).setValue("test"); cmd.getParametersMap().get(OnapCommandHttpConstants.DEAFULT_PARAMETER_PASSWORD).setValue("password"); @@ -55,7 +57,8 @@ public class OnapAuthClientCommandBasedTest { public void yesCatalogNoAuthTest() throws OnapCommandException { try { OnapHttpCommand cmd = getCommand("sample-test-schema-no-auth-yes-catalog.yaml"); - cmd.getParametersMap().get(OnapCommandHttpConstants.DEAFULT_PARAMETER_HOST_URL).setValue("http://localhost:8080"); + cmd.getParametersMap().get(OnapCommandHttpConstants.DEAFULT_PARAMETER_HOST_URL) + .setValue("http://localhost:8080"); cmd.execute(); } catch (OnapCommandException e) { @@ -68,7 +71,8 @@ public class OnapAuthClientCommandBasedTest { public void noCatalogYesAuthTest() throws OnapCommandException { try { OnapHttpCommand cmd = getCommand("sample-test-schema-yes-auth-no-catalog.yaml"); - cmd.getParametersMap().get(OnapCommandHttpConstants.DEAFULT_PARAMETER_HOST_URL).setValue("http://localhost:8080"); + cmd.getParametersMap().get(OnapCommandHttpConstants.DEAFULT_PARAMETER_HOST_URL) + .setValue("http://localhost:8080"); cmd.getParametersMap().get(OnapCommandHttpConstants.DEAFULT_PARAMETER_USERNAME).setValue("test"); cmd.getParametersMap().get(OnapCommandHttpConstants.DEAFULT_PARAMETER_PASSWORD).setValue("password"); @@ -109,7 +113,8 @@ public class OnapAuthClientCommandBasedTest { protected void processRequest() throws OnapCommandException { if (!this.getService().isModeDirect()) { String url = this.authClient.getServiceUrl(); - assert url.equals(this.getParametersMap().get(OnapCommandHttpConstants.DEAFULT_PARAMETER_HOST_URL).getValue() + "/"); + assert url.equals(this.getParametersMap().get(OnapCommandHttpConstants.DEAFULT_PARAMETER_HOST_URL) + .getValue() + "/"); } } }; @@ -118,4 +123,4 @@ public class OnapAuthClientCommandBasedTest { return cmd; } - } +} -- cgit 1.2.3-korg From d2c81be4533619e2593c2fbe1392a2a33694405d Mon Sep 17 00:00:00 2001 From: Kanagaraj Manickam k00365106 Date: Wed, 9 May 2018 11:45:25 +0000 Subject: Fix the samples in utils test Issue-ID: CLI-100 Change-Id: I2b95749095d86c1ceb3a882a4f93fd173b5c9df9 Signed-off-by: Kanagaraj Manickam k00365106 --- .../cli/fw/http/utils/OnapCommandUtilsTest.java | 40 +++++++++++++++++++--- 1 file changed, 36 insertions(+), 4 deletions(-) (limited to 'profiles') diff --git a/profiles/http/src/test/java/org/onap/cli/fw/http/utils/OnapCommandUtilsTest.java b/profiles/http/src/test/java/org/onap/cli/fw/http/utils/OnapCommandUtilsTest.java index 13b2db42..6e03e74b 100644 --- a/profiles/http/src/test/java/org/onap/cli/fw/http/utils/OnapCommandUtilsTest.java +++ b/profiles/http/src/test/java/org/onap/cli/fw/http/utils/OnapCommandUtilsTest.java @@ -101,7 +101,11 @@ public class OnapCommandUtilsTest { public void populateOutputsTest() throws OnapCommandException { HttpResult output = new HttpResult(); output.setBody( - "{\"serviceName\":\"test\",\"version\":\"v1\",\"url\":\"/api/test/v1\",\"protocol\":\"REST\",\"visualRange\":\"1\",\"lb_policy\":\"hash\",\"nodes\":[{\"ip\":\"127.0.0.1\",\"port\":\"8012\",\"ttl\":0,\"nodeId\":\"test_127.0.0.1_8012\",\"expiration\":\"2017-02-10T05:33:25Z\",\"created_at\":\"2017-02-10T05:33:25Z\",\"updated_at\":\"2017-02-10T05:33:25Z\"}],\"status\":\"1\"}"); + "{\"serviceName\":\"test\",\"version\":\"v1\",\"url\":\"/api/test/v1\",\"protocol\":\"REST\"," + + "\"visualRange\":\"1\",\"lb_policy\":\"hash\",\"nodes\":[{\"ip\":\"127.0.0.1\",\"port\":\"8012\"," + + "\"ttl\":0,\"nodeId\":\"test_127.0.0.1_8012\",\"expiration\":\"2017-02-10T05:33:25Z\"," + + "\"created_at\":\"2017-02-10T05:33:25Z\",\"updated_at\":\"2017-02-10T05:33:25Z\"}]," + + "\"status\":\"1\"}"); Map mapHead = new HashMap<>(); mapHead.put("head1", "value1"); output.setRespHeaders(mapHead); @@ -120,7 +124,8 @@ public class OnapCommandUtilsTest { input1 = OnapCommandHttpUtils.populateOutputs(params, output); } catch (OnapCommandHttpInvalidResponseBody e) { assertEquals( - "0x3004::Http response body does not have json entry {$.serviceName, Missing property in path $['{$']", + "0x3004::Http response body does not have json entry {$.serviceName, " + + "Missing property in path $['{$']", e.getMessage()); } output.setBody("{}"); @@ -140,8 +145,35 @@ public class OnapCommandUtilsTest { @Test public void testJsonEmptyCheck() throws OnapCommandHttpInvalidRequestBody { - String sample = "{\"request\":{\"method\":\"\",\"uri\":\"/onboarding-api/v1.0/vendor-license-models/cf2d907d998e44698ce3b4cded5f66a7/versions/2.0/license-agreements\",\"headers\":{\"Authorization\":\"Basic Y3MwMDA4OmRlbW8xMjM0NTYh\",\"X-FromAppId\":\"onap-cli\",\"Accept\":\"application/json\",\"USER_ID\":\"cs0008\",\"X-TransactionId\":\"req-66a37478-d840-44f8-b436-56f4a3b6f640\",\"Content-Type\":\"application/json\"},\"json\":null},\"response\":{\"status\":200,\"json\":{\"listCount\":2,\"results\":[{\"name\":\"sf\",\"description\":\"sdfgdf\",\"licenseTerm\":{\"choice\":\"Fixed_Term\",\"other\":null},\"id\":\"1e2edfccaca847f896070d0fac26667a\",\"featureGroupsIds\":[\"3a2fb75b52a54e9c8093e7c154210f9e\"]},{\"name\":\"kanag-cli-la\",\"description\":\"kanag cli la\",\"licenseTerm\":{\"choice\":\"Fixed_Term\",\"other\":\"\"},\"id\":\"77e151d0503b45ecb7e40f5f5f1a887e\",\"featureGroupsIds\":[\"3a2fb75b52a54e9c8093e7c154210f9e\"]}]}}}"; - String result = "{\"request\":{\"uri\":\"/onboarding-api/v1.0/vendor-license-models/cf2d907d998e44698ce3b4cded5f66a7/versions/2.0/license-agreements\",\"headers\":{\"Authorization\":\"Basic Y3MwMDA4OmRlbW8xMjM0NTYh\",\"X-FromAppId\":\"onap-cli\",\"Accept\":\"application/json\",\"USER_ID\":\"cs0008\",\"X-TransactionId\":\"req-66a37478-d840-44f8-b436-56f4a3b6f640\",\"Content-Type\":\"application/json\"}},\"response\":{\"status\":200,\"json\":{\"listCount\":2,\"results\":[{\"name\":\"sf\",\"description\":\"sdfgdf\",\"licenseTerm\":{\"choice\":\"Fixed_Term\"},\"id\":\"1e2edfccaca847f896070d0fac26667a\",\"featureGroupsIds\":[\"3a2fb75b52a54e9c8093e7c154210f9e\"]},{\"name\":\"kanag-cli-la\",\"description\":\"kanag cli la\",\"licenseTerm\":{\"choice\":\"Fixed_Term\"},\"id\":\"77e151d0503b45ecb7e40f5f5f1a887e\",\"featureGroupsIds\":[\"3a2fb75b52a54e9c8093e7c154210f9e\"]}]}}}"; + String sample = "{\"request\":{\"method\":\"\",\"uri\":\"/onboarding-api/v1.0/" + + "vendor-license-models/cf2d907d998e44698ce3b4cded5f66a7/versions/2.0/license-agreements\"," + + "\"headers\":{\"Authorization\":\"Basic Y3MwMDA4OmRlbW8xMjM0NTYh\",\"X-FromAppId\":\"onap-cli\"," + + "\"Accept\":\"application/json\",\"USER_ID\":\"cs0008\"," + + "\"X-TransactionId\":\"req-66a37478-d840-44f8-b436-56f4a3b6f640\"," + + "\"Content-Type\":\"application/json\"},\"json\":null}," + + "\"response\":{\"status\":200,\"json\":{\"listCount\":2," + + "\"results\":[{\"name\":\"sf\",\"description\":\"sdfgdf\"," + + "\"licenseTerm\":{\"choice\":\"Fixed_Term\",\"other\":null}," + + "\"id\":\"1e2edfccaca847f896070d0fac26667a\"," + + "\"featureGroupsIds\":[\"3a2fb75b52a54e9c8093e7c154210f9e\"]}," + + "{\"name\":\"kanag-cli-la\",\"description\":\"kanag cli la\"," + + "\"licenseTerm\":{\"choice\":\"Fixed_Term\",\"other\":\"\"}," + + "\"id\":\"77e151d0503b45ecb7e40f5f5f1a887e\"," + + "\"featureGroupsIds\":[\"3a2fb75b52a54e9c8093e7c154210f9e\"]}]}}}"; + String result = "{\"request\":{\"uri\":" + + "\"/onboarding-api/v1.0/vendor-license-models/cf2d907d998e44698ce3b4cded5f66a7/" + + "versions/2.0/license-agreements\",\"headers\":" + + "{\"Authorization\":\"Basic Y3MwMDA4OmRlbW8xMjM0NTYh\"," + + "\"X-FromAppId\":\"onap-cli\",\"Accept\":\"application/json\"," + + "\"USER_ID\":\"cs0008\",\"X-TransactionId\":\"req-66a37478-d840-44f8-b436-56f4a3b6f640\"," + + "\"Content-Type\":\"application/json\"}},\"response\":{\"status\":200," + + "\"json\":{\"listCount\":2,\"results\":[{\"name\":\"sf\"," + + "\"description\":\"sdfgdf\",\"licenseTerm\":{\"choice\":\"Fixed_Term\"}," + + "\"id\":\"1e2edfccaca847f896070d0fac26667a\",\"featureGroupsIds\":" + + "[\"3a2fb75b52a54e9c8093e7c154210f9e\"]},{\"name\":\"kanag-cli-la\"," + + "\"description\":\"kanag cli la\",\"licenseTerm\":{\"choice\":\"Fixed_Term\"}," + + "\"id\":\"77e151d0503b45ecb7e40f5f5f1a887e\",\"featureGroupsIds\":" + + "[\"3a2fb75b52a54e9c8093e7c154210f9e\"]}]}}}"; assertEquals(result, OnapCommandHttpUtils.normalizeJson(sample)); } } -- cgit 1.2.3-korg From 1771f21be73fad02ad9e5736ee8d6412cb824950 Mon Sep 17 00:00:00 2001 From: Kanagaraj Manickam k00365106 Date: Wed, 9 May 2018 11:46:04 +0000 Subject: Fix build warnings in snmp profile Issue-ID: CLI-100 Change-Id: I1a7790d51b7773b931b9f9c0da6332725412a248 Signed-off-by: Kanagaraj Manickam k00365106 --- .../onap/cli/fw/snmp/cmd/OnapSnmpCommandTest.java | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) (limited to 'profiles') diff --git a/profiles/snmp/src/test/java/org/onap/cli/fw/snmp/cmd/OnapSnmpCommandTest.java b/profiles/snmp/src/test/java/org/onap/cli/fw/snmp/cmd/OnapSnmpCommandTest.java index 00c985d5..2fd83f9d 100644 --- a/profiles/snmp/src/test/java/org/onap/cli/fw/snmp/cmd/OnapSnmpCommandTest.java +++ b/profiles/snmp/src/test/java/org/onap/cli/fw/snmp/cmd/OnapSnmpCommandTest.java @@ -16,11 +16,22 @@ package org.onap.cli.fw.snmp.cmd; +import static org.junit.Assert.assertEquals; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + import mockit.Mock; import mockit.MockUp; -import org.junit.*; + +import org.junit.Test; import org.onap.cli.fw.error.OnapCommandException; -import org.onap.cli.fw.error.OnapCommandInvalidParameterValue; import org.onap.cli.fw.input.OnapCommandParameter; import org.onap.cli.fw.input.OnapCommandParameterType; import org.onap.cli.fw.output.OnapCommandResult; @@ -34,10 +45,6 @@ import org.snmp4j.smi.OID; import org.snmp4j.smi.OctetString; import org.snmp4j.smi.VariableBinding; -import java.io.IOException; -import java.util.*; - -import static org.junit.Assert.*; public class OnapSnmpCommandTest { @@ -91,7 +98,6 @@ public class OnapSnmpCommandTest { snmpCmd.run(); OnapCommandResult result = snmpCmd.getResult(); - assertEquals("snmp", result.getRecordsMap().get("system-desc") - .getValues().get(0)); + assertEquals("snmp", result.getRecordsMap().get("system-desc").getValues().get(0)); } } \ No newline at end of file -- cgit 1.2.3-korg