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.ToscaMetaEntryVersion261.ENTRY_DEFINITIONS;
28 import static org.openecomp.sdc.tosca.csar.ToscaMetaEntryVersion261.ETSI_ENTRY_CHANGE_LOG;
29 import static org.openecomp.sdc.tosca.csar.ToscaMetaEntryVersion261.ETSI_ENTRY_MANIFEST;
31 import java.io.IOException;
32 import java.io.InputStream;
33 import org.junit.Test;
37 public class MetadataParsingTest {
40 public void testNoEntryDefinitions() throws IOException {
41 try (InputStream is = getClass()
42 .getResourceAsStream("/vspmanager.csar/metadata/Invalidtosca.meta")) {
43 ToscaMetadata onboardingToscaMetadata = OnboardingToscaMetadata.parseToscaMetadataFile(is);
44 assertFalse(onboardingToscaMetadata.isValid());
45 assertNull(onboardingToscaMetadata.getMetaEntries().get(ENTRY_DEFINITIONS.getName()));
50 public void testValidMetadataFile() throws IOException {
51 try (InputStream is = getClass()
52 .getResourceAsStream("/vspmanager.csar/metadata/Validtosca.meta")) {
53 ToscaMetadata onboardingToscaMetadata = OnboardingToscaMetadata.parseToscaMetadataFile(is);
54 assertEquals("Definitions/MainServiceTemplate.yaml", onboardingToscaMetadata.getMetaEntries().get(
55 ENTRY_DEFINITIONS.getName()));
61 public void testInvalidMetadataFileEmptyKey() throws IOException {
62 try (InputStream is = getClass()
63 .getResourceAsStream("/vspmanager.csar/metadata/InvalidtoscaEmptyKey.meta")) {
64 ToscaMetadata onboardingToscaMetadata = OnboardingToscaMetadata.parseToscaMetadataFile(is);
65 assertFalse(onboardingToscaMetadata.isValid());
70 public void testInvalidMetadataFileEmptyValue() throws IOException {
71 try (InputStream is = getClass()
72 .getResourceAsStream("/vspmanager.csar/metadata/InvalidtoscaEmptyValue.meta")) {
73 ToscaMetadata onboardingToscaMetadata = OnboardingToscaMetadata.parseToscaMetadataFile(is);
74 assertFalse(onboardingToscaMetadata.isValid());
79 public void testValidETSIMetadataFile() throws IOException {
80 try (InputStream is = getClass()
81 .getResourceAsStream("/vspmanager.csar/metadata/ValidETSItosca.meta")) {
82 ToscaMetadata onboardingToscaMetadata = OnboardingToscaMetadata.parseToscaMetadataFile(is);
83 assertEquals("Definitions/MainServiceTemplate.yaml", onboardingToscaMetadata.getMetaEntries().get(
84 ENTRY_DEFINITIONS.getName()));
85 assertEquals("MainServiceTemplate.mf", onboardingToscaMetadata.getMetaEntries().get(ETSI_ENTRY_MANIFEST.getName()));
86 assertEquals("change.log", onboardingToscaMetadata.getMetaEntries().get(ETSI_ENTRY_CHANGE_LOG.getName()));