diff options
author | sheetalm <sheetal.mudholkar@amdocs.com> | 2018-06-12 17:32:56 +0530 |
---|---|---|
committer | Avi Gaffa <avi.gaffa@amdocs.com> | 2018-06-13 08:16:41 +0000 |
commit | 67e400cc929314f1d66accb2f2f47d489f6b0c4f (patch) | |
tree | 1f92e95dd1165944ec57de9e7318850a587cb1c4 /openecomp-be/backend | |
parent | d932a21e9f99ef5e706975a73c4f17a145445fe1 (diff) |
Fix for nfcparameters in component questionnaire
issue - nfc naming code and nfc function fields' values are wiped out
with a VSP update
Moved the above fields from composition to questionnaire
Add BDD test. Add license to java files
Change-Id: I2b746fedc17c19b716df35bf0dad2c212f15df30
Issue-ID: SDC-1419
Signed-off-by: sheetalm <sheetal.mudholkar@amdocs.com>
Diffstat (limited to 'openecomp-be/backend')
5 files changed, 28 insertions, 49 deletions
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/CompositionEntityDataManager.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/CompositionEntityDataManager.java index c4cb95808a..37af2b86e1 100644 --- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/CompositionEntityDataManager.java +++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/CompositionEntityDataManager.java @@ -1,21 +1,17 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ +/* + * Copyright © 2016-2018 European Support Limited + * * 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 + * 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; @@ -59,7 +55,7 @@ public interface CompositionEntityDataManager { Set<CompositionEntityValidationData> getAllErrorsByVsp(String vspId); - ComponentEntity createComponent(ComponentEntity component); + ComponentEntity createComponent(ComponentEntity component, boolean isManualVsp); NicEntity createNic(NicEntity nic); diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ComponentManagerImpl.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ComponentManagerImpl.java index 67867d52f6..ca8757dd11 100644 --- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ComponentManagerImpl.java +++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ComponentManagerImpl.java @@ -1,11 +1,11 @@ /* - * Copyright © 2016-2017 European Support Limited + * Copyright © 2016-2018 European Support Limited * * 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 + * 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, @@ -92,7 +92,7 @@ public class ComponentManagerImpl implements ComponentManager { } else { validateComponentManual(component); updateComponentName(component); - createdComponent = compositionEntityDataManager.createComponent(component); + createdComponent = compositionEntityDataManager.createComponent(component, true); } return createdComponent; } @@ -222,8 +222,8 @@ public class ComponentManagerImpl implements ComponentManager { .map(nic -> nic.getNicCompositionData().getName()).collect(Collectors.toList()); questionnaireResponse.setSchema(getComponentQuestionnaireSchema( new ComponentQuestionnaireSchemaInput(nicNames, questionnaireResponse.getData() == null - ? null - : JsonUtil.json2Object(questionnaireResponse.getData(), Map.class)))); + ? null : JsonUtil.json2Object(questionnaireResponse.getData(), Map.class), + null, false))); return questionnaireResponse; } diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/CompositionEntityDataManagerImpl.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/CompositionEntityDataManagerImpl.java index db6a63a2ba..1946db8b5d 100644 --- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/CompositionEntityDataManagerImpl.java +++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/CompositionEntityDataManagerImpl.java @@ -1,21 +1,17 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ +/* + * Copyright © 2016-2018 European Support Limited + * * 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 + * 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.impl; @@ -38,15 +34,7 @@ import org.openecomp.sdc.vendorsoftwareproduct.dao.ImageDao; import org.openecomp.sdc.vendorsoftwareproduct.dao.NetworkDao; import org.openecomp.sdc.vendorsoftwareproduct.dao.NicDao; import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductInfoDao; -import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentEntity; -import org.openecomp.sdc.vendorsoftwareproduct.dao.type.CompositionEntity; -import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComputeEntity; -import org.openecomp.sdc.vendorsoftwareproduct.dao.type.DeploymentFlavorEntity; -import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ImageEntity; -import org.openecomp.sdc.vendorsoftwareproduct.dao.type.NetworkEntity; -import org.openecomp.sdc.vendorsoftwareproduct.dao.type.NicEntity; -import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspDetails; -import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspQuestionnaireEntity; +import org.openecomp.sdc.vendorsoftwareproduct.dao.type.*; import org.openecomp.sdc.vendorsoftwareproduct.services.schemagenerator.SchemaGenerator; import org.openecomp.sdc.vendorsoftwareproduct.types.composition.Component; import org.openecomp.sdc.vendorsoftwareproduct.types.composition.ComponentData; @@ -59,6 +47,7 @@ import org.openecomp.sdc.vendorsoftwareproduct.types.composition.Image; import org.openecomp.sdc.vendorsoftwareproduct.types.composition.Network; import org.openecomp.sdc.vendorsoftwareproduct.types.composition.NetworkType; import org.openecomp.sdc.vendorsoftwareproduct.types.composition.Nic; +import org.openecomp.sdc.vendorsoftwareproduct.types.schemagenerator.ComponentQuestionnaireSchemaInput; import org.openecomp.sdc.vendorsoftwareproduct.types.schemagenerator.SchemaTemplateContext; import org.openecomp.sdc.vendorsoftwareproduct.types.schemagenerator.SchemaTemplateInput; import org.openecomp.sdc.versioning.dao.types.Version; @@ -268,7 +257,7 @@ public class CompositionEntityDataManagerImpl implements CompositionEntityDataMa ComponentEntity componentEntity = new ComponentEntity(vspId, version, null); componentEntity.setComponentCompositionData(component.getData()); - String componentId = createComponent(componentEntity).getId(); + String componentId = createComponent(componentEntity, false).getId(); saveImagesByComponent(vspId, version, component, componentId); saveComputesFlavorByComponent(vspId, version, component, componentId); @@ -321,13 +310,13 @@ public class CompositionEntityDataManagerImpl implements CompositionEntityDataMa } @Override - public ComponentEntity createComponent(ComponentEntity component) { + public ComponentEntity createComponent(ComponentEntity component, boolean isManualVsp) { //component.setId(CommonMethods.nextUuId()); will be set by the dao - component.setQuestionnaireData( - new JsonSchemaDataGenerator( - generateSchema(SchemaTemplateContext.questionnaire, CompositionEntityType.component, - null)) - .generateData()); + ComponentQuestionnaireSchemaInput schemaInput = new ComponentQuestionnaireSchemaInput(null, + null, component.getComponentCompositionData().getDisplayName(), isManualVsp); + String questionnarieData = new JsonSchemaDataGenerator(generateSchema(SchemaTemplateContext.questionnaire, + CompositionEntityType.component, schemaInput)).generateData(); + component.setQuestionnaireData(questionnarieData); componentDao.create(component); return component; diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/VendorSoftwareProductManagerImpl.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/VendorSoftwareProductManagerImpl.java index 5874394e96..e3c7d6ecdd 100644 --- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/VendorSoftwareProductManagerImpl.java +++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/VendorSoftwareProductManagerImpl.java @@ -5,7 +5,7 @@ * 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 + * 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, @@ -766,7 +766,8 @@ public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductMa componentDao.listCompositionAndQuestionnaire(vspId, version); components.forEach(component -> compositionEntityDataManager.addEntity(component, new ComponentQuestionnaireSchemaInput(nicNamesByComponent.get(component.getId()), - JsonUtil.json2Object(component.getQuestionnaireData(), Map.class)))); + JsonUtil.json2Object(component.getQuestionnaireData(), Map.class), null, + OnboardingMethod.Manual.name().equals(onboardingMethod)))); Collection<ComputeEntity> computes = computeDao.listByVsp(vspId, version); computes.forEach(compute -> compositionEntityDataManager.addEntity(compute, null)); diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ComponentManagerImplTest.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ComponentManagerImplTest.java index 3652223e61..243da26152 100644 --- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ComponentManagerImplTest.java +++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ComponentManagerImplTest.java @@ -1,9 +1,6 @@ package org.openecomp.sdc.vendorsoftwareproduct.impl; -import org.mockito.InjectMocks; -import org.mockito.Mock; -import org.mockito.MockitoAnnotations; -import org.mockito.Spy; +import org.mockito.*; import org.openecomp.sdc.common.errors.CoreException; import org.openecomp.sdc.vendorsoftwareproduct.NicManager; import org.openecomp.sdc.vendorsoftwareproduct.dao.ComponentDao; @@ -106,7 +103,7 @@ public class ComponentManagerImplTest { doReturn(true).when(vspInfoDao).isManual(anyObject(), anyObject()); Collection<ComponentEntity> vspComponentList = new ArrayList<>(); doReturn(vspComponentList).when(componentDaoMock).list(anyObject()); - doReturn(expected).when(compositionEntityDataManagerMock).createComponent(anyObject()); + doReturn(expected).when(compositionEntityDataManagerMock).createComponent(anyObject(), Matchers.anyBoolean()); ComponentEntity created = componentManager.createComponent(expected); Assert.assertNotNull(created); @@ -234,9 +231,6 @@ public class ComponentManagerImplTest { ComponentData compData = new ComponentData(); compData.setName(COMP1_ID + " name"); // no change compData.setDisplayName(COMP1_ID + " display name"); // no change - compData.setVfcCode(COMP1_ID + " display name"); // no change - compData.setNfcCode(COMP1_ID + " display name"); // no change - compData.setNfcFunction(COMP1_ID + " display name"); // no change compData.setDescription(COMP1_ID + " desc updated"); // allowed change component.setComponentCompositionData(compData); @@ -457,7 +451,6 @@ public class ComponentManagerImplTest { ComponentData compData = new ComponentData(); compData.setName(compId + " name"); compData.setDisplayName(compId + " display name"); - compData.setVfcCode(compId + " display name"); compData.setDescription(compId + " desc"); componentEntity.setComponentCompositionData(compData); componentEntity.setQuestionnaireData("{}"); |