From d761b7ce6d662e2d23410ef7f2dec3350eac05b5 Mon Sep 17 00:00:00 2001 From: "m.kowalski3" Date: Mon, 24 Jun 2019 14:53:49 +0200 Subject: [PATCH] Add unit tests for: -ComponentErrorBuilder -ComputeErrorBuilder -CreatePackageForNonFinalVendorSoftwareProductErrorBuilder Issue-ID: SDC-2327 Signed-off-by: Marcin Kowalski Change-Id: I465619c8e4b9819c4706a38633a9e1d6bf5551ab --- .../errors/ComponentErrorBuilderTest.java | 43 +++++++++++++++++++ .../errors/ComputeErrorBuilderTest.java | 42 +++++++++++++++++++ ...FinalVendorSoftwareProductErrorBuilderTest.java | 49 ++++++++++++++++++++++ 3 files changed, 134 insertions(+) create mode 100644 openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/errors/ComponentErrorBuilderTest.java create mode 100644 openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/errors/ComputeErrorBuilderTest.java create mode 100644 openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/errors/CreatePackageForNonFinalVendorSoftwareProductErrorBuilderTest.java 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 index 0000000000..daf7a3d0fd --- /dev/null +++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/errors/ComponentErrorBuilderTest.java @@ -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 index 0000000000..08c1c8c930 --- /dev/null +++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/errors/ComputeErrorBuilderTest.java @@ -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 index 0000000000..7fbf1ee7da --- /dev/null +++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/errors/CreatePackageForNonFinalVendorSoftwareProductErrorBuilderTest.java @@ -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()); + } +} -- 2.16.6