diff options
author | m.kowalski3 <m.kowalski3@partner.samsung.com> | 2019-07-01 12:46:31 +0200 |
---|---|---|
committer | Oren Kleks <orenkle@amdocs.com> | 2019-07-04 10:43:48 +0000 |
commit | 97b2d7ee46e604c2e6ec5846b3f330a1adca4dcc (patch) | |
tree | e4c2e2842f4398bc869f633400e9d02322dc8a4b | |
parent | 9d1727691bd02cd423236b94d063f64a6f2493b8 (diff) |
Add unit tests for:
-MonitoringUploadErrorBuilder
-NicErrorBuilder
-VendorSoftwareProductInvalidErrorBuilder
Issue-ID: SDC-2327
Signed-off-by: Marcin Kowalski <m.kowalski3@partner.samsung.com>
Change-Id: I4e34f6f511e27a5f33e96f5bc482cca7765a66e8
3 files changed, 145 insertions, 0 deletions
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()); + } +} |