Onboard PNF software version
[sdc.git] / common-be / src / test / java / org / openecomp / sdc / be / csar / pnf / SoftwareInformationArtifactYamlParserTest.java
1 /*
2  * ============LICENSE_START=======================================================
3  *  Copyright (C) 2019 Nordix Foundation
4  *  ================================================================================
5  *  Licensed under the Apache License, Version 2.0 (the "License");
6  *  you may not use this file except in compliance with the License.
7  *  You may obtain a copy of the License at
8  *
9  *        http://www.apache.org/licenses/LICENSE-2.0
10  *  Unless required by applicable law or agreed to in writing, software
11  *  distributed under the License is distributed on an "AS IS" BASIS,
12  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  *  See the License for the specific language governing permissions and
14  *  limitations under the License.
15  *
16  *  SPDX-License-Identifier: Apache-2.0
17  *  ============LICENSE_END=========================================================
18  */
19
20 package org.openecomp.sdc.be.csar.pnf;
21
22 import static org.hamcrest.CoreMatchers.equalTo;
23 import static org.hamcrest.CoreMatchers.hasItems;
24 import static org.hamcrest.CoreMatchers.is;
25 import static org.junit.Assert.assertThat;
26
27 import java.io.IOException;
28 import java.util.Optional;
29 import org.junit.Test;
30 import org.openecomp.sdc.be.test.util.TestResourcesHandler;
31
32 public class SoftwareInformationArtifactYamlParserTest {
33
34     @Test
35     public void parse() throws IOException {
36         //given
37         final byte[] resourceAsByteArray = TestResourcesHandler
38             .getResourceAsByteArray("artifacts/pnfSoftwareInformation/pnf-sw-information.yaml");
39         //when
40         final Optional<PnfSoftwareInformation> pnfSoftwareInformation = SoftwareInformationArtifactYamlParser
41             .parse(resourceAsByteArray);
42         //then
43         final PnfSoftwareVersion expectedPnfSoftwareVersion1 = new PnfSoftwareVersion("version1", "first software version of PNF");
44         final PnfSoftwareVersion expectedPnfSoftwareVersion2 = new PnfSoftwareVersion("version2", "second software version of PNF");
45         assertThat("The software information should be parsed", pnfSoftwareInformation.isPresent(), is(true));
46         pnfSoftwareInformation.ifPresent(softwareInformation -> {
47             assertThat("The software information provider should be as expected",
48                 softwareInformation.getProvider(), is(equalTo("Ericsson")));
49             assertThat("The software information description should be as expected",
50                 softwareInformation.getDescription(), is(equalTo("pnf software information")));
51             assertThat("The software information version should be as expected",
52                 softwareInformation.getVersion(), is(equalTo("1.0")));
53             assertThat("The software versions should contain expected versions",
54                 softwareInformation.getSoftwareVersionSet(),
55                 hasItems(expectedPnfSoftwareVersion1, expectedPnfSoftwareVersion2));
56         });
57     }
58
59 }