1 package org.openecomp.sdc.vendorsoftwareproduct.upload.csar;
4 import org.openecomp.sdc.common.errors.Messages;
5 import org.openecomp.sdc.vendorsoftwareproduct.impl.orchestration.csar.OnboardingManifest;
7 import java.io.IOException;
8 import java.io.InputStream;
10 import static org.junit.Assert.assertEquals;
11 import static org.junit.Assert.assertFalse;
12 import static org.junit.Assert.assertTrue;
14 public class ManifestParsingTest {
17 public void testSuccessfulParsing() throws IOException {
18 try (InputStream is = getClass()
19 .getResourceAsStream("/vspmanager.csar/manifest/ValidTosca.mf")) {
20 OnboardingManifest onboardingManifest = new OnboardingManifest(is);
21 assertTrue(onboardingManifest.isValid());
22 assertEquals(onboardingManifest.getMetadata().size(), 4);
23 assertEquals(onboardingManifest.getSources().size(), 5);
28 public void testNoMetadataParsing() throws IOException {
29 try (InputStream is = getClass()
30 .getResourceAsStream("/vspmanager.csar/manifest/InvalidTosca1.mf")) {
31 OnboardingManifest onboardingManifest = new OnboardingManifest(is);
32 assertFalse(onboardingManifest.isValid());
33 assertTrue(onboardingManifest.getErrors().stream().anyMatch(error -> error
34 .contains(Messages.MANIFEST_INVALID_LINE.getErrorMessage().substring(0, 10))));
39 public void testBrokenMDParsing() throws IOException {
40 try (InputStream is = getClass()
41 .getResourceAsStream("/vspmanager.csar/manifest/InvalidTosca2.mf")) {
42 OnboardingManifest onboardingManifest = new OnboardingManifest(is);
43 assertFalse(onboardingManifest.isValid());
44 assertTrue(onboardingManifest.getErrors().stream().anyMatch(error -> error
45 .contains(Messages.MANIFEST_INVALID_LINE.getErrorMessage().substring(0, 10))));
50 public void testNoMetaParsing() throws IOException {
51 try (InputStream is = getClass()
52 .getResourceAsStream("/vspmanager.csar/manifest/InvalidTosca4.mf")) {
53 OnboardingManifest onboardingManifest = new OnboardingManifest(is);
54 assertFalse(onboardingManifest.isValid());
55 assertTrue(onboardingManifest.getErrors().stream().anyMatch(error -> error
56 .contains(Messages.MANIFEST_NO_METADATA.getErrorMessage().substring(0, 10))));