2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
21 package org.openecomp.sdc.tosca.csar;
24 import static org.junit.Assert.assertEquals;
25 import static org.junit.Assert.assertFalse;
26 import static org.junit.Assert.assertNull;
27 import static org.openecomp.sdc.tosca.csar.ToscaMetaEntry.ENTRY_DEFINITIONS;
28 import static org.openecomp.sdc.tosca.csar.ToscaMetaEntry.ETSI_ENTRY_CHANGE_LOG;
29 import static org.openecomp.sdc.tosca.csar.ToscaMetaEntry.ETSI_ENTRY_MANIFEST;
31 import java.io.IOException;
32 import java.io.InputStream;
34 import org.junit.Test;
38 public class MetadataParsingTest {
41 public void testNoEntryDefinitions() throws IOException {
42 try (InputStream is = getClass()
43 .getResourceAsStream("/vspmanager.csar/metadata/Invalidtosca.meta")) {
44 ToscaMetadata onboardingToscaMetadata = OnboardingToscaMetadata.parseToscaMetadataFile(is);
45 assertFalse(onboardingToscaMetadata.isValid());
46 assertNull(onboardingToscaMetadata.getMetaEntries().get(ENTRY_DEFINITIONS.getName()));
51 public void testValidMetadataFile() throws IOException {
52 try (InputStream is = getClass()
53 .getResourceAsStream("/vspmanager.csar/metadata/Validtosca.meta")) {
54 ToscaMetadata onboardingToscaMetadata = OnboardingToscaMetadata.parseToscaMetadataFile(is);
55 assertEquals("Definitions/MainServiceTemplate.yaml", onboardingToscaMetadata.getMetaEntries().get(
56 ENTRY_DEFINITIONS.getName()));
62 public void testInvalidMetadataFileEmptyKey() throws IOException {
63 try (InputStream is = getClass()
64 .getResourceAsStream("/vspmanager.csar/metadata/InvalidtoscaEmptyKey.meta")) {
65 ToscaMetadata onboardingToscaMetadata = OnboardingToscaMetadata.parseToscaMetadataFile(is);
66 assertFalse(onboardingToscaMetadata.isValid());
71 public void testInvalidMetadataFileEmptyValue() throws IOException {
72 try (InputStream is = getClass()
73 .getResourceAsStream("/vspmanager.csar/metadata/InvalidtoscaEmptyValue.meta")) {
74 ToscaMetadata onboardingToscaMetadata = OnboardingToscaMetadata.parseToscaMetadataFile(is);
75 assertFalse(onboardingToscaMetadata.isValid());
80 public void testValidETSIMetadataFile() throws IOException {
81 try (InputStream is = getClass()
82 .getResourceAsStream("/vspmanager.csar/metadata/ValidETSItosca.meta")) {
83 ToscaMetadata onboardingToscaMetadata = OnboardingToscaMetadata.parseToscaMetadataFile(is);
84 assertEquals("Definitions/MainServiceTemplate.yaml", onboardingToscaMetadata.getMetaEntries().get(
85 ENTRY_DEFINITIONS.getName()));
86 assertEquals("MainServiceTemplate.mf", onboardingToscaMetadata.getMetaEntries().get(ETSI_ENTRY_MANIFEST.getName()));
87 assertEquals("change.log", onboardingToscaMetadata.getMetaEntries().get(ETSI_ENTRY_CHANGE_LOG.getName()));