From 1ec3dde2067e0181faa8e5098219c93126638aef Mon Sep 17 00:00:00 2001 From: vasraz Date: Mon, 6 Jul 2020 17:08:08 +0100 Subject: Support for defining attributes on a node_type This commit aims to add support of attributes on node_type. It is first of several commits to cover all support. It includes: - new classes: AttributeDefinition ComponentInstanceAttribute IAttributeInputCommon IAttributeInputCommon AttributeDataDefinition MapAttributesDataDefinition - support of 'Import of VFC with attributes' - TCs fix for changed code Next commit(s) will cover: - support of "Onboarding packages with attributes" - support of "Download TOSCA Artifacts - Tosca Model" - support of "Import onboarded VSP" Change-Id: I0167abc58e8aeef3d631833cc323e466f8e71492 Signed-off-by: Vasyl Razinkov Issue-ID: SDC-3200 --- .../impl/AttributeBusinessLogicTest.java | 165 ++++++++++----------- .../impl/ComponentInstanceBusinessLogicTest.java | 34 +++-- .../sdc/be/components/impl/ImportUtilsTest.java | 18 ++- 3 files changed, 109 insertions(+), 108 deletions(-) (limited to 'catalog-be/src/test/java/org') diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/AttributeBusinessLogicTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/AttributeBusinessLogicTest.java index 57af76a103..db4c699d04 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/AttributeBusinessLogicTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/AttributeBusinessLogicTest.java @@ -31,9 +31,10 @@ import org.openecomp.sdc.be.dao.janusgraph.JanusGraphOperationStatus; import org.openecomp.sdc.be.dao.jsongraph.JanusGraphDao; import org.openecomp.sdc.be.impl.ComponentsUtils; import org.openecomp.sdc.be.model.Component; -import org.openecomp.sdc.be.model.DataTypeDefinition; import org.openecomp.sdc.be.model.LifecycleStateEnum; import org.openecomp.sdc.be.model.PropertyDefinition; +import org.openecomp.sdc.be.datatypes.elements.AttributeDataDefinition; +import org.openecomp.sdc.be.model.AttributeDefinition; import org.openecomp.sdc.be.model.Resource; import org.openecomp.sdc.be.model.cache.ApplicationDataTypeCache; import org.openecomp.sdc.be.model.jsonjanusgraph.operations.ToscaOperationFacade; @@ -53,6 +54,7 @@ import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyObject; import static org.mockito.Mockito.when; +import org.openecomp.sdc.be.model.DataTypeDefinition; public class AttributeBusinessLogicTest extends BaseBusinessLogicMock{ @@ -74,7 +76,6 @@ public class AttributeBusinessLogicTest extends BaseBusinessLogicMock{ AttributeBusinessLogic attributeBusinessLogic=createTestSubject(); IGraphLockOperation igraphLockOperation = Mockito.mock(IGraphLockOperation.class); - @Before public void setup() throws Exception{ @@ -107,23 +108,21 @@ public class AttributeBusinessLogicTest extends BaseBusinessLogicMock{ baseBusinessLogic.set(attributeBusinessLogic, propertyOperation); } - @Test public void testCreateAttribute() throws Exception { AttributeBusinessLogic testSubject; String resourceId = ""; PropertyDefinition newAttributeDef = null; String userId = ""; - Either result; + Either result; // default test testSubject = createTestSubject(); } - @Test public void testIsAttributeExist() throws Exception { - AttributeBusinessLogic testSubject;List attributes = null; + AttributeBusinessLogic testSubject;List attributes = null; String resourceUid = ""; String propertyName = ""; boolean result; @@ -132,7 +131,6 @@ public class AttributeBusinessLogicTest extends BaseBusinessLogicMock{ testSubject=createTestSubject();attributes = null; } - @Test public void testGetAttribute() throws Exception { AttributeBusinessLogic testSubject; @@ -145,7 +143,6 @@ public class AttributeBusinessLogicTest extends BaseBusinessLogicMock{ testSubject = createTestSubject(); } - @Test public void testUpdateAttribute() throws Exception { AttributeBusinessLogic testSubject; @@ -159,7 +156,6 @@ public class AttributeBusinessLogicTest extends BaseBusinessLogicMock{ testSubject = createTestSubject(); } - @Test public void testDeleteAttribute() throws Exception { AttributeBusinessLogic testSubject; @@ -172,11 +168,10 @@ public class AttributeBusinessLogicTest extends BaseBusinessLogicMock{ testSubject = createTestSubject(); } - @Test public void createAttribute_lockfail() throws Exception { - Either response; - PropertyDefinition prop= new PropertyDefinition(); + Either response; + AttributeDataDefinition prop= new AttributeDataDefinition(); response = attributeBusinessLogic.createAttribute("RES01", prop, "USR01"); @@ -187,36 +182,36 @@ public class AttributeBusinessLogicTest extends BaseBusinessLogicMock{ @Test public void createAttribute_Success() throws Exception { - Component resource= new Resource(); + Component resource = new Resource(); resource.setLifecycleState(LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT); resource.setIsDeleted(false); resource.setLastUpdaterUserId("USR01"); - PropertyDefinition prop= new PropertyDefinition(); - prop.setType(ToscaPropertyType.STRING.getType()); + AttributeDefinition attrib = new AttributeDefinition(); + attrib.setType(ToscaPropertyType.STRING.getType()); - when(igraphLockOperation.lockComponent(any(),any())).thenReturn(StorageOperationStatus.OK); + when(igraphLockOperation.lockComponent(any(), any())).thenReturn(StorageOperationStatus.OK); //Either toscastatus=Either.right(StorageOperationStatus.INVALID_PROPERTY); - Either toscastatus=Either.left(resource); + Either toscastatus = Either.left(resource); when(toscaOperationFacade.getToscaElement("RES01")).thenReturn(toscastatus); - PropertyDefinition propertyDefinition = new PropertyDefinition(); - Either either = Either.left(propertyDefinition); - when(toscaOperationFacade.addAttributeOfResource(anyObject(),anyObject())).thenReturn(either); + AttributeDataDefinition attributeDataDefinition = new AttributeDataDefinition(); + Either either = Either.left(attributeDataDefinition); + when(toscaOperationFacade.addAttributeOfResource(anyObject(), anyObject())).thenReturn(either); when(propertyOperation.isPropertyTypeValid(anyObject())).thenReturn(true); - Map data=new HashMap<>(); - data.put("ONE",new DataTypeDefinition()); + Map data = new HashMap<>(); + data.put("ONE", new DataTypeDefinition()); Either, JanusGraphOperationStatus> allDataTypes = Either.left(data); when(applicationDataTypeCache.getAll()).thenReturn(allDataTypes); - when(propertyOperation.isPropertyDefaultValueValid(anyObject(),anyObject())).thenReturn(true); - Either response; + when(propertyOperation.isPropertyDefaultValueValid(anyObject(), anyObject())).thenReturn(true); + Either response; - response = attributeBusinessLogic.createAttribute("RES01", prop, "USR01"); + response = attributeBusinessLogic.createAttribute("RES01", attrib, "USR01"); - Assert.assertEquals(true,response.isLeft()); + Assert.assertEquals(true, response.isLeft()); } @@ -230,8 +225,8 @@ public class AttributeBusinessLogicTest extends BaseBusinessLogicMock{ when(igraphLockOperation.lockComponent(any(),any())).thenReturn(StorageOperationStatus.OK); - Either response; - PropertyDefinition prop= new PropertyDefinition(); + Either response; + AttributeDataDefinition prop= new AttributeDataDefinition(); baseBusinessLogic = attributeBusinessLogic.getClass().getSuperclass().getDeclaredField("toscaOperationFacade"); baseBusinessLogic.setAccessible(true); @@ -256,8 +251,8 @@ public class AttributeBusinessLogicTest extends BaseBusinessLogicMock{ when(igraphLockOperation.lockComponent(any(),any())).thenReturn(StorageOperationStatus.OK); - Either response; - PropertyDefinition prop= new PropertyDefinition(); + Either response; + AttributeDataDefinition prop= new AttributeDataDefinition(); //Either toscastatus=Either.right(StorageOperationStatus.INVALID_PROPERTY); Either toscastatus=Either.left(resource); @@ -272,73 +267,71 @@ public class AttributeBusinessLogicTest extends BaseBusinessLogicMock{ @Test public void createAttribute_componentalreadyexist_fails() throws Exception { - Either response; - PropertyDefinition prop= new PropertyDefinition(); - prop.setName("RES01"); - prop.setParentUniqueId("RES01"); + Either response; + AttributeDefinition attrib = new AttributeDefinition(); + attrib.setName("RES01"); + attrib.setParentUniqueId("RES01"); - List attributes = new ArrayList<>(); - attributes.add(prop); + List attributes = new ArrayList<>(); + attributes.add(attrib); - Component resource= new Resource(); + Component resource = new Resource(); resource.setLifecycleState(LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT); resource.setIsDeleted(false); resource.setLastUpdaterUserId("USR01"); ((Resource) resource).setAttributes(attributes); - when(igraphLockOperation.lockComponent(any(),any())).thenReturn(StorageOperationStatus.OK); + when(igraphLockOperation.lockComponent(any(), any())).thenReturn(StorageOperationStatus.OK); //Either toscastatus=Either.right(StorageOperationStatus.INVALID_PROPERTY); - Either toscastatus=Either.left(resource); + Either toscastatus = Either.left(resource); when(toscaOperationFacade.getToscaElement("RES01")).thenReturn(toscastatus); - response = attributeBusinessLogic.createAttribute("RES01", prop, "USR01"); + response = attributeBusinessLogic.createAttribute("RES01", attrib, "USR01"); - Assert.assertEquals(true,response.isRight()); + Assert.assertEquals(true, response.isRight()); } - @Test public void createAttribute_addresourcetostoragefails() throws Exception { - Component resource= new Resource(); + Component resource = new Resource(); resource.setLifecycleState(LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT); resource.setIsDeleted(false); resource.setLastUpdaterUserId("USR01"); - PropertyDefinition prop= new PropertyDefinition(); - prop.setType(ToscaPropertyType.STRING.getType()); - IGraphLockOperation igraphLockOperation = Mockito.mock(IGraphLockOperation.class); - when(igraphLockOperation.lockComponent(any(),any())).thenReturn(StorageOperationStatus.OK); + when(igraphLockOperation.lockComponent(any(), any())).thenReturn(StorageOperationStatus.OK); //Either toscastatus=Either.right(StorageOperationStatus.INVALID_PROPERTY); - Either toscastatus=Either.left(resource); + Either toscastatus = Either.left(resource); when(toscaOperationFacade.getToscaElement("RES01")).thenReturn(toscastatus); - PropertyDefinition propertyDefinition = new PropertyDefinition(); - Either either = Either.right(StorageOperationStatus.CONNECTION_FAILURE); - when(toscaOperationFacade.addAttributeOfResource(anyObject(),anyObject())).thenReturn(either); + AttributeDataDefinition attributeDataDefinition = new AttributeDataDefinition(); + Either either = Either + .right(StorageOperationStatus.CONNECTION_FAILURE); + when(toscaOperationFacade.addAttributeOfResource(anyObject(), anyObject())).thenReturn(either); when(propertyOperation.isPropertyTypeValid(anyObject())).thenReturn(true); - Map data=new HashMap<>(); - data.put("ONE",new DataTypeDefinition()); + Map data = new HashMap<>(); + data.put("ONE", new DataTypeDefinition()); Either, JanusGraphOperationStatus> allDataTypes = Either.left(data); when(applicationDataTypeCache.getAll()).thenReturn(allDataTypes); - when(propertyOperation.isPropertyDefaultValueValid(anyObject(),anyObject())).thenReturn(true); - Either response; + when(propertyOperation.isPropertyDefaultValueValid(anyObject(), anyObject())).thenReturn(true); + Either response; - response = attributeBusinessLogic.createAttribute("RES01", prop, "USR01"); + AttributeDataDefinition attrib = new AttributeDefinition(); + response = attributeBusinessLogic.createAttribute("RES01", attrib, "USR01"); - Assert.assertEquals(true,response.isRight()); + Assert.assertEquals(true, response.isRight()); } @Test public void testgetAttribute_ATTRIBUTE_NOT_FOUND() throws Exception { - Either result; + Either result; Component resource= new Resource(); resource.setLifecycleState(LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT); @@ -353,31 +346,31 @@ public class AttributeBusinessLogicTest extends BaseBusinessLogicMock{ @Test public void testgetAttribute_success() throws Exception { - Either result; + Either result; - Component resource= new Resource(); + Component resource = new Resource(); resource.setLifecycleState(LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT); resource.setIsDeleted(false); resource.setLastUpdaterUserId("USR01"); - PropertyDefinition prop= new PropertyDefinition(); - prop.setUniqueId("ATTR01"); - prop.setParentUniqueId("RES01"); + AttributeDefinition attrib = new AttributeDefinition(); + attrib.setUniqueId("ATTR01"); + attrib.setParentUniqueId("RES01"); - List attr = new ArrayList<>(); - attr.add(prop); + List attr = new ArrayList<>(); + attr.add(attrib); ((Resource) resource).setAttributes(attr); - Either toscastatus=Either.left(resource); + Either toscastatus = Either.left(resource); when(toscaOperationFacade.getToscaElement("RES01")).thenReturn(toscastatus); - result=attributeBusinessLogic.getAttribute("RES01","ATTR01", "USR01"); - Assert.assertEquals(true,result.isLeft()); + result = attributeBusinessLogic.getAttribute("RES01", "ATTR01", "USR01"); + Assert.assertEquals(true, result.isLeft()); } @Test public void testgetAttribute_RESOURCE_NOT_FOUND() throws Exception { - Either result; + Either result; Either toscastatus=Either.right(StorageOperationStatus.PARENT_RESOURCE_NOT_FOUND); when(toscaOperationFacade.getToscaElement("RES01")).thenReturn(toscastatus); @@ -388,7 +381,7 @@ public class AttributeBusinessLogicTest extends BaseBusinessLogicMock{ @Test public void testdeleteAttribute_FAILED_TO_LOCK_COMPONENT() throws Exception { - Either result; + Either result; result=attributeBusinessLogic.deleteAttribute("RES01","ATTR01", "USR01"); Assert.assertEquals(true,result.isRight()); @@ -396,7 +389,7 @@ public class AttributeBusinessLogicTest extends BaseBusinessLogicMock{ @Test public void testdeleteAttribute_get_RESOURCE_from_DB_failed() throws Exception { - Either result; + Either result; Either toscastatus=Either.right(StorageOperationStatus.CONNECTION_FAILURE); when(toscaOperationFacade.getToscaElement("RES01")).thenReturn(toscastatus); @@ -407,7 +400,7 @@ public class AttributeBusinessLogicTest extends BaseBusinessLogicMock{ @Test public void testdeleteAttribute_get_RESOURCE_verification_failed() throws Exception { - Either result; + Either result; Component resource= new Resource(); @@ -430,7 +423,7 @@ public class AttributeBusinessLogicTest extends BaseBusinessLogicMock{ @Test public void testdeleteAttribute_nonexistingresource() throws Exception { - Either result; + Either result; Component resource= new Resource(); @@ -449,7 +442,7 @@ public class AttributeBusinessLogicTest extends BaseBusinessLogicMock{ @Test public void testdeleteAttribute_success() throws Exception { - Either result; + Either result; Component resource= new Resource(); @@ -457,23 +450,21 @@ public class AttributeBusinessLogicTest extends BaseBusinessLogicMock{ resource.setIsDeleted(false); resource.setLastUpdaterUserId("USR01"); + when(igraphLockOperation.lockComponent(any(), any())).thenReturn(StorageOperationStatus.OK); - when(igraphLockOperation.lockComponent(any(),any())).thenReturn(StorageOperationStatus.OK); - - Either toscastatus=Either.left(resource); + Either toscastatus = Either.left(resource); when(toscaOperationFacade.getToscaElement("RES01")).thenReturn(toscastatus); - when(toscaOperationFacade.deleteAttributeOfResource(any(),any())).thenReturn(StorageOperationStatus.OK); + when(toscaOperationFacade.deleteAttributeOfResource(any(), any())).thenReturn(StorageOperationStatus.OK); - PropertyDefinition prop= new PropertyDefinition(); - prop.setUniqueId("ATTR01"); - prop.setParentUniqueId("RES01"); - List attributes = new ArrayList<>(); - attributes.add(prop); + AttributeDefinition attrib = new AttributeDefinition(); + attrib.setUniqueId("ATTR01"); + attrib.setParentUniqueId("RES01"); + List attributes = new ArrayList<>(); + attributes.add(attrib); ((Resource) resource).setAttributes(attributes); - result=attributeBusinessLogic.deleteAttribute("RES01","ATTR01", "USR01"); - Assert.assertEquals(true,result.isLeft()); + result = attributeBusinessLogic.deleteAttribute("RES01", "ATTR01", "USR01"); + Assert.assertEquals(true, result.isLeft()); } - -} \ No newline at end of file +} diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogicTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogicTest.java index 127e1d9aba..f213835406 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogicTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogicTest.java @@ -22,9 +22,12 @@ package org.openecomp.sdc.be.components.impl; import static org.assertj.core.api.Assertions.assertThat; import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; import static org.junit.jupiter.api.Assertions.assertSame; import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; import static org.junit.jupiter.api.DynamicTest.dynamicTest; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anySet; @@ -57,6 +60,8 @@ import org.mockito.Mock; import org.mockito.Mockito; import org.mockito.MockitoAnnotations; import org.mockito.junit.jupiter.MockitoExtension; +import org.mockito.junit.jupiter.MockitoSettings; +import org.mockito.quality.Strictness; import org.openecomp.sdc.be.components.impl.exceptions.ByActionStatusComponentException; import org.openecomp.sdc.be.components.impl.exceptions.ByResponseFormatComponentException; import org.openecomp.sdc.be.components.impl.exceptions.ComponentException; @@ -88,6 +93,7 @@ import org.openecomp.sdc.be.model.ComponentInstance; import org.openecomp.sdc.be.model.ComponentInstanceInput; import org.openecomp.sdc.be.model.ComponentInstancePropInput; import org.openecomp.sdc.be.model.ComponentInstanceProperty; +import org.openecomp.sdc.be.model.ComponentInstanceAttribute; import org.openecomp.sdc.be.model.ComponentParametersView; import org.openecomp.sdc.be.model.DataTypeDefinition; import org.openecomp.sdc.be.model.InputDefinition; @@ -120,6 +126,7 @@ import org.openecomp.sdc.exception.ResponseFormat; */ @ExtendWith(MockitoExtension.class) +@MockitoSettings(strictness = Strictness.LENIENT) class ComponentInstanceBusinessLogicTest { private final static String USER_ID = "jh0003"; @@ -486,8 +493,7 @@ class ComponentInstanceBusinessLogicTest { ComponentInstance responseFormatEither = componentInstanceBusinessLogic .deleteForwardingPathsRelatedTobeDeletedComponentInstance( containerComponentID, containerComponentType, ci); - assertThat(!responseFormatEither.isEmpty()).isEqualTo(true); - + assertFalse(responseFormatEither.isEmpty()); } @Test @@ -624,7 +630,7 @@ class ComponentInstanceBusinessLogicTest { componentInstanceBusinessLogic .getRelationById(COMPONENT_ID, RELATION_ID, USER_ID, component.getComponentType()); } catch (ByActionStatusComponentException e) { - assertSame(e.getActionStatus(), ActionStatus.USER_NOT_FOUND); + assertSame(ActionStatus.USER_NOT_FOUND, e.getActionStatus()); } } @@ -887,7 +893,7 @@ class ComponentInstanceBusinessLogicTest { // default test testSubject = createTestSubject(); result = Deencapsulation.invoke(testSubject, "validateParent", new Object[]{resource, nodeTemplateId}); - assertNotNull(result); + assertFalse(result); } @Test @@ -940,6 +946,7 @@ class ComponentInstanceBusinessLogicTest { testSubject = createTestSubject(); result = Deencapsulation.invoke(testSubject, "findRelation", new Object[]{relationId, requirementCapabilityRelations}); + assertNull(result); } @Test @@ -990,6 +997,7 @@ class ComponentInstanceBusinessLogicTest { testSubject = createTestSubject(); result = Deencapsulation.invoke(testSubject, "updateCapabilityPropertyOnContainerComponent", new Object[]{property, newValue, resource, toInstance, capabilityType, capabilityName}); + assertNull(result); } @Test @@ -1224,7 +1232,7 @@ class ComponentInstanceBusinessLogicTest { @Test void testCreateOrUpdateAttributeValueForCopyPaste() { ComponentInstance serviceComponentInstance = createComponetInstanceFromComponent(service); - ComponentInstanceProperty attribute = new ComponentInstanceProperty(); + ComponentInstanceAttribute attribute = new ComponentInstanceAttribute(); attribute.setType("string"); attribute.setUniqueId("testCreateOrUpdateAttributeValueForCopyPaste"); SchemaDefinition def = Mockito.mock(SchemaDefinition.class); @@ -1234,9 +1242,9 @@ class ComponentInstanceBusinessLogicTest { service.setLastUpdaterUserId(USER_ID); service.setLifecycleState(LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT); - Map> instAttrsMap = new HashMap<>(); - List instAttrsList = new ArrayList<>(); - ComponentInstanceProperty prop = new ComponentInstanceProperty(); + Map> instAttrsMap = new HashMap<>(); + List instAttrsList = new ArrayList<>(); + ComponentInstanceAttribute prop = new ComponentInstanceAttribute(); prop.setUniqueId(attribute.getUniqueId()); instAttrsList.add(prop); instAttrsMap.put(toInstance.getUniqueId(), instAttrsList); @@ -1250,7 +1258,7 @@ class ComponentInstanceBusinessLogicTest { when(toscaOperationFacade.updateComponentInstanceMetadataOfTopologyTemplate(service)) .thenReturn(serviceEitherLeft); - Either result = Deencapsulation + Either result = Deencapsulation .invoke(componentInstanceBusinessLogic, "createOrUpdateAttributeValueForCopyPaste", ComponentTypeEnum.SERVICE, @@ -1264,8 +1272,8 @@ class ComponentInstanceBusinessLogicTest { service.setLifecycleState(oldLifeCycleState); assertThat(result.isLeft()).isTrue(); - ComponentInstanceProperty resultProp = result.left().value(); - assertEquals(resultProp.getPath().size(), 1); + ComponentInstanceAttribute resultProp = result.left().value(); + assertEquals(1, resultProp.getPath().size()); assertEquals(resultProp.getPath().get(0), toInstance.getUniqueId()); } @@ -1496,8 +1504,8 @@ class ComponentInstanceBusinessLogicTest { Optional propertyCandidate = getComponentInstanceProperty(PROP_NAME); - assertThat(propertyCandidate.isPresent()).isTrue(); - assertEquals(propertyCandidate.get().getName(), PROP_NAME); + assertThat(propertyCandidate).isPresent(); + assertEquals(PROP_NAME, propertyCandidate.get().getName()); } @Test diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ImportUtilsTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ImportUtilsTest.java index e47cdc999e..3783c5e1fd 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ImportUtilsTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ImportUtilsTest.java @@ -28,10 +28,12 @@ import org.openecomp.sdc.be.components.impl.ImportUtils.ResultStatusEnum; import org.openecomp.sdc.be.components.impl.ImportUtils.ToscaElementTypeEnum; import org.openecomp.sdc.be.datatypes.elements.PropertyDataDefinition; import org.openecomp.sdc.be.datatypes.elements.SchemaDefinition; +import org.openecomp.sdc.be.model.AttributeDefinition; import org.openecomp.sdc.be.model.HeatParameterDefinition; import org.openecomp.sdc.be.model.InputDefinition; import org.openecomp.sdc.be.model.PropertyConstraint; import org.openecomp.sdc.be.model.PropertyDefinition; +import org.openecomp.sdc.be.datatypes.elements.AttributeDataDefinition; import org.openecomp.sdc.be.model.operations.impl.AnnotationTypeOperations; import org.openecomp.sdc.be.model.tosca.constraints.ValidValuesConstraint; import org.openecomp.sdc.be.utils.TypeUtils; @@ -305,7 +307,7 @@ public class ImportUtilsTest { public void testGetAttributesFromYml() throws IOException { Map toscaJson = (Map) loadJsonFromFile("importToscaWithAttribute.yml"); - Either, ResultStatusEnum> actualAttributes = ImportUtils.getAttributes(toscaJson); + Either, ResultStatusEnum> actualAttributes = ImportUtils.getAttributes(toscaJson); assertTrue(actualAttributes.isLeft()); Map> expectedAttributes = getElements(toscaJson, TypeUtils.ToscaTagNamesEnum.ATTRIBUTES); compareAttributes(expectedAttributes, actualAttributes.left().value()); @@ -364,10 +366,10 @@ public class ImportUtilsTest { } - private void compareAttributes(Map> expected, Map actual) { + private void compareAttributes(Map> expected, Map actual) { Map singleExpectedAttribute; - PropertyDefinition actualAttribute, expectedAttributeModel; + AttributeDataDefinition actualAttribute, expectedAttributeModel; // attributes of resource for (Map.Entry> expectedAttribute : expected.entrySet()) { @@ -379,11 +381,11 @@ public class ImportUtilsTest { expectedAttributeModel = ImportUtils.createModuleAttribute(singleExpectedAttribute); expectedAttributeModel.setName(expectedAttribute.getKey().toString()); - assertEquals(expectedAttributeModel.getDefaultValue(), actualAttribute.getDefaultValue()); - assertEquals(expectedAttributeModel.getDescription(), actualAttribute.getDescription()); - assertEquals(expectedAttributeModel.getName(), actualAttribute.getName()); - assertEquals(expectedAttributeModel.getStatus(), actualAttribute.getStatus()); - assertEquals(expectedAttributeModel.getType(), actualAttribute.getType()); + assertEquals(((AttributeDefinition)expectedAttributeModel).getDefaultValue(), ((AttributeDefinition)actualAttribute).getDefaultValue()); + assertEquals(((AttributeDefinition)expectedAttributeModel).getDescription(), ((AttributeDefinition)actualAttribute).getDescription()); + assertEquals(((AttributeDefinition)expectedAttributeModel).getName(), ((AttributeDefinition)actualAttribute).getName()); + assertEquals(((AttributeDefinition)expectedAttributeModel).getStatus(), ((AttributeDefinition)actualAttribute).getStatus()); + assertEquals(((AttributeDefinition)expectedAttributeModel).getType(), ((AttributeDefinition)actualAttribute).getType()); compareSchemas(expectedAttributeModel.getSchema(), actualAttribute.getSchema()); -- cgit 1.2.3-korg