From 4d8b50e2a87095d737db72f454f7520ff97f4ec5 Mon Sep 17 00:00:00 2001 From: Tomasz Golabek Date: Tue, 20 Aug 2019 11:39:23 +0200 Subject: Unit tests - openecomp-sdc-vsp-manager Tests for org.openecomp.sdc.vendorsoftwareproduct Change-Id: I737b8ca71219c3e241f902a34419c685435e467c Issue-ID: SDC-2326 Signed-off-by: Tomasz Golabek --- .../ComponentManagerFactoryTest.java | 32 +++++++++++++ .../types/ComponentValidationResultTest.java | 45 ++++++++++++++++++ .../DeploymentFlavorValidationResultTest.java | 45 ++++++++++++++++++ .../types/LicensingDataTest.java | 32 +++++++++++++ .../OrchestrationTemplateActionResponseTest.java | 54 ++++++++++++++++++++++ .../types/QuestionnaireValidationResultTest.java | 45 ++++++++++++++++++ .../types/UploadFileStructureTest.java | 45 ++++++++++++++++++ .../utils/ComponentDependencyTrackerTest.java | 43 +++++++++++++++++ 8 files changed, 341 insertions(+) create mode 100644 openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/ComponentManagerFactoryTest.java create mode 100644 openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/types/ComponentValidationResultTest.java create mode 100644 openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/types/DeploymentFlavorValidationResultTest.java create mode 100644 openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/types/LicensingDataTest.java create mode 100644 openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/types/OrchestrationTemplateActionResponseTest.java create mode 100644 openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/types/QuestionnaireValidationResultTest.java create mode 100644 openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/types/UploadFileStructureTest.java create mode 100644 openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/utils/ComponentDependencyTrackerTest.java (limited to 'openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src') diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/ComponentManagerFactoryTest.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/ComponentManagerFactoryTest.java new file mode 100644 index 0000000000..7d59215847 --- /dev/null +++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/ComponentManagerFactoryTest.java @@ -0,0 +1,32 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2019 Nokia. 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; + +import static org.junit.Assert.assertNotNull; + +import org.junit.Test; + +public class ComponentManagerFactoryTest { + + @Test + public void instanceShouldNotBeNull() { + assertNotNull(ComponentManagerFactory.getInstance()); + } +} \ No newline at end of file diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/types/ComponentValidationResultTest.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/types/ComponentValidationResultTest.java new file mode 100644 index 0000000000..543f05cded --- /dev/null +++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/types/ComponentValidationResultTest.java @@ -0,0 +1,45 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2019 Nokia. 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.types; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import java.util.Collections; +import java.util.Set; +import org.junit.Test; +import org.openecomp.sdc.vendorsoftwareproduct.types.composition.CompositionEntityValidationData; + +public class ComponentValidationResultTest { + @Test + public void componentShouldBeNotValidWhenNotNull() { + Set validationData = Collections.emptySet(); + ComponentValidationResult componentValidationResult = new ComponentValidationResult(validationData); + assertEquals(componentValidationResult.getValidationData(), validationData); + assertFalse(componentValidationResult.isValid()); + } + + @Test + public void componentShouldBeValidWhenNull() { + ComponentValidationResult componentValidationResult = new ComponentValidationResult(null); + assertTrue(componentValidationResult.isValid()); + } +} \ No newline at end of file diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/types/DeploymentFlavorValidationResultTest.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/types/DeploymentFlavorValidationResultTest.java new file mode 100644 index 0000000000..e01e06234d --- /dev/null +++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/types/DeploymentFlavorValidationResultTest.java @@ -0,0 +1,45 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2019 Nokia. 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.types; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import java.util.Collections; +import java.util.Set; +import org.junit.Test; +import org.openecomp.sdc.vendorsoftwareproduct.types.composition.CompositionEntityValidationData; + +public class DeploymentFlavorValidationResultTest { + @Test + public void flavorShouldBeNotValidWhenNotNull() { + Set validationData = Collections.emptySet(); + DeploymentFlavorValidationResult componentValidationResult = new DeploymentFlavorValidationResult(validationData); + assertEquals(componentValidationResult.getValidationData(), validationData); + assertFalse(componentValidationResult.isValid()); + } + + @Test + public void flavorShouldBeValidWhenNull() { + DeploymentFlavorValidationResult componentValidationResult = new DeploymentFlavorValidationResult(null); + assertTrue(componentValidationResult.isValid()); + } +} \ No newline at end of file diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/types/LicensingDataTest.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/types/LicensingDataTest.java new file mode 100644 index 0000000000..2061eadad3 --- /dev/null +++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/types/LicensingDataTest.java @@ -0,0 +1,32 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2019 Nokia. 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.types; + +import static com.google.code.beanmatchers.BeanMatchers.hasValidGettersAndSetters; +import static org.junit.Assert.assertThat; + +import org.junit.Test; + +public class LicensingDataTest { + @Test + public void shouldHaveValidGettersAndSetters() { + assertThat(LicensingData.class, hasValidGettersAndSetters()); + } +} \ No newline at end of file diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/types/OrchestrationTemplateActionResponseTest.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/types/OrchestrationTemplateActionResponseTest.java new file mode 100644 index 0000000000..21db918d73 --- /dev/null +++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/types/OrchestrationTemplateActionResponseTest.java @@ -0,0 +1,54 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2019 Nokia. 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.types; + +import static com.google.code.beanmatchers.BeanMatchers.hasValidGettersAndSettersExcluding; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertThat; + +import org.junit.Test; +import org.openecomp.sdc.datatypes.error.ErrorLevel; + +public class OrchestrationTemplateActionResponseTest { + + private static final String ERROR = "error"; + private static final String TEST = "test"; + + @Test + public void shouldHaveValidGettersAndSetters() { + assertThat(OrchestrationTemplateActionResponse.class, hasValidGettersAndSettersExcluding("errors")); + } + + @Test + public void shouldAddErrorToMap() { + OrchestrationTemplateActionResponse orchestrationTemplateActionResponse = new OrchestrationTemplateActionResponse(); + orchestrationTemplateActionResponse.addErrorMessageToMap(TEST, ERROR, ErrorLevel.ERROR); + assertEquals(orchestrationTemplateActionResponse.getStatus(), UploadFileStatus.Failure); + assertEquals(orchestrationTemplateActionResponse.getErrors().get(TEST).get(0).getMessage(), ERROR); + } + + @Test + public void shouldAddErrorToMapButLeaveAStatusUnchanged() { + OrchestrationTemplateActionResponse orchestrationTemplateActionResponse = new OrchestrationTemplateActionResponse(); + orchestrationTemplateActionResponse.addErrorMessageToMap(TEST, ERROR, ErrorLevel.INFO); + assertEquals(orchestrationTemplateActionResponse.getStatus(), UploadFileStatus.Success); + assertEquals(orchestrationTemplateActionResponse.getErrors().get(TEST).get(0).getMessage(), ERROR); + } +} \ No newline at end of file diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/types/QuestionnaireValidationResultTest.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/types/QuestionnaireValidationResultTest.java new file mode 100644 index 0000000000..bc0ed11448 --- /dev/null +++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/types/QuestionnaireValidationResultTest.java @@ -0,0 +1,45 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2019 Nokia. 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.types; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import java.util.Collections; +import java.util.Set; +import org.junit.Test; +import org.openecomp.sdc.vendorsoftwareproduct.types.composition.CompositionEntityValidationData; + +public class QuestionnaireValidationResultTest { + @Test + public void questionnaireShouldBeNotValidWhenNotNull() { + Set validationData = Collections.emptySet(); + QuestionnaireValidationResult questionnaireValidationResult = new QuestionnaireValidationResult(validationData); + assertEquals(questionnaireValidationResult.getValidationData(), validationData); + assertFalse(questionnaireValidationResult.isValid()); + } + + @Test + public void questionnaireShouldBeValidWhenNull() { + QuestionnaireValidationResult questionnaireValidationResult = new QuestionnaireValidationResult(null); + assertTrue(questionnaireValidationResult.isValid()); + } +} \ No newline at end of file diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/types/UploadFileStructureTest.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/types/UploadFileStructureTest.java new file mode 100644 index 0000000000..6cd0b449ff --- /dev/null +++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/types/UploadFileStructureTest.java @@ -0,0 +1,45 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2019 Nokia. 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.types; + +import static com.google.code.beanmatchers.BeanMatchers.hasValidGettersAndSetters; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertThat; + +import java.util.ArrayList; +import org.junit.Test; + +public class UploadFileStructureTest { + + private static final String TEST = "test"; + + @Test + public void shouldHaveValidGettersAndSetters() { + assertThat(UploadFileStructure.class, hasValidGettersAndSetters()); + } + + @Test + public void shouldAddFileToList() { + UploadFileStructure uploadFileStructure = new UploadFileStructure(); + uploadFileStructure.setFileNames(new ArrayList<>()); + uploadFileStructure.addNewFileToList(TEST); + assertEquals(uploadFileStructure.getFileNames().get(0), TEST); + } +} \ No newline at end of file diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/utils/ComponentDependencyTrackerTest.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/utils/ComponentDependencyTrackerTest.java new file mode 100644 index 0000000000..ec13a4d2c3 --- /dev/null +++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/utils/ComponentDependencyTrackerTest.java @@ -0,0 +1,43 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2019 Nokia. 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.utils; + +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import org.junit.Test; + +public class ComponentDependencyTrackerTest { + + @Test + public void shouldAddNonCyclicDependency() { + ComponentDependencyTracker componentDependencyTracker = new ComponentDependencyTracker(); + componentDependencyTracker.addDependency("TEST1", "TEST2"); + assertFalse(componentDependencyTracker.isCyclicDependencyPresent()); + } + + @Test + public void shouldAddCyclicDependency() { + ComponentDependencyTracker componentDependencyTracker = new ComponentDependencyTracker(); + componentDependencyTracker.addDependency("TEST1", "TEST2"); + componentDependencyTracker.addDependency("TEST2", "TEST1"); + assertTrue(componentDependencyTracker.isCyclicDependencyPresent()); + } +} \ No newline at end of file -- cgit 1.2.3-korg