Add unit tests for: 77/90377/2
authorm.kowalski3 <m.kowalski3@partner.samsung.com>
Mon, 24 Jun 2019 12:53:49 +0000 (14:53 +0200)
committerOren Kleks <orenkle@amdocs.com>
Tue, 25 Jun 2019 12:19:01 +0000 (12:19 +0000)
-ComponentErrorBuilder
-ComputeErrorBuilder
-CreatePackageForNonFinalVendorSoftwareProductErrorBuilder

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

openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/errors/ComponentErrorBuilderTest.java [new file with mode: 0644]
openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/errors/ComputeErrorBuilderTest.java [new file with mode: 0644]
openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/errors/CreatePackageForNonFinalVendorSoftwareProductErrorBuilderTest.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/ComponentErrorBuilderTest.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/errors/ComponentErrorBuilderTest.java
new file mode 100644 (file)
index 0000000..daf7a3d
--- /dev/null
@@ -0,0 +1,43 @@
+/*-
+ * ============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 ComponentErrorBuilderTest {
+
+    @Test
+    public void testVfcMissingImageErrorBuilder() {
+        //when
+        ErrorCode errorCode = ComponentErrorBuilder.vfcMissingImageErrorBuilder();
+
+        //then
+        assertEquals(VendorSoftwareProductErrorCodes.VFC_INVALID, errorCode.id());
+        assertEquals(ErrorCategory.APPLICATION, errorCode.category());
+        assertEquals(
+                "All VFC need to have atleast a single Image specified. Please fix the VFC Images and re-submit the VSP",
+                errorCode.message());
+    }
+}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/errors/ComputeErrorBuilderTest.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/errors/ComputeErrorBuilderTest.java
new file mode 100644 (file)
index 0000000..08c1c8c
--- /dev/null
@@ -0,0 +1,42 @@
+/*-
+ * ============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 ComputeErrorBuilderTest {
+
+    @Test
+    public void testGetComputeNameFormatErrorBuilder() {
+        //when
+        ErrorCode errorCode = ComputeErrorBuilder.getComputeNameFormatErrorBuilder("");
+
+        //then
+        assertEquals(VendorSoftwareProductErrorCodes.COMPUTE_NAME_FORMAT_NOT_ALLOWED, errorCode.id());
+        assertEquals(ErrorCategory.APPLICATION, errorCode.category());
+        assertEquals("Field does not conform to predefined criteria: name : must match ", errorCode.message());
+
+    }
+}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/errors/CreatePackageForNonFinalVendorSoftwareProductErrorBuilderTest.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/errors/CreatePackageForNonFinalVendorSoftwareProductErrorBuilderTest.java
new file mode 100644 (file)
index 0000000..7fbf1ee
--- /dev/null
@@ -0,0 +1,49 @@
+/*-
+ * ============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 CreatePackageForNonFinalVendorSoftwareProductErrorBuilderTest {
+
+    @Test
+    public void testBuild() {
+        //given
+        CreatePackageForNonFinalVendorSoftwareProductErrorBuilder
+                createPackageForNonFinalVendorSoftwareProductErrorBuilder =
+                new CreatePackageForNonFinalVendorSoftwareProductErrorBuilder("1", Version.valueOf("1.1"));
+
+        //when
+        ErrorCode errorCode = createPackageForNonFinalVendorSoftwareProductErrorBuilder.build();
+
+        //then
+        assertEquals(VendorSoftwareProductErrorCodes.CREATE_PACKAGE_FOR_NON_FINAL_VSP, errorCode.id());
+        assertEquals(ErrorCategory.APPLICATION, errorCode.category());
+        assertEquals(
+                "Package creation for vendor software product with id 1 and version 1.1 is not allowed since it is not final (submitted).",
+                errorCode.message());
+    }
+}