From 97b2d7ee46e604c2e6ec5846b3f330a1adca4dcc Mon Sep 17 00:00:00 2001 From: "m.kowalski3" Date: Mon, 1 Jul 2019 12:46:31 +0200 Subject: Add unit tests for: -MonitoringUploadErrorBuilder -NicErrorBuilder -VendorSoftwareProductInvalidErrorBuilder Issue-ID: SDC-2327 Signed-off-by: Marcin Kowalski Change-Id: I4e34f6f511e27a5f33e96f5bc482cca7765a66e8 --- .../errors/MonitoringUploadErrorBuilderTest.java | 46 +++++++++++++++++ .../errors/NicErrorBuilderTest.java | 41 +++++++++++++++ ...ndorSoftwareProductInvalidErrorBuilderTest.java | 58 ++++++++++++++++++++++ 3 files changed, 145 insertions(+) create mode 100644 openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/errors/MonitoringUploadErrorBuilderTest.java create mode 100644 openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/errors/NicErrorBuilderTest.java create mode 100644 openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/errors/VendorSoftwareProductInvalidErrorBuilderTest.java (limited to 'openecomp-be/backend') 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 index 0000000000..ba726d64c4 --- /dev/null +++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/errors/MonitoringUploadErrorBuilderTest.java @@ -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 index 0000000000..a73070a12d --- /dev/null +++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/errors/NicErrorBuilderTest.java @@ -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 index 0000000000..a54304db8e --- /dev/null +++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/errors/VendorSoftwareProductInvalidErrorBuilderTest.java @@ -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()); + } +} -- cgit 1.2.3-korg