Update aai-parent in babel to 1.13.3
[aai/babel.git] / src / test / java / org / onap / aai / babel / csar / vnfcatalog / ConfigurationsToBabelArtifactConverterTest.java
1 /**
2  * ============LICENSE_START=======================================================
3  * org.onap.aai
4  * ================================================================================
5  * Copyright (c) 2017-2019 AT&T Intellectual Property. All rights reserved.
6  * Copyright (c) 2017-2019 European Software Marketing Ltd.
7  * ===============================================================================
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  *       http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  * ============LICENSE_END=========================================================
20  */
21
22 package org.onap.aai.babel.csar.vnfcatalog;
23
24 import static org.hamcrest.CoreMatchers.equalTo;
25 import static org.hamcrest.CoreMatchers.is;
26 import static org.hamcrest.CoreMatchers.nullValue;
27 import static org.hamcrest.MatcherAssert.assertThat;
28
29 import com.google.gson.Gson;
30 import com.google.gson.reflect.TypeToken;
31 import java.io.IOException;
32 import java.util.ArrayList;
33 import java.util.List;
34 import org.junit.jupiter.api.Test;
35 import org.onap.aai.babel.service.data.BabelArtifact;
36 import org.onap.aai.babel.service.data.BabelArtifact.ArtifactType;
37 import org.onap.aai.babel.util.ArtifactTestUtils;
38
39 /**
40  * Tests {@link ConfigurationsToBabelArtifactConverter}.
41  */
42 public class ConfigurationsToBabelArtifactConverterTest {
43     @Test
44     public void testNullListSupplied() {
45         assertThat(ConfigurationsToBabelArtifactConverter.convert(null), is(nullValue()));
46     }
47
48     @Test
49     public void testEmptyListSupplied() {
50         assertThat(ConfigurationsToBabelArtifactConverter.convert(new ArrayList<>()), is(nullValue()));
51     }
52
53     @Test
54     public void testValidListSupplied() throws IOException {
55         String expectedJson = new ArtifactTestUtils().getRequestJson("vnfVendorImageConfigurations.json");
56         List<VendorImageConfiguration> configurations =
57                 new Gson().fromJson(expectedJson, new TypeToken<ArrayList<VendorImageConfiguration>>() {}.getType());
58
59         BabelArtifact artifact = ConfigurationsToBabelArtifactConverter.convert(configurations);
60
61         assertThat(artifact.getName(), is(equalTo("vnfVendorImageConfigurations")));
62         assertThat(artifact.getType(), is(equalTo(ArtifactType.VNFCATALOG)));
63         assertThat(artifact.getPayload(), is(equalTo(expectedJson)));
64     }
65 }