Add unit tests for: 15/90715/2
authorm.kowalski3 <m.kowalski3@partner.samsung.com>
Mon, 1 Jul 2019 10:46:31 +0000 (12:46 +0200)
committerOren Kleks <orenkle@amdocs.com>
Thu, 4 Jul 2019 10:43:48 +0000 (10:43 +0000)
-MonitoringUploadErrorBuilder
-NicErrorBuilder
-VendorSoftwareProductInvalidErrorBuilder

Issue-ID: SDC-2327
Signed-off-by: Marcin Kowalski <m.kowalski3@partner.samsung.com>
Change-Id: I4e34f6f511e27a5f33e96f5bc482cca7765a66e8

openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/errors/MonitoringUploadErrorBuilderTest.java [new file with mode: 0644]
openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/errors/NicErrorBuilderTest.java [new file with mode: 0644]
openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/errors/VendorSoftwareProductInvalidErrorBuilderTest.java [new file with mode: 0644]

diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/errors/MonitoringUploadErrorBuilderTest.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/errors/MonitoringUploadErrorBuilderTest.java
new file mode 100644 (file)
index 0000000..ba726d6
--- /dev/null
@@ -0,0 +1,46 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2019 Samsung. 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.openecomp.sdc.vendorsoftwareproduct.errors;
+
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Test;
+import org.openecomp.sdc.common.errors.ErrorCategory;
+import org.openecomp.sdc.common.errors.ErrorCode;
+
+public class MonitoringUploadErrorBuilderTest {
+
+    @Test
+    public void testMonitoringUploadErrorBuilder() {
+        //when
+        MonitoringUploadErrorBuilder monitoringUploadErrorBuilder =
+                new MonitoringUploadErrorBuilder("1", null, "error");
+        ErrorCode errorCode = monitoringUploadErrorBuilder.build();
+
+        //then
+        assertEquals(VendorSoftwareProductErrorCodes.MONITORING_UPLOAD_INVALID, errorCode.id());
+        assertEquals(ErrorCategory.APPLICATION, errorCode.category());
+        assertEquals(
+                "Monitoring file uploaded for vendor software product with Id 1 and version null is invalid: error",
+                errorCode.message());
+    }
+
+}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/errors/NicErrorBuilderTest.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/errors/NicErrorBuilderTest.java
new file mode 100644 (file)
index 0000000..a73070a
--- /dev/null
@@ -0,0 +1,41 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2019 Samsung. 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.openecomp.sdc.vendorsoftwareproduct.errors;
+
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Test;
+import org.openecomp.sdc.common.errors.ErrorCategory;
+import org.openecomp.sdc.common.errors.ErrorCode;
+
+public class NicErrorBuilderTest {
+
+    @Test
+    public void testGetNicNameFormatErrorBuilder() {
+        //when
+        ErrorCode errorCode = NicErrorBuilder.getNicNameFormatErrorBuilder("1");
+
+        //then
+        assertEquals(VendorSoftwareProductErrorCodes.NIC_NAME_FORMAT_NOT_ALLOWED, errorCode.id());
+        assertEquals(ErrorCategory.APPLICATION, errorCode.category());
+        assertEquals("Field does not conform to predefined criteria: name : must match 1", errorCode.message());
+    }
+}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/errors/VendorSoftwareProductInvalidErrorBuilderTest.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/errors/VendorSoftwareProductInvalidErrorBuilderTest.java
new file mode 100644 (file)
index 0000000..a54304d
--- /dev/null
@@ -0,0 +1,58 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2019 Samsung. 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.openecomp.sdc.vendorsoftwareproduct.errors;
+
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Test;
+import org.openecomp.sdc.common.errors.ErrorCategory;
+import org.openecomp.sdc.common.errors.ErrorCode;
+import org.openecomp.sdc.versioning.dao.types.Version;
+
+public class VendorSoftwareProductInvalidErrorBuilderTest {
+
+    @Test
+    public void testVendorSoftwareProductMissingServiceModelErrorBuilder() {
+        //when
+        ErrorCode errorCode = VendorSoftwareProductInvalidErrorBuilder
+                                      .vendorSoftwareProductMissingServiceModelErrorBuilder("1",
+                                              Version.valueOf("1.1"));
+
+        //then
+        assertEquals(VendorSoftwareProductErrorCodes.VSP_INVALID, errorCode.id());
+        assertEquals(ErrorCategory.APPLICATION, errorCode.category());
+        assertEquals("Vendor software product with Id 1 and version null is invalid - does not contain service model.",
+                errorCode.message());
+    }
+
+    @Test
+    public void testVspMissingDeploymentFlavorErrorBuilder() {
+        //when
+        ErrorCode errorCode = VendorSoftwareProductInvalidErrorBuilder.vspMissingDeploymentFlavorErrorBuilder();
+
+        //then
+        assertEquals(VendorSoftwareProductErrorCodes.VSP_INVALID, errorCode.id());
+        assertEquals(ErrorCategory.APPLICATION, errorCode.category());
+        assertEquals(
+                "VSP has to have a minimum of one Deployment Flavor defined for being able to be instantiated.Please add a "
+                        + "Deployment Flavor and re-submit the VSP.", errorCode.message());
+    }
+}