summaryrefslogtreecommitdiffstats
path: root/mso-catalog-db/src/test
diff options
context:
space:
mode:
authorMcblain, Thomas <tom.mcblain@att.com>2019-06-06 15:59:20 -0400
committerBenjamin, Max (mb388a) <mb388a@us.att.com>2019-06-06 15:59:30 -0400
commit37b23b4d859eda7fab5af1366f9688d882b8427a (patch)
tree017c0445971aaf9662e4cea1f16d213e77c71698 /mso-catalog-db/src/test
parentc4b90365d5c117bc6fd64af421a1468539a8aec3 (diff)
Handle when model cust uuid is null from sdnc
Modify wording on null uuid exception and test for it Expand null handling to vfmc and cvnfc find in lists Modify to chain the filter of nulls then to match. Change to ExpectedException in junit; filter nulls. Handle better when model cust. uuid is null from sdnc Change-Id: I1f1edffa1db84509bd649803660a55510868b6eb Issue-ID: SO-1989 Signed-off-by: Benjamin, Max (mb388a) <mb388a@us.att.com>
Diffstat (limited to 'mso-catalog-db/src/test')
-rw-r--r--mso-catalog-db/src/test/java/org/onap/so/db/catalog/client/CatalogDbClientTest.java173
1 files changed, 173 insertions, 0 deletions
diff --git a/mso-catalog-db/src/test/java/org/onap/so/db/catalog/client/CatalogDbClientTest.java b/mso-catalog-db/src/test/java/org/onap/so/db/catalog/client/CatalogDbClientTest.java
new file mode 100644
index 0000000000..9c257bdec3
--- /dev/null
+++ b/mso-catalog-db/src/test/java/org/onap/so/db/catalog/client/CatalogDbClientTest.java
@@ -0,0 +1,173 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * 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.onap.so.db.catalog.client;
+
+import static org.junit.Assert.assertTrue;
+import java.util.ArrayList;
+import javax.persistence.EntityNotFoundException;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+import org.onap.so.db.catalog.beans.CvnfcCustomization;
+import org.onap.so.db.catalog.beans.VfModuleCustomization;
+import org.onap.so.db.catalog.beans.VnfResourceCustomization;
+
+public class CatalogDbClientTest {
+
+ private CatalogDbClient catalogDbClient;
+
+ @Before
+ public void init() {
+ catalogDbClient = new CatalogDbClient();
+ }
+
+ @Rule
+ public ExpectedException thrown = ExpectedException.none();
+
+ @Test
+ public final void testFindVnfResourceCustomizationInListNullInList() {
+ thrown.expect(EntityNotFoundException.class);
+ String vnfCustomizationUUID = "a123";
+ VnfResourceCustomization vrc = new VnfResourceCustomization();
+ vrc.setModelCustomizationUUID("z789J");
+ VnfResourceCustomization vrc2 = new VnfResourceCustomization();
+ vrc2.setModelCustomizationUUID(null);
+ ArrayList<VnfResourceCustomization> vrcs = new ArrayList<VnfResourceCustomization>();
+ vrcs.add(vrc);
+ vrcs.add(vrc2);
+ catalogDbClient.findVnfResourceCustomizationInList(vnfCustomizationUUID, vrcs);
+ }
+
+ @Test
+ public final void testFindVnfResourceCustomizationInListNullString() {
+ thrown.expect(EntityNotFoundException.class);
+ thrown.expectMessage("a NULL UUID was provided in query to search for VnfResourceCustomization");
+ String vnfCustomizationUUID = null;
+ VnfResourceCustomization vrc = new VnfResourceCustomization();
+ vrc.setModelCustomizationUUID("z789J");
+ VnfResourceCustomization vrc2 = new VnfResourceCustomization();
+ vrc2.setModelCustomizationUUID("a123");
+ ArrayList<VnfResourceCustomization> vrcs = new ArrayList<VnfResourceCustomization>();
+ vrcs.add(vrc);
+ vrcs.add(vrc2);
+ catalogDbClient.findVnfResourceCustomizationInList(vnfCustomizationUUID, vrcs);
+ }
+
+ @Test
+ public final void testFindVnfResourceCustomizationInListNoNulls() {
+ String vnfCustomizationUUID = "a123";
+ VnfResourceCustomization vrc = new VnfResourceCustomization();
+ vrc.setModelCustomizationUUID("z789J");
+ VnfResourceCustomization vrc2 = new VnfResourceCustomization();
+ vrc2.setModelCustomizationUUID("a123");
+ ArrayList<VnfResourceCustomization> vrcs = new ArrayList<VnfResourceCustomization>();
+ vrcs.add(vrc);
+ vrcs.add(vrc2);
+ VnfResourceCustomization aVrc = catalogDbClient.findVnfResourceCustomizationInList(vnfCustomizationUUID, vrcs);
+ assertTrue(aVrc.getModelCustomizationUUID().equals("a123"));
+ }
+
+ @Test
+ public final void testFindVfModuleCustomizationInListNullInList() {
+ thrown.expect(EntityNotFoundException.class);
+ String vfModuleCustomizationUUID = "a123";
+ VfModuleCustomization vmc = new VfModuleCustomization();
+ vmc.setModelCustomizationUUID("z789J");
+ VfModuleCustomization vmc2 = new VfModuleCustomization();
+ vmc2.setModelCustomizationUUID(null);
+ ArrayList<VfModuleCustomization> vmcs = new ArrayList<VfModuleCustomization>();
+ vmcs.add(vmc);
+ vmcs.add(vmc2);
+ catalogDbClient.findVfModuleCustomizationInList(vfModuleCustomizationUUID, vmcs);
+ }
+
+ @Test
+ public final void testFindVfModuleCustomizationInListNullString() {
+ thrown.expect(EntityNotFoundException.class);
+ thrown.expectMessage("a NULL UUID was provided in query to search for VfModuleCustomization");
+ String vfModuleCustomizationUUID = null;
+ VfModuleCustomization vmc = new VfModuleCustomization();
+ vmc.setModelCustomizationUUID("z789J");
+ VfModuleCustomization vmc2 = new VfModuleCustomization();
+ vmc2.setModelCustomizationUUID("a123");
+ ArrayList<VfModuleCustomization> vmcs = new ArrayList<VfModuleCustomization>();
+ vmcs.add(vmc);
+ vmcs.add(vmc2);
+ catalogDbClient.findVfModuleCustomizationInList(vfModuleCustomizationUUID, vmcs);
+ }
+
+ @Test
+ public final void testFindVfModuleCustomizationInListNoNulls() {
+ String vfModuleCustomizationUUID = "a123";
+ VfModuleCustomization vmc = new VfModuleCustomization();
+ vmc.setModelCustomizationUUID("z789J");
+ VfModuleCustomization vmc2 = new VfModuleCustomization();
+ vmc2.setModelCustomizationUUID("a123");
+ ArrayList<VfModuleCustomization> vmcs = new ArrayList<VfModuleCustomization>();
+ vmcs.add(vmc);
+ vmcs.add(vmc2);
+ VfModuleCustomization aVmc = catalogDbClient.findVfModuleCustomizationInList(vfModuleCustomizationUUID, vmcs);
+ assertTrue(aVmc.getModelCustomizationUUID().equals("a123"));
+ }
+
+ @Test
+ public final void testFindCvnfcCustomizationInListNullInList() {
+ thrown.expect(EntityNotFoundException.class);
+ String cvnfcCustomizationUuid = "a123";
+ CvnfcCustomization cvnfc = new CvnfcCustomization();
+ cvnfc.setModelCustomizationUUID("z789J");
+ CvnfcCustomization cvnfc2 = new CvnfcCustomization();
+ cvnfc2.setModelCustomizationUUID(null);
+ ArrayList<CvnfcCustomization> cvnfcs = new ArrayList<CvnfcCustomization>();
+ cvnfcs.add(cvnfc);
+ cvnfcs.add(cvnfc2);
+ catalogDbClient.findCvnfcCustomizationInAList(cvnfcCustomizationUuid, cvnfcs);
+ }
+
+ @Test
+ public final void testFindCvnfcCustomizationInListNullString() {
+ thrown.expect(EntityNotFoundException.class);
+ thrown.expectMessage("a NULL UUID was provided in query to search for CvnfcCustomization");
+ String cvnfcCustomizationUuid = null;
+ CvnfcCustomization cvnfc = new CvnfcCustomization();
+ cvnfc.setModelCustomizationUUID("z789J");
+ CvnfcCustomization cvnfc2 = new CvnfcCustomization();
+ cvnfc2.setModelCustomizationUUID("a123");
+ ArrayList<CvnfcCustomization> cvnfcs = new ArrayList<CvnfcCustomization>();
+ cvnfcs.add(cvnfc);
+ cvnfcs.add(cvnfc2);
+ catalogDbClient.findCvnfcCustomizationInAList(cvnfcCustomizationUuid, cvnfcs);
+ }
+
+ @Test
+ public final void testFindCvnfcCustomizationInListNoNulls() {
+ String cvnfcCustomizationUuid = "a123";
+ CvnfcCustomization cvnfc = new CvnfcCustomization();
+ cvnfc.setModelCustomizationUUID("z789J");
+ CvnfcCustomization cvnfc2 = new CvnfcCustomization();
+ cvnfc2.setModelCustomizationUUID("a123");
+ ArrayList<CvnfcCustomization> cvnfcs = new ArrayList<CvnfcCustomization>();
+ cvnfcs.add(cvnfc);
+ cvnfcs.add(cvnfc2);
+ CvnfcCustomization aCvnfc = catalogDbClient.findCvnfcCustomizationInAList(cvnfcCustomizationUuid, cvnfcs);
+ assertTrue(aCvnfc.getModelCustomizationUUID().equals("a123"));
+ }
+}