summaryrefslogtreecommitdiffstats
path: root/framework/src/test
diff options
context:
space:
mode:
authorKanagaraj Manickam k00365106 <kanagaraj.manickam@huawei.com>2017-10-04 23:04:34 +0530
committerKanagaraj Manickam k00365106 <kanagaraj.manickam@huawei.com>2017-11-20 12:24:22 +0530
commitc521118e69aaa589d631f95f34dcf88e7a8bd1b6 (patch)
tree0fd1b0c92b95747bb30c6873c43ed63c707e42f6 /framework/src/test
parent863a720fec2abf3fec87cff154df390e29ee5187 (diff)
Add overriding concept to Parameters
Issue-Id: CLI-66 Change-Id: I90b69da1b4235bfa12d4eaffd3f73538fd12a443 Signed-off-by: Kanagaraj Manickam k00365106 <kanagaraj.manickam@huawei.com>
Diffstat (limited to 'framework/src/test')
-rw-r--r--framework/src/test/java/org/onap/cli/fw/ad/OnapAuthClientTest.java214
-rw-r--r--framework/src/test/java/org/onap/cli/fw/ad/OnapCredentialsTest.java32
-rw-r--r--framework/src/test/java/org/onap/cli/fw/utils/OnapCommandUtilsTest.java1
3 files changed, 0 insertions, 247 deletions
diff --git a/framework/src/test/java/org/onap/cli/fw/ad/OnapAuthClientTest.java b/framework/src/test/java/org/onap/cli/fw/ad/OnapAuthClientTest.java
deleted file mode 100644
index 4c14c889..00000000
--- a/framework/src/test/java/org/onap/cli/fw/ad/OnapAuthClientTest.java
+++ /dev/null
@@ -1,214 +0,0 @@
-/*
- * Copyright 2017 Huawei Technologies Co., Ltd.
- *
- * 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.
- */
-
-package org.onap.cli.fw.ad;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import static org.junit.Assert.assertEquals;
-
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.Ignore;
-import org.junit.Test;
-import org.onap.cli.fw.conf.OnapCommandConfg;
-import org.onap.cli.fw.error.OnapCommandException;
-import org.onap.cli.fw.error.OnapCommandExecutionFailed;
-import org.onap.cli.fw.error.OnapCommandHttpFailure;
-import org.onap.cli.fw.error.OnapCommandServiceNotFound;
-import org.onap.cli.fw.http.HttpInput;
-import org.onap.cli.fw.http.HttpResult;
-import org.onap.cli.fw.http.OnapHttpConnection;
-import org.onap.cli.fw.input.OnapCommandParameter;
-
-import mockit.Invocation;
-import mockit.Mock;
-import mockit.MockUp;
-
-@Ignore
-public class OnapAuthClientTest {
-
- OnapAuthClient client;
-
- @Before
- public void setUp() throws OnapCommandHttpFailure, OnapCommandException {
- OnapCredentials creds = new OnapCredentials("test", "test123", "http://192.168.99.10:80");
- OnapService service = new OnapService();
- List<OnapCommandParameter> params = new ArrayList<>();
- client = new OnapAuthClient(null, false);
- }
-
- @Test
- public void loginFailedAuthIgnoredTest() throws OnapCommandException {
- OnapCredentials creds = new OnapCredentials("test", "test123", "http://192.168.99.10:80");
- OnapService service = new OnapService();
- List<OnapCommandParameter> params = new ArrayList<>();
- if (OnapCommandConfg.isAuthIgnored()) {
- client.getDebugInfo();
- client.login();
- }
- }
-
- @Test
- public void logoutFailedAuthIgnoredTest() throws OnapCommandException {
- OnapCredentials creds = new OnapCredentials("test", "test123", "http://192.168.99.10:80");
- OnapService service = new OnapService();
- List<OnapCommandParameter> params = new ArrayList<>();
- if (OnapCommandConfg.isAuthIgnored()) {
- client.logout();
- }
- }
-
- @Test
- public void getMsbUrlTest() throws OnapCommandException {
- OnapCredentials creds = new OnapCredentials("test", "test123", "http://192.168.99.10:80");
- OnapService service = new OnapService();
- List<OnapCommandParameter> params = new ArrayList<>();
- OnapService srv = new OnapService();
- srv.setName("msb");
- String msb = client.getServiceUrl();
- assertEquals("http://192.168.99.10:80/api/microservices/v1", msb);
- }
-
- @Ignore
- @Test(expected = OnapCommandServiceNotFound.class)
- public void loginFailedServiceNotFoundTest() throws OnapCommandException {
- mockIsAuthIgnored(false);
- HttpResult result = new HttpResult();
- result.setStatus(404);
- mockHttpRequest(result);
- client.login();
-
- }
-
- @Ignore
- @Test(expected = OnapCommandExecutionFailed.class)
- public void loginFailedCommandExecutionFailedTest() throws OnapCommandException {
-
- mockIsAuthIgnored(false);
- HttpResult result = new HttpResult();
- result.setStatus(401);
- mockHttpRequest(result);
- client.login();
- }
-
- @Ignore
- @Test(expected = OnapCommandExecutionFailed.class)
- public void loginFailedWrongJasonBodyTest() throws OnapCommandException {
- mockIsAuthIgnored(false);
- HttpResult result = new HttpResult();
- result.setStatus(200);
- mockHttpRequest(result);
- client.login();
- }
-
- @Ignore
- @Test
- public void loginSuccessTest() {
-
- mockIsAuthIgnored(false);
- HttpResult result = new HttpResult();
- result.setBody("{\"url\":\"http://192.168.4.47\"}");
- result.setStatus(200);
- mockHttpConsecutiveRequest(result);
- try {
- client.login();
- } catch (OnapCommandException e) {
- }
- mockHttpRequest(null);
- }
-
- @Test
- public void logoutFailedTest() {
-
- mockIsAuthIgnored(false);
- HttpResult result = new HttpResult();
- result.setBody("{\"url\":\"http://192.168.4.47\"}");
- result.setStatus(200);
- mockHttpConsecutiveRequest(result);
- try {
- client.logout();
- } catch (OnapCommandException e) {
- }
- mockHttpRequest(null);
- }
-
- @Test
- public void logoutSuccessTest() {
-
- mockIsAuthIgnored(false);
- HttpResult result = new HttpResult();
- result.setBody("{\"url\":\"http://192.168.4.47\"}");
- result.setStatus(204);
- mockHttpConsecutiveRequest(result);
- try {
- client.logout();
- } catch (OnapCommandException e) {
- }
- mockHttpRequest(null);
- }
-
- private void mockIsAuthIgnored(boolean isAuthIgnored) {
-
- new MockUp<OnapCommandConfg>() {
- boolean isMock = true;
-
- @Mock
- public boolean isAuthIgnored(Invocation inv) {
- if (isMock) {
- isMock = false;
- return isAuthIgnored;
- } else {
- return inv.proceed();
- }
- }
- };
- }
-
- private static void mockHttpRequest(HttpResult result) {
- new MockUp<OnapHttpConnection>() {
- boolean isMock = true;
-
- @Mock
- public HttpResult request(Invocation inv, HttpInput input) throws OnapCommandHttpFailure {
- if (isMock) {
- isMock = false;
- return result;
- } else {
- return inv.proceed(input);
- }
- }
- };
- }
-
- private void mockHttpConsecutiveRequest(HttpResult result) {
- new MockUp<OnapHttpConnection>() {
- @Mock
- public HttpResult request(Invocation inv, HttpInput input) throws OnapCommandHttpFailure {
- return result;
- }
- };
- }
-
- @AfterClass
- public static void clear() {
- HttpResult result = new HttpResult();
- result.setBody("{\"url\":\"http://192.168.4.47\"}");
- result.setStatus(200);
- mockHttpRequest(result);
- }
-}
diff --git a/framework/src/test/java/org/onap/cli/fw/ad/OnapCredentialsTest.java b/framework/src/test/java/org/onap/cli/fw/ad/OnapCredentialsTest.java
deleted file mode 100644
index cc431454..00000000
--- a/framework/src/test/java/org/onap/cli/fw/ad/OnapCredentialsTest.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Copyright 2017 Huawei Technologies Co., Ltd.
- *
- * 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.
- */
-
-package org.onap.cli.fw.ad;
-
-import static org.junit.Assert.assertTrue;
-
-import org.junit.Test;
-
-public class OnapCredentialsTest {
-
- @Test
- public void credentialsTest() {
- OnapCredentials cre = new OnapCredentials("test", "test123", "url");
- assertTrue(cre.getUsername().equals("test") && cre.getPassword().equals("test123")
- && cre.getHostUrl().equals("url"));
- }
-
-}
diff --git a/framework/src/test/java/org/onap/cli/fw/utils/OnapCommandUtilsTest.java b/framework/src/test/java/org/onap/cli/fw/utils/OnapCommandUtilsTest.java
index faf8394a..82869fa3 100644
--- a/framework/src/test/java/org/onap/cli/fw/utils/OnapCommandUtilsTest.java
+++ b/framework/src/test/java/org/onap/cli/fw/utils/OnapCommandUtilsTest.java
@@ -37,7 +37,6 @@ import org.junit.Test;
import org.junit.runners.MethodSorters;
import org.onap.cli.fw.OnapCommand;
import org.onap.cli.fw.OnapCommandSchema;
-import org.onap.cli.fw.ad.OnapCredentials;
import org.onap.cli.fw.cmd.OnapHttpCommand;
import org.onap.cli.fw.cmd.OnapSwaggerCommand;
import org.onap.cli.fw.error.OnapCommandException;