Improve unit-test coverage 04/2204/2
authorLott, Christopher (cl778h) <cl778h@att.com>
Mon, 13 Jan 2020 21:08:06 +0000 (16:08 -0500)
committerLott, Christopher (cl778h) <cl778h@att.com>
Mon, 13 Jan 2020 21:10:32 +0000 (16:10 -0500)
Add tests of the API builder classes and methods.

Change-Id: I9c4ea2fa63ef83beed81f807fe3eb1c790708595
Signed-off-by: Lott, Christopher (cl778h) <cl778h@att.com>
webapp-backend/src/test/java/org/oransc/ric/portal/dashboard/config/A1MediatorConfigTest.java [new file with mode: 0644]
webapp-backend/src/test/java/org/oransc/ric/portal/dashboard/config/AbstractConfigTest.java [new file with mode: 0644]
webapp-backend/src/test/java/org/oransc/ric/portal/dashboard/config/AppManagerConfigTest.java [new file with mode: 0644]
webapp-backend/src/test/java/org/oransc/ric/portal/dashboard/config/CaasIngressConfigTest.java [new file with mode: 0644]
webapp-backend/src/test/java/org/oransc/ric/portal/dashboard/config/E2ManagerConfigTest.java [new file with mode: 0644]
webapp-backend/src/test/java/org/oransc/ric/portal/dashboard/model/ModelTest.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 (file)
index 0000000..747b412
--- /dev/null
@@ -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 (file)
index 0000000..4e8a11e
--- /dev/null
@@ -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 (file)
index 0000000..8811ccb
--- /dev/null
@@ -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 (file)
index 0000000..13da476
--- /dev/null
@@ -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 (file)
index 0000000..a1094e2
--- /dev/null
@@ -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);
+       }
+
+}
index 71225aa..3208fd4 100644 (file)
@@ -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());
+       }
+
 }