diff options
9 files changed, 347 insertions, 0 deletions
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/pom.xml b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/pom.xml index 1dbb1d7e8e..4d705f8c66 100644 --- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/pom.xml +++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/pom.xml @@ -179,6 +179,12 @@ <scope>test</scope> </dependency> <dependency> + <groupId>com.google.code.bean-matchers</groupId> + <artifactId>bean-matchers</artifactId> + <version>${bean-matchers.version}</version> + <scope>test</scope> + </dependency> + <dependency> <groupId>org.openecomp.sdc</groupId> <artifactId>openecomp-sdc-activity-log-api</artifactId> <version>${project.version}</version> 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<CompositionEntityValidationData> 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<CompositionEntityValidationData> 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<CompositionEntityValidationData> 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 |