diff options
Diffstat (limited to 'catalog-model')
5 files changed, 207 insertions, 4 deletions
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/NodeTypeMetadata.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/NodeTypeMetadata.java new file mode 100644 index 0000000000..da83b8f41b --- /dev/null +++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/NodeTypeMetadata.java @@ -0,0 +1,49 @@ +/* + * - + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * 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. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdc.be.model; + +import java.util.List; +import lombok.Data; +import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum; +import org.openecomp.sdc.be.model.category.CategoryDefinition; + +/** + * Holds metadata information about a TOSCA node_type. + */ +@Data +public class NodeTypeMetadata { + + private String name; + private String toscaName; + private String description; + private String contactId; + private String resourceIconPath; + private String model; + private String icon; + private String vendorName; + private String vendorRelease; + private String resourceVendorModelNumber; + private String resourceType = ResourceTypeEnum.VFC.getValue(); + private List<String> tags; + private List<CategoryDefinition> categories; + +} diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/NodeTypesMetadataList.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/NodeTypesMetadataList.java new file mode 100644 index 0000000000..25b9616521 --- /dev/null +++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/NodeTypesMetadataList.java @@ -0,0 +1,35 @@ +/* + * - + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * 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. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdc.be.model; + +import java.util.List; +import lombok.Data; + +/** + * Dto to hold a list of TOSCA node type metadata. + */ +@Data +public class NodeTypesMetadataList { + + private List<NodeTypeMetadata> nodeMetadataList; + +} diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/UploadResourceInfo.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/UploadResourceInfo.java index 752fad2278..dcb01169c6 100644 --- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/UploadResourceInfo.java +++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/UploadResourceInfo.java @@ -21,10 +21,12 @@ package org.openecomp.sdc.be.model; import java.util.ArrayList; import java.util.List; +import lombok.NoArgsConstructor; import org.openecomp.sdc.be.model.category.CategoryDefinition; import org.openecomp.sdc.be.model.category.SubCategoryDefinition; import org.openecomp.sdc.common.api.UploadArtifactInfo; +@NoArgsConstructor public class UploadResourceInfo { private String payloadData; @@ -39,7 +41,6 @@ public class UploadResourceInfo { public UploadResourceInfo(String payload, String payloadName, String description, String category, List<String> tags, List<UploadArtifactInfo> artifactsList, String modelName) { - super(); this.payloadData = payload; this.payloadName = payloadName; this.description = description; @@ -60,9 +61,6 @@ public class UploadResourceInfo { } } - public UploadResourceInfo() { - } - public String getPayloadData() { return payloadData; } diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/mapper/NodeTypeMetadataMapper.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/mapper/NodeTypeMetadataMapper.java new file mode 100644 index 0000000000..feef044b7f --- /dev/null +++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/mapper/NodeTypeMetadataMapper.java @@ -0,0 +1,52 @@ +/* + * - + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * 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. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdc.be.model.mapper; + +import lombok.AccessLevel; +import lombok.NoArgsConstructor; +import org.openecomp.sdc.be.model.NodeTypeMetadata; +import org.openecomp.sdc.be.model.UploadResourceInfo; + +/** + * Responsible to map the {@code NodeTypeMetadata} to and from other classes. + */ +@NoArgsConstructor(access = AccessLevel.PRIVATE) +public class NodeTypeMetadataMapper { + + public static UploadResourceInfo mapTo(final NodeTypeMetadata nodeTypeMetadata) { + var uploadResourceInfo = new UploadResourceInfo(); + uploadResourceInfo.setName(nodeTypeMetadata.getName()); + uploadResourceInfo.setDescription(nodeTypeMetadata.getDescription()); + uploadResourceInfo.setContactId(nodeTypeMetadata.getContactId()); + uploadResourceInfo.setIcon(nodeTypeMetadata.getIcon()); + uploadResourceInfo.setResourceIconPath(nodeTypeMetadata.getResourceIconPath()); + uploadResourceInfo.setVendorName(nodeTypeMetadata.getVendorName()); + uploadResourceInfo.setModel(nodeTypeMetadata.getModel()); + uploadResourceInfo.setVendorRelease(nodeTypeMetadata.getVendorRelease()); + uploadResourceInfo.setResourceVendorModelNumber(nodeTypeMetadata.getResourceVendorModelNumber()); + uploadResourceInfo.setResourceType(nodeTypeMetadata.getResourceType()); + uploadResourceInfo.setTags(nodeTypeMetadata.getTags()); + uploadResourceInfo.setCategories(nodeTypeMetadata.getCategories()); + return uploadResourceInfo; + } + +} diff --git a/catalog-model/src/test/java/org/openecomp/sdc/be/model/mapper/NodeTypeMetadataMapperTest.java b/catalog-model/src/test/java/org/openecomp/sdc/be/model/mapper/NodeTypeMetadataMapperTest.java new file mode 100644 index 0000000000..1121503228 --- /dev/null +++ b/catalog-model/src/test/java/org/openecomp/sdc/be/model/mapper/NodeTypeMetadataMapperTest.java @@ -0,0 +1,69 @@ +/* + * - + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * 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. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdc.be.model.mapper; + +import static org.junit.jupiter.api.Assertions.*; + +import java.util.List; +import org.junit.jupiter.api.Test; +import org.openecomp.sdc.be.model.NodeTypeMetadata; +import org.openecomp.sdc.be.model.UploadResourceInfo; +import org.openecomp.sdc.be.model.category.CategoryDefinition; + +class NodeTypeMetadataMapperTest { + + @Test + void mapToUploadResourceInfoTest() { + final var nodeTypeMetadata = new NodeTypeMetadata(); + nodeTypeMetadata.setName("name"); + nodeTypeMetadata.setDescription("description"); + nodeTypeMetadata.setContactId("contactId"); + nodeTypeMetadata.setIcon("icon"); + nodeTypeMetadata.setResourceIconPath("resourceIconPath"); + nodeTypeMetadata.setVendorName("vendorName"); + nodeTypeMetadata.setModel("model"); + nodeTypeMetadata.setVendorRelease("vendorRelease"); + nodeTypeMetadata.setResourceVendorModelNumber("resourceVendorModelNumber"); + nodeTypeMetadata.setResourceType("resourceType"); + nodeTypeMetadata.setTags(List.of("tag1", "tag2")); + nodeTypeMetadata.setCategories(List.of(new CategoryDefinition())); + + final UploadResourceInfo uploadResourceInfo = NodeTypeMetadataMapper.mapTo(nodeTypeMetadata); + assertEquals(nodeTypeMetadata.getName(), uploadResourceInfo.getName()); + assertEquals(nodeTypeMetadata.getDescription(), uploadResourceInfo.getDescription()); + assertEquals(nodeTypeMetadata.getContactId(), uploadResourceInfo.getContactId()); + assertEquals(nodeTypeMetadata.getResourceIconPath(), uploadResourceInfo.getResourceIconPath()); + assertEquals(nodeTypeMetadata.getVendorName(), uploadResourceInfo.getVendorName()); + assertEquals(nodeTypeMetadata.getModel(), uploadResourceInfo.getModel()); + assertEquals(nodeTypeMetadata.getVendorRelease(), uploadResourceInfo.getVendorRelease()); + assertEquals(nodeTypeMetadata.getResourceVendorModelNumber(), uploadResourceInfo.getResourceVendorModelNumber()); + assertEquals(nodeTypeMetadata.getResourceType(), uploadResourceInfo.getResourceType()); + assertEquals(nodeTypeMetadata.getTags(), uploadResourceInfo.getTags()); + assertEquals(nodeTypeMetadata.getCategories(), uploadResourceInfo.getCategories()); + + final var nodeTypeMetadata1 = new NodeTypeMetadata(); + nodeTypeMetadata1.setIcon("icon"); + final UploadResourceInfo uploadResourceInfo1 = NodeTypeMetadataMapper.mapTo(nodeTypeMetadata1); + assertEquals(nodeTypeMetadata1.getIcon(), uploadResourceInfo1.getResourceIconPath()); + } + +}
\ No newline at end of file |