From a4c4e6ac19b6b36038bf2ec5bca54f1ead616bfc Mon Sep 17 00:00:00 2001 From: "Lott, Christopher (cl778h)" Date: Mon, 13 Jan 2020 16:08:06 -0500 Subject: [PATCH] Improve unit-test coverage Add tests of the API builder classes and methods. Change-Id: I9c4ea2fa63ef83beed81f807fe3eb1c790708595 Signed-off-by: Lott, Christopher (cl778h) --- .../dashboard/config/A1MediatorConfigTest.java | 35 +++++++++++++++++++ .../dashboard/config/AbstractConfigTest.java | 38 ++++++++++++++++++++ .../dashboard/config/AppManagerConfigTest.java | 38 ++++++++++++++++++++ .../dashboard/config/CaasIngressConfigTest.java | 36 +++++++++++++++++++ .../dashboard/config/E2ManagerConfigTest.java | 38 ++++++++++++++++++++ .../ric/portal/dashboard/model/ModelTest.java | 40 ++++++++++++++++++++++ 6 files changed, 225 insertions(+) create mode 100644 webapp-backend/src/test/java/org/oransc/ric/portal/dashboard/config/A1MediatorConfigTest.java create mode 100644 webapp-backend/src/test/java/org/oransc/ric/portal/dashboard/config/AbstractConfigTest.java create mode 100644 webapp-backend/src/test/java/org/oransc/ric/portal/dashboard/config/AppManagerConfigTest.java create mode 100644 webapp-backend/src/test/java/org/oransc/ric/portal/dashboard/config/CaasIngressConfigTest.java create mode 100644 webapp-backend/src/test/java/org/oransc/ric/portal/dashboard/config/E2ManagerConfigTest.java diff --git a/webapp-backend/src/test/java/org/oransc/ric/portal/dashboard/config/A1MediatorConfigTest.java b/webapp-backend/src/test/java/org/oransc/ric/portal/dashboard/config/A1MediatorConfigTest.java new file mode 100644 index 00000000..747b4124 --- /dev/null +++ b/webapp-backend/src/test/java/org/oransc/ric/portal/dashboard/config/A1MediatorConfigTest.java @@ -0,0 +1,35 @@ +/*- + * ========================LICENSE_START================================= + * O-RAN-SC + * %% + * Copyright (C) 2019 AT&T Intellectual Property + * %% + * 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=================================== + */ +package org.oransc.ric.portal.dashboard.config; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.oransc.ric.a1med.client.api.A1MediatorApi; + +public class A1MediatorConfigTest extends AbstractConfigTest { + + @Test + public void builderTest() { + A1MediatorApiBuilder builder = new A1MediatorApiBuilder(instanceConfig, "suffix"); + A1MediatorApi a1Api = builder.getA1MediatorApi(RICInstanceMockConfiguration.INSTANCE_KEY_1); + Assertions.assertNotNull(a1Api); + } + +} diff --git a/webapp-backend/src/test/java/org/oransc/ric/portal/dashboard/config/AbstractConfigTest.java b/webapp-backend/src/test/java/org/oransc/ric/portal/dashboard/config/AbstractConfigTest.java new file mode 100644 index 00000000..4e8a11e5 --- /dev/null +++ b/webapp-backend/src/test/java/org/oransc/ric/portal/dashboard/config/AbstractConfigTest.java @@ -0,0 +1,38 @@ +/*- + * ========================LICENSE_START================================= + * O-RAN-SC + * %% + * Copyright (C) 2020 AT&T Intellectual Property + * %% + * 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=================================== + */ +package org.oransc.ric.portal.dashboard.config; + +import org.junit.jupiter.api.extension.ExtendWith; +import org.oransc.ric.portal.dashboard.model.RicInstanceList; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; +import org.springframework.test.context.ActiveProfiles; +import org.springframework.test.context.junit.jupiter.SpringExtension; + +@ExtendWith(SpringExtension.class) +@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT) +@ActiveProfiles("test") +public class AbstractConfigTest { + + @Autowired + protected RicInstanceList instanceConfig; + +} diff --git a/webapp-backend/src/test/java/org/oransc/ric/portal/dashboard/config/AppManagerConfigTest.java b/webapp-backend/src/test/java/org/oransc/ric/portal/dashboard/config/AppManagerConfigTest.java new file mode 100644 index 00000000..8811ccb5 --- /dev/null +++ b/webapp-backend/src/test/java/org/oransc/ric/portal/dashboard/config/AppManagerConfigTest.java @@ -0,0 +1,38 @@ +/*- + * ========================LICENSE_START================================= + * O-RAN-SC + * %% + * Copyright (C) 2020 AT&T Intellectual Property + * %% + * 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=================================== + */ +package org.oransc.ric.portal.dashboard.config; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.oransc.ric.plt.appmgr.client.api.HealthApi; +import org.oransc.ric.plt.appmgr.client.api.XappApi; + +public class AppManagerConfigTest extends AbstractConfigTest { + + @Test + public void builderTest() { + AppManagerApiBuilder builder = new AppManagerApiBuilder(instanceConfig, "suffix"); + HealthApi healthApi = builder.getHealthApi(RICInstanceMockConfiguration.INSTANCE_KEY_1); + Assertions.assertNotNull(healthApi); + XappApi xappApi = builder.getXappApi(RICInstanceMockConfiguration.INSTANCE_KEY_1); + Assertions.assertNotNull(xappApi); + } + +} diff --git a/webapp-backend/src/test/java/org/oransc/ric/portal/dashboard/config/CaasIngressConfigTest.java b/webapp-backend/src/test/java/org/oransc/ric/portal/dashboard/config/CaasIngressConfigTest.java new file mode 100644 index 00000000..13da4762 --- /dev/null +++ b/webapp-backend/src/test/java/org/oransc/ric/portal/dashboard/config/CaasIngressConfigTest.java @@ -0,0 +1,36 @@ +/*- + * ========================LICENSE_START================================= + * O-RAN-SC + * %% + * Copyright (C) 2020 AT&T Intellectual Property + * %% + * 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=================================== + */ +package org.oransc.ric.portal.dashboard.config; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.oransc.ric.portal.dashboard.k8sapi.SimpleKubernetesClient; + +public class CaasIngressConfigTest extends AbstractConfigTest { + + @Test + public void builderTest() { + SimpleKubernetesClientBuilder builder = new SimpleKubernetesClientBuilder(instanceConfig, "suffix"); + SimpleKubernetesClient clientApi = builder + .getSimpleKubernetesClient(RICInstanceMockConfiguration.INSTANCE_KEY_1); + Assertions.assertNotNull(clientApi); + } + +} diff --git a/webapp-backend/src/test/java/org/oransc/ric/portal/dashboard/config/E2ManagerConfigTest.java b/webapp-backend/src/test/java/org/oransc/ric/portal/dashboard/config/E2ManagerConfigTest.java new file mode 100644 index 00000000..a1094e26 --- /dev/null +++ b/webapp-backend/src/test/java/org/oransc/ric/portal/dashboard/config/E2ManagerConfigTest.java @@ -0,0 +1,38 @@ +/*- + * ========================LICENSE_START================================= + * O-RAN-SC + * %% + * Copyright (C) 2020 AT&T Intellectual Property + * %% + * 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=================================== + */ +package org.oransc.ric.portal.dashboard.config; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.oransc.ric.e2mgr.client.api.HealthCheckApi; +import org.oransc.ric.e2mgr.client.api.NodebApi; + +public class E2ManagerConfigTest extends AbstractConfigTest { + + @Test + public void builderTest() { + E2ManagerApiBuilder builder = new E2ManagerApiBuilder(instanceConfig, "suffix"); + HealthCheckApi healthApi = builder.getHealthCheckApi(RICInstanceMockConfiguration.INSTANCE_KEY_1); + Assertions.assertNotNull(healthApi); + NodebApi nodebApi = builder.getNodebApi(RICInstanceMockConfiguration.INSTANCE_KEY_1); + Assertions.assertNotNull(nodebApi); + } + +} diff --git a/webapp-backend/src/test/java/org/oransc/ric/portal/dashboard/model/ModelTest.java b/webapp-backend/src/test/java/org/oransc/ric/portal/dashboard/model/ModelTest.java index 71225aad..3208fd46 100644 --- a/webapp-backend/src/test/java/org/oransc/ric/portal/dashboard/model/ModelTest.java +++ b/webapp-backend/src/test/java/org/oransc/ric/portal/dashboard/model/ModelTest.java @@ -107,6 +107,9 @@ public class ModelTest extends AbstractModelTest { m = new RanDetailsTransport(nodebIdentity, nodebResponse); Assert.assertEquals(m.getNodebIdentity(), nodebIdentity); Assert.assertEquals(m.getNodebStatus(), nodebResponse); + m.nodebIdentity(nodebIdentity).nodebStatus(nodebResponse); + Assert.assertEquals(m.getNodebIdentity(), nodebIdentity); + Assert.assertEquals(m.getNodebStatus(), nodebResponse); } private void checkSuccessTransport(SuccessTransport m) { @@ -124,4 +127,41 @@ public class ModelTest extends AbstractModelTest { logger.info(m.toString()); } + private void checkRicInstanceKeyName(RicInstanceKeyName m) { + Assert.assertEquals(s1, m.getKey()); + Assert.assertEquals(s2, m.getName()); + } + + @Test + public void testRicInstanceKeyName() { + RicInstanceKeyName m = new RicInstanceKeyName(s1, s1); + m = new RicInstanceKeyName(); + m.setKey(s1); + m.setName(s2); + checkRicInstanceKeyName(m); + Assert.assertEquals(m, m); + Assert.assertNotEquals(1, m.hashCode()); + logger.info(m.toString()); + } + + private void checkRicInstance(RicInstance m) { + Assert.assertEquals(s1, m.getAppUrlPrefix()); + Assert.assertEquals(s2, m.getCaasUrlPrefix()); + Assert.assertEquals(s3, m.getKey()); + Assert.assertEquals(s4, m.getName()); + } + + @Test + public void testRicInstance() { + RicInstance m = new RicInstance(); + m.setAppUrlPrefix(s1); + m.setCaasUrlPrefix(s2); + m.setKey(s3); + m.setName(s4); + checkRicInstance(m); + Assert.assertEquals(m, m); + Assert.assertNotEquals(1, m.hashCode()); + logger.info(m.toString()); + } + } -- 2.16.6